1 /* A Bison parser, made by GNU Bison 2.1. */
3 /* Skeleton parser for Yacc-like parsing with Bison,
4 Copyright (C) 1984, 1989, 1990, 2000, 2001, 2002, 2003, 2004, 2005 Free Software Foundation, Inc.
6 This program is free software; you can redistribute it and/or modify
7 it under the terms of the GNU General Public License as published by
8 the Free Software Foundation; either version 2, or (at your option)
11 This program is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 GNU General Public License for more details.
16 You should have received a copy of the GNU General Public License
17 along with this program; if not, write to the Free Software
18 Foundation, Inc., 51 Franklin Street, Fifth Floor,
19 Boston, MA 02110-1301, USA. */
21 /* As a special exception, when this file is copied by Bison into a
22 Bison output file, you may use that output file without restriction.
23 This special exception was added by the Free Software Foundation
24 in version 1.24 of Bison. */
26 /* Written by Richard Stallman by simplifying the original so called
27 ``semantic'' parser. */
29 /* All symbols defined below should begin with yy or YY, to avoid
30 infringing on user name space. This should be done even for local
31 variables, as they might otherwise be expanded by user macros.
32 There are some unavoidable exceptions within include files to
33 define necessary library symbols; they are noted "INFRINGES ON
34 USER NAME SPACE" below. */
36 /* Identify Bison output. */
40 #define YYBISON_VERSION "2.1"
43 #define YYSKELETON_NAME "yacc.c"
48 /* Using locations. */
49 #define YYLSP_NEEDED 0
56 /* Put the tokens into the symbol table, so that GDB and other debuggers
86 /* Copy the first part of user declarations. */
87 #line 21 "itbl-parse.y"
92 Yacc grammar for instruction table entries.
94 =======================================================================
95 Original Instruction table specification document:
97 MIPS Coprocessor Table Specification
98 ====================================
100 This document describes the format of the MIPS coprocessor table. The
101 table specifies a list of valid functions, data registers and control
102 registers that can be used in coprocessor instructions. This list,
103 together with the coprocessor instruction classes listed below,
104 specifies the complete list of coprocessor instructions that will
105 be recognized and assembled by the GNU assembler. In effect,
106 this makes the GNU assembler table-driven, where the table is
107 specified by the programmer.
109 The table is an ordinary text file that the GNU assembler reads when
110 it starts. Using the information in the table, the assembler
111 generates an internal list of valid coprocessor registers and
112 functions. The assembler uses this internal list in addition to the
113 standard MIPS registers and instructions which are built-in to the
114 assembler during code generation.
116 To specify the coprocessor table when invoking the GNU assembler, use
117 the command line option "--itbl file", where file is the
118 complete name of the table, including path and extension.
122 gas -t cop.tbl test.s -o test.o
123 gas -t /usr/local/lib/cop.tbl test.s -o test.o
124 gas --itbl d:\gnu\data\cop.tbl test.s -o test.o
126 Only one table may be supplied during a single invocation of
133 Below is a list of the valid coprocessor instruction classes for
134 any given coprocessor "z". These instructions are already recognized
135 by the assembler, and are listed here only for reference.
137 Class format instructions
138 -------------------------------------------------
141 LWCz rt,offset (base)
142 SWCz rt,offset (base)
162 LDCz rt,offset (base)
163 SDCz rt,offset (base)
169 The coprocessor table defines coprocessor-specific registers that can
170 be used with all of the above classes of instructions, where
171 appropriate. It also defines additional coprocessor-specific
172 functions for Class3 (COPz cofun) instructions, Thus, the table allows
173 the programmer to use convenient mnemonics and operands for these
174 functions, instead of the COPz mmenmonic and cofun operand.
176 The names of the MIPS general registers and their aliases are defined
177 by the assembler and will be recognized as valid register names by the
178 assembler when used (where allowed) in coprocessor instructions.
179 However, the names and values of all coprocessor data and control
180 register mnemonics must be specified in the coprocessor table.
186 Here is the grammar for the coprocessor table:
190 entry -> [z entrydef] [comment] '\n'
192 entrydef -> type name val
193 entrydef -> 'insn' name val funcdef ; type of entry (instruction)
195 z -> 'p'['0'..'3'] ; processor number
196 type -> ['dreg' | 'creg' | 'greg' ] ; type of entry (register)
197 ; 'dreg', 'creg' or 'greg' specifies a data, control, or general
198 ; register mnemonic, respectively
199 name -> [ltr|dec]* ; mnemonic of register/function
200 val -> [dec|hex] ; register/function number (integer constant)
202 funcdef -> frange flags fields
203 ; bitfield range for opcode
204 ; list of fields' formats
206 field -> [','] ftype frange flags
207 flags -> ['*' flagexpr]
208 flagexpr -> '[' flagexpr ']'
209 flagexpr -> val '|' flagexpr
210 ftype -> [ type | 'immed' | 'addr' ]
211 ; 'immed' specifies an immediate value; see grammar for "val" above
212 ; 'addr' specifies a C identifier; name of symbol to be resolved at
214 frange -> ':' val '-' val ; starting to ending bit positions, where
215 ; where 0 is least significant bit
216 frange -> (null) ; default range of 31-0 will be assumed
218 comment -> [';'|'#'] [char]*
219 char -> any printable character
220 ltr -> ['a'..'z'|'A'..'Z']
221 dec -> ['0'..'9']* ; value in decimal
222 hex -> '0x'['0'..'9' | 'a'..'f' | 'A'..'F']* ; value in hexadecimal
232 p1 dreg d1 1 ; data register "d1" for COP1 has value 1
233 p1 creg c3 3 ; ctrl register "c3" for COP1 has value 3
234 p3 func fill 0x1f:24-20 ; function "fill" for COP3 has value 31 and
237 will allow the assembler to accept the following coprocessor instructions:
242 Here, the general purpose register "$2", and instruction "LWC1", are standard
243 mnemonics built-in to the MIPS assembler.
250 p3 dreg d3 3 ; data register "d3" for COP3 has value 3
251 p3 creg c2 22 ; control register "c2" for COP3 has value 22
252 p3 func fee 0x1f:24-20 dreg:17-13 creg:12-8 immed:7-0
253 ; function "fee" for COP3 has value 31, and 3 fields
254 ; consisting of a data register, a control register,
255 ; and an immediate value.
257 will allow the assembler to accept the following coprocessor instruction:
261 and will emit the object code:
263 31-26 25 24-20 19-18 17-13 12-8 7-0
264 COPz CO fun dreg creg immed
265 010011 1 11111 00 00011 10110 00000001
274 p3 dreg d3 3 ; data register "d3" for COP3 has value 3
275 p3 creg c2 22 ; control register "c2" for COP3 has value 22
276 p3 func fuu 0x01f00001 dreg:17-13 creg:12-8
278 will allow the assembler to accept the following coprocessor
283 and will emit the object code:
285 31-26 25 24-20 19-18 17-13 12-8 7-0
286 COPz CO fun dreg creg
287 010011 1 11111 00 00011 10110 00000001
291 In this way, the programmer can force arbitrary bits of an instruction
292 to have predefined values.
294 =======================================================================
298 To handle more than one bit position range within an instruction,
299 use 0s to mask out the ranges which don't apply.
300 May decide to modify the syntax to allow commas separate multiple
301 ranges within an instruction (range','range).
304 The number of parms argument to the function entry
305 was deleted from the original format such that we now count the fields.
308 FIXME! should really change lexical analyzer
309 to recognize 'dreg' etc. in context sensitive way.
310 Currently function names or mnemonics may be incorrectly parsed as keywords
312 FIXME! hex is ambiguous with any digit
317 #include "itbl-lex.h"
318 #include "itbl-ops.h"
331 #define DBG(x) printf x
337 #define DBGL2(x) printf x
342 static int sbit
, ebit
;
343 static struct itbl_entry
*insn
=0;
344 static int yyerror
PARAMS ((const char *));
348 /* Enabling traces. */
353 /* Enabling verbose error messages. */
354 #ifdef YYERROR_VERBOSE
355 # undef YYERROR_VERBOSE
356 # define YYERROR_VERBOSE 1
358 # define YYERROR_VERBOSE 0
361 /* Enabling the token table. */
362 #ifndef YYTOKEN_TABLE
363 # define YYTOKEN_TABLE 0
366 #if ! defined (YYSTYPE) && ! defined (YYSTYPE_IS_DECLARED)
367 #line 282 "itbl-parse.y"
368 typedef union YYSTYPE
{
374 /* Line 196 of yacc.c. */
375 #line 376 "itbl-parse.c"
376 # define yystype YYSTYPE /* obsolescent; will be withdrawn */
377 # define YYSTYPE_IS_DECLARED 1
378 # define YYSTYPE_IS_TRIVIAL 1
383 /* Copy the second part of user declarations. */
386 /* Line 219 of yacc.c. */
387 #line 388 "itbl-parse.c"
389 #if ! defined (YYSIZE_T) && defined (__SIZE_TYPE__)
390 # define YYSIZE_T __SIZE_TYPE__
392 #if ! defined (YYSIZE_T) && defined (size_t)
393 # define YYSIZE_T size_t
395 #if ! defined (YYSIZE_T) && (defined (__STDC__) || defined (__cplusplus))
396 # include <stddef.h> /* INFRINGES ON USER NAME SPACE */
397 # define YYSIZE_T size_t
399 #if ! defined (YYSIZE_T)
400 # define YYSIZE_T unsigned int
406 # include <libintl.h> /* INFRINGES ON USER NAME SPACE */
407 # define YY_(msgid) dgettext ("bison-runtime", msgid)
411 # define YY_(msgid) msgid
415 #if ! defined (yyoverflow) || YYERROR_VERBOSE
417 /* The parser invokes alloca or malloc; define the necessary symbols. */
419 # ifdef YYSTACK_USE_ALLOCA
420 # if YYSTACK_USE_ALLOCA
422 # define YYSTACK_ALLOC __builtin_alloca
424 # define YYSTACK_ALLOC alloca
425 # if defined (__STDC__) || defined (__cplusplus)
426 # include <stdlib.h> /* INFRINGES ON USER NAME SPACE */
427 # define YYINCLUDED_STDLIB_H
433 # ifdef YYSTACK_ALLOC
434 /* Pacify GCC's `empty if-body' warning. */
435 # define YYSTACK_FREE(Ptr) do { /* empty */; } while (0)
436 # ifndef YYSTACK_ALLOC_MAXIMUM
437 /* The OS might guarantee only one guard page at the bottom of the stack,
438 and a page size can be as small as 4096 bytes. So we cannot safely
439 invoke alloca (N) if N exceeds 4096. Use a slightly smaller number
440 to allow for a few compiler-allocated temporary stack slots. */
441 # define YYSTACK_ALLOC_MAXIMUM 4032 /* reasonable circa 2005 */
444 # define YYSTACK_ALLOC YYMALLOC
445 # define YYSTACK_FREE YYFREE
446 # ifndef YYSTACK_ALLOC_MAXIMUM
447 # define YYSTACK_ALLOC_MAXIMUM ((YYSIZE_T) -1)
453 # define YYMALLOC malloc
454 # if (! defined (malloc) && ! defined (YYINCLUDED_STDLIB_H) \
455 && (defined (__STDC__) || defined (__cplusplus)))
456 void *malloc (YYSIZE_T
); /* INFRINGES ON USER NAME SPACE */
461 # if (! defined (free) && ! defined (YYINCLUDED_STDLIB_H) \
462 && (defined (__STDC__) || defined (__cplusplus)))
463 void free (void *); /* INFRINGES ON USER NAME SPACE */
470 #endif /* ! defined (yyoverflow) || YYERROR_VERBOSE */
473 #if (! defined (yyoverflow) \
474 && (! defined (__cplusplus) \
475 || (defined (YYSTYPE_IS_TRIVIAL) && YYSTYPE_IS_TRIVIAL)))
477 /* A type that is properly aligned for any stack member. */
484 /* The size of the maximum gap between one aligned stack and the next. */
485 # define YYSTACK_GAP_MAXIMUM (sizeof (union yyalloc) - 1)
487 /* The size of an array large to enough to hold all stacks, each with
489 # define YYSTACK_BYTES(N) \
490 ((N) * (sizeof (short int) + sizeof (YYSTYPE)) \
491 + YYSTACK_GAP_MAXIMUM)
493 /* Copy COUNT objects from FROM to TO. The source and destination do
496 # if defined (__GNUC__) && 1 < __GNUC__
497 # define YYCOPY(To, From, Count) \
498 __builtin_memcpy (To, From, (Count) * sizeof (*(From)))
500 # define YYCOPY(To, From, Count) \
504 for (yyi = 0; yyi < (Count); yyi++) \
505 (To)[yyi] = (From)[yyi]; \
511 /* Relocate STACK from its old location to the new one. The
512 local variables YYSIZE and YYSTACKSIZE give the old and new number of
513 elements in the stack, and YYPTR gives the new location of the
514 stack. Advance YYPTR to a properly aligned location for the next
516 # define YYSTACK_RELOCATE(Stack) \
519 YYSIZE_T yynewbytes; \
520 YYCOPY (&yyptr->Stack, Stack, yysize); \
521 Stack = &yyptr->Stack; \
522 yynewbytes = yystacksize * sizeof (*Stack) + YYSTACK_GAP_MAXIMUM; \
523 yyptr += yynewbytes / sizeof (*yyptr); \
529 #if defined (__STDC__) || defined (__cplusplus)
530 typedef signed char yysigned_char
;
532 typedef short int yysigned_char
;
535 /* YYFINAL -- State number of the termination state. */
537 /* YYLAST -- Last index in YYTABLE. */
540 /* YYNTOKENS -- Number of terminals. */
542 /* YYNNTS -- Number of nonterminals. */
544 /* YYNRULES -- Number of rules. */
546 /* YYNRULES -- Number of states. */
549 /* YYTRANSLATE(YYLEX) -- Bison symbol number corresponding to YYLEX. */
551 #define YYMAXUTOK 267
553 #define YYTRANSLATE(YYX) \
554 ((unsigned int) (YYX) <= YYMAXUTOK ? yytranslate[YYX] : YYUNDEFTOK)
556 /* YYTRANSLATE[YYLEX] -- Bison symbol number corresponding to YYLEX. */
557 static const unsigned char yytranslate
[] =
559 0, 2, 2, 2, 2, 2, 2, 2, 2, 2,
560 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
561 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
562 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
563 2, 2, 17, 2, 13, 19, 2, 2, 2, 2,
564 2, 2, 2, 2, 2, 2, 2, 2, 18, 2,
565 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
566 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
567 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
568 2, 15, 2, 16, 2, 2, 2, 2, 2, 2,
569 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
570 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
571 2, 2, 2, 2, 14, 2, 2, 2, 2, 2,
572 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
573 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
574 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
575 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
576 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
577 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
578 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
579 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
580 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
581 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
582 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
583 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
584 2, 2, 2, 2, 2, 2, 1, 2, 3, 4,
585 5, 6, 7, 8, 9, 10, 11, 12
589 /* YYPRHS[YYN] -- Index of the first RHS symbol of rule number YYN in
591 static const unsigned char yyprhs
[] =
593 0, 0, 3, 5, 8, 9, 15, 16, 26, 28,
594 31, 35, 38, 39, 41, 43, 45, 49, 53, 57,
595 59, 62, 63, 68, 69, 71, 73, 75, 77, 79
598 /* YYRHS -- A `-1'-separated list of the rules' RHS. */
599 static const yysigned_char yyrhs
[] =
601 21, 0, -1, 22, -1, 23, 22, -1, -1, 31,
602 32, 33, 34, 11, -1, -1, 31, 8, 33, 34,
603 30, 29, 24, 25, 11, -1, 11, -1, 1, 11,
604 -1, 13, 27, 25, -1, 27, 25, -1, -1, 32,
605 -1, 7, -1, 6, -1, 26, 30, 29, -1, 9,
606 14, 28, -1, 15, 28, 16, -1, 9, -1, 17,
607 28, -1, -1, 18, 9, 19, 9, -1, -1, 12,
608 -1, 3, -1, 4, -1, 5, -1, 10, -1, 9,
612 /* YYRLINE[YYN] -- source line where rule number YYN was defined. */
613 static const unsigned short int yyrline
[] =
615 0, 299, 299, 303, 304, 308, 315, 314, 323, 324,
616 328, 329, 330, 334, 339, 344, 352, 361, 365, 369,
617 376, 382, 388, 395, 402, 410, 415, 420, 428, 444
621 #if YYDEBUG || YYERROR_VERBOSE || YYTOKEN_TABLE
622 /* YYTNAME[SYMBOL-NUM] -- String name of the symbol SYMBOL-NUM.
623 First, the terminals, then, starting at YYNTOKENS, nonterminals. */
624 static const char *const yytname
[] =
626 "$end", "error", "$undefined", "DREG", "CREG", "GREG", "IMMED", "ADDR",
627 "INSN", "NUM", "ID", "NL", "PNUM", "','", "'|'", "'['", "']'", "'*'",
628 "':'", "'-'", "$accept", "insntbl", "entrys", "entry", "@1",
629 "fieldspecs", "ftype", "fieldspec", "flagexpr", "flags", "range", "pnum",
630 "regtype", "name", "value", 0
635 /* YYTOKNUM[YYLEX-NUM] -- Internal token number corresponding to
637 static const unsigned short int yytoknum
[] =
639 0, 256, 257, 258, 259, 260, 261, 262, 263, 264,
640 265, 266, 267, 44, 124, 91, 93, 42, 58, 45
644 /* YYR1[YYN] -- Symbol number of symbol that rule YYN derives. */
645 static const unsigned char yyr1
[] =
647 0, 20, 21, 22, 22, 23, 24, 23, 23, 23,
648 25, 25, 25, 26, 26, 26, 27, 28, 28, 28,
649 29, 29, 30, 30, 31, 32, 32, 32, 33, 34
652 /* YYR2[YYN] -- Number of symbols composing right hand side of rule YYN. */
653 static const unsigned char yyr2
[] =
655 0, 2, 1, 2, 0, 5, 0, 9, 1, 2,
656 3, 2, 0, 1, 1, 1, 3, 3, 3, 1,
657 2, 0, 4, 0, 1, 1, 1, 1, 1, 1
660 /* YYDEFACT[STATE-NAME] -- Default rule to reduce with in state
661 STATE-NUM when YYTABLE doesn't specify something else to do. Zero
662 means the default is an error. */
663 static const unsigned char yydefact
[] =
665 0, 0, 8, 24, 0, 2, 0, 0, 9, 1,
666 3, 25, 26, 27, 0, 0, 28, 0, 0, 29,
667 23, 0, 0, 21, 5, 0, 0, 6, 0, 19,
668 0, 20, 12, 22, 0, 0, 15, 14, 0, 0,
669 23, 12, 13, 17, 18, 12, 7, 21, 11, 10,
673 /* YYDEFGOTO[NTERM-NUM]. */
674 static const yysigned_char yydefgoto
[] =
676 -1, 4, 5, 6, 32, 39, 40, 41, 31, 27,
680 /* YYPACT[STATE-NUM] -- Index in YYTABLE of the portion describing
682 #define YYPACT_NINF -16
683 static const yysigned_char yypact
[] =
685 0, -9, -16, -16, 10, -16, 0, 12, -16, -16,
686 -16, -16, -16, -16, 3, 3, -16, 9, 9, -16,
687 11, 8, 19, 15, -16, 14, -6, -16, 25, 21,
688 -6, -16, 1, -16, -6, 20, -16, -16, 18, 26,
689 11, 1, -16, -16, -16, 1, -16, 15, -16, -16,
693 /* YYPGOTO[NTERM-NUM]. */
694 static const yysigned_char yypgoto
[] =
696 -16, -16, 32, -16, -16, -15, -16, 2, -3, -8,
700 /* YYTABLE[YYPACT[STATE-NUM]]. What to do in state STATE-NUM. If
701 positive, shift that token. If negative, reduce the rule which
702 number is the opposite. If zero, do what YYDEFACT says.
703 If YYTABLE_NINF, syntax error. */
704 #define YYTABLE_NINF -5
705 static const yysigned_char yytable
[] =
707 -4, 1, 8, 29, 11, 12, 13, 36, 37, 30,
708 9, 2, 3, 16, 38, 11, 12, 13, 19, 24,
709 14, 11, 12, 13, 36, 37, 48, 35, 25, 22,
710 49, 43, 26, 28, 33, 34, 44, 46, 10, 50,
711 45, 15, 18, 0, 47, 0, 21
714 static const yysigned_char yycheck
[] =
716 0, 1, 11, 9, 3, 4, 5, 6, 7, 15,
717 0, 11, 12, 10, 13, 3, 4, 5, 9, 11,
718 8, 3, 4, 5, 6, 7, 41, 30, 9, 18,
719 45, 34, 17, 19, 9, 14, 16, 11, 6, 47,
720 38, 7, 15, -1, 40, -1, 18
723 /* YYSTOS[STATE-NUM] -- The (internal number of the) accessing
724 symbol of state STATE-NUM. */
725 static const unsigned char yystos
[] =
727 0, 1, 11, 12, 21, 22, 23, 31, 11, 0,
728 22, 3, 4, 5, 8, 32, 10, 33, 33, 9,
729 34, 34, 18, 30, 11, 9, 17, 29, 19, 9,
730 15, 28, 24, 9, 14, 28, 6, 7, 13, 25,
731 26, 27, 32, 28, 16, 27, 11, 30, 25, 25,
735 #define yyerrok (yyerrstatus = 0)
736 #define yyclearin (yychar = YYEMPTY)
740 #define YYACCEPT goto yyacceptlab
741 #define YYABORT goto yyabortlab
742 #define YYERROR goto yyerrorlab
745 /* Like YYERROR except do call yyerror. This remains here temporarily
746 to ease the transition to the new meaning of YYERROR, for GCC.
747 Once GCC version 2 has supplanted version 1, this can go. */
749 #define YYFAIL goto yyerrlab
751 #define YYRECOVERING() (!!yyerrstatus)
753 #define YYBACKUP(Token, Value) \
755 if (yychar == YYEMPTY && yylen == 1) \
759 yytoken = YYTRANSLATE (yychar); \
765 yyerror (YY_("syntax error: cannot back up")); \
772 #define YYERRCODE 256
775 /* YYLLOC_DEFAULT -- Set CURRENT to span from RHS[1] to RHS[N].
776 If N is 0, then set CURRENT to the empty location which ends
777 the previous symbol: RHS[0] (always defined). */
779 #define YYRHSLOC(Rhs, K) ((Rhs)[K])
780 #ifndef YYLLOC_DEFAULT
781 # define YYLLOC_DEFAULT(Current, Rhs, N) \
785 (Current).first_line = YYRHSLOC (Rhs, 1).first_line; \
786 (Current).first_column = YYRHSLOC (Rhs, 1).first_column; \
787 (Current).last_line = YYRHSLOC (Rhs, N).last_line; \
788 (Current).last_column = YYRHSLOC (Rhs, N).last_column; \
792 (Current).first_line = (Current).last_line = \
793 YYRHSLOC (Rhs, 0).last_line; \
794 (Current).first_column = (Current).last_column = \
795 YYRHSLOC (Rhs, 0).last_column; \
801 /* YY_LOCATION_PRINT -- Print the location on the stream.
802 This macro was not mandated originally: define only if we know
803 we won't break user code: when these are the locations we know. */
805 #ifndef YY_LOCATION_PRINT
806 # if YYLTYPE_IS_TRIVIAL
807 # define YY_LOCATION_PRINT(File, Loc) \
808 fprintf (File, "%d.%d-%d.%d", \
809 (Loc).first_line, (Loc).first_column, \
810 (Loc).last_line, (Loc).last_column)
812 # define YY_LOCATION_PRINT(File, Loc) ((void) 0)
817 /* YYLEX -- calling `yylex' with the right arguments. */
820 # define YYLEX yylex (YYLEX_PARAM)
822 # define YYLEX yylex ()
825 /* Enable debugging if requested. */
829 # include <stdio.h> /* INFRINGES ON USER NAME SPACE */
830 # define YYFPRINTF fprintf
833 # define YYDPRINTF(Args) \
839 # define YY_SYMBOL_PRINT(Title, Type, Value, Location) \
843 YYFPRINTF (stderr, "%s ", Title); \
844 yysymprint (stderr, \
846 YYFPRINTF (stderr, "\n"); \
850 /*------------------------------------------------------------------.
851 | yy_stack_print -- Print the state stack from its BOTTOM up to its |
853 `------------------------------------------------------------------*/
855 #if defined (__STDC__) || defined (__cplusplus)
857 yy_stack_print (short int *bottom
, short int *top
)
860 yy_stack_print (bottom
, top
)
865 YYFPRINTF (stderr
, "Stack now");
866 for (/* Nothing. */; bottom
<= top
; ++bottom
)
867 YYFPRINTF (stderr
, " %d", *bottom
);
868 YYFPRINTF (stderr
, "\n");
871 # define YY_STACK_PRINT(Bottom, Top) \
874 yy_stack_print ((Bottom), (Top)); \
878 /*------------------------------------------------.
879 | Report that the YYRULE is going to be reduced. |
880 `------------------------------------------------*/
882 #if defined (__STDC__) || defined (__cplusplus)
884 yy_reduce_print (int yyrule
)
887 yy_reduce_print (yyrule
)
892 unsigned long int yylno
= yyrline
[yyrule
];
893 YYFPRINTF (stderr
, "Reducing stack by rule %d (line %lu), ",
895 /* Print the symbols being reduced, and their result. */
896 for (yyi
= yyprhs
[yyrule
]; 0 <= yyrhs
[yyi
]; yyi
++)
897 YYFPRINTF (stderr
, "%s ", yytname
[yyrhs
[yyi
]]);
898 YYFPRINTF (stderr
, "-> %s\n", yytname
[yyr1
[yyrule
]]);
901 # define YY_REDUCE_PRINT(Rule) \
904 yy_reduce_print (Rule); \
907 /* Nonzero means print parse trace. It is left uninitialized so that
908 multiple parsers can coexist. */
911 # define YYDPRINTF(Args)
912 # define YY_SYMBOL_PRINT(Title, Type, Value, Location)
913 # define YY_STACK_PRINT(Bottom, Top)
914 # define YY_REDUCE_PRINT(Rule)
915 #endif /* !YYDEBUG */
918 /* YYINITDEPTH -- initial size of the parser's stacks. */
920 # define YYINITDEPTH 200
923 /* YYMAXDEPTH -- maximum size the stacks can grow to (effective only
924 if the built-in stack extension method is used).
926 Do not make this value too large; the results are undefined if
927 YYSTACK_ALLOC_MAXIMUM < YYSTACK_BYTES (YYMAXDEPTH)
928 evaluated with infinite-precision integer arithmetic. */
931 # define YYMAXDEPTH 10000
939 # if defined (__GLIBC__) && defined (_STRING_H)
940 # define yystrlen strlen
942 /* Return the length of YYSTR. */
944 # if defined (__STDC__) || defined (__cplusplus)
945 yystrlen (const char *yystr
)
951 const char *yys
= yystr
;
953 while (*yys
++ != '\0')
956 return yys
- yystr
- 1;
962 # if defined (__GLIBC__) && defined (_STRING_H) && defined (_GNU_SOURCE)
963 # define yystpcpy stpcpy
965 /* Copy YYSRC to YYDEST, returning the address of the terminating '\0' in
968 # if defined (__STDC__) || defined (__cplusplus)
969 yystpcpy (char *yydest
, const char *yysrc
)
971 yystpcpy (yydest
, yysrc
)
977 const char *yys
= yysrc
;
979 while ((*yyd
++ = *yys
++) != '\0')
988 /* Copy to YYRES the contents of YYSTR after stripping away unnecessary
989 quotes and backslashes, so that it's suitable for yyerror. The
990 heuristic is that double-quoting is unnecessary unless the string
991 contains an apostrophe, a comma, or backslash (other than
992 backslash-backslash). YYSTR is taken from yytname. If YYRES is
993 null, do not copy; instead, return the length of what the result
996 yytnamerr (char *yyres
, const char *yystr
)
1001 char const *yyp
= yystr
;
1008 goto do_not_strip_quotes
;
1012 goto do_not_strip_quotes
;
1025 do_not_strip_quotes
: ;
1029 return yystrlen (yystr
);
1031 return yystpcpy (yyres
, yystr
) - yyres
;
1035 #endif /* YYERROR_VERBOSE */
1040 /*--------------------------------.
1041 | Print this symbol on YYOUTPUT. |
1042 `--------------------------------*/
1044 #if defined (__STDC__) || defined (__cplusplus)
1046 yysymprint (FILE *yyoutput
, int yytype
, YYSTYPE
*yyvaluep
)
1049 yysymprint (yyoutput
, yytype
, yyvaluep
)
1055 /* Pacify ``unused variable'' warnings. */
1058 if (yytype
< YYNTOKENS
)
1059 YYFPRINTF (yyoutput
, "token %s (", yytname
[yytype
]);
1061 YYFPRINTF (yyoutput
, "nterm %s (", yytname
[yytype
]);
1065 if (yytype
< YYNTOKENS
)
1066 YYPRINT (yyoutput
, yytoknum
[yytype
], *yyvaluep
);
1073 YYFPRINTF (yyoutput
, ")");
1076 #endif /* ! YYDEBUG */
1077 /*-----------------------------------------------.
1078 | Release the memory associated to this symbol. |
1079 `-----------------------------------------------*/
1081 #if defined (__STDC__) || defined (__cplusplus)
1083 yydestruct (const char *yymsg
, int yytype
, YYSTYPE
*yyvaluep
)
1086 yydestruct (yymsg
, yytype
, yyvaluep
)
1092 /* Pacify ``unused variable'' warnings. */
1097 YY_SYMBOL_PRINT (yymsg
, yytype
, yyvaluep
, yylocationp
);
1108 /* Prevent warnings from -Wmissing-prototypes. */
1110 #ifdef YYPARSE_PARAM
1111 # if defined (__STDC__) || defined (__cplusplus)
1112 int yyparse (void *YYPARSE_PARAM
);
1116 #else /* ! YYPARSE_PARAM */
1117 #if defined (__STDC__) || defined (__cplusplus)
1122 #endif /* ! YYPARSE_PARAM */
1126 /* The look-ahead symbol. */
1129 /* The semantic value of the look-ahead symbol. */
1132 /* Number of syntax errors so far. */
1141 #ifdef YYPARSE_PARAM
1142 # if defined (__STDC__) || defined (__cplusplus)
1143 int yyparse (void *YYPARSE_PARAM
)
1145 int yyparse (YYPARSE_PARAM
)
1146 void *YYPARSE_PARAM
;
1148 #else /* ! YYPARSE_PARAM */
1149 #if defined (__STDC__) || defined (__cplusplus)
1163 /* Number of tokens to shift before error messages enabled. */
1165 /* Look-ahead token as an internal (translated) token number. */
1168 /* Three stacks and their tools:
1169 `yyss': related to states,
1170 `yyvs': related to semantic values,
1171 `yyls': related to locations.
1173 Refer to the stacks thru separate pointers, to allow yyoverflow
1174 to reallocate them elsewhere. */
1176 /* The state stack. */
1177 short int yyssa
[YYINITDEPTH
];
1178 short int *yyss
= yyssa
;
1181 /* The semantic value stack. */
1182 YYSTYPE yyvsa
[YYINITDEPTH
];
1183 YYSTYPE
*yyvs
= yyvsa
;
1188 #define YYPOPSTACK (yyvsp--, yyssp--)
1190 YYSIZE_T yystacksize
= YYINITDEPTH
;
1192 /* The variables used to return semantic value and location from the
1197 /* When reducing, the number of symbols on the RHS of the reduced
1201 YYDPRINTF ((stderr
, "Starting parse\n"));
1206 yychar
= YYEMPTY
; /* Cause a token to be read. */
1208 /* Initialize stack pointers.
1209 Waste one element of value and location stack
1210 so that they stay on the same level as the state stack.
1211 The wasted elements are never initialized. */
1218 /*------------------------------------------------------------.
1219 | yynewstate -- Push a new state, which is found in yystate. |
1220 `------------------------------------------------------------*/
1222 /* In all cases, when you get here, the value and location stacks
1223 have just been pushed. so pushing a state here evens the stacks.
1230 if (yyss
+ yystacksize
- 1 <= yyssp
)
1232 /* Get the current used size of the three stacks, in elements. */
1233 YYSIZE_T yysize
= yyssp
- yyss
+ 1;
1237 /* Give user a chance to reallocate the stack. Use copies of
1238 these so that the &'s don't force the real ones into
1240 YYSTYPE
*yyvs1
= yyvs
;
1241 short int *yyss1
= yyss
;
1244 /* Each stack pointer address is followed by the size of the
1245 data in use in that stack, in bytes. This used to be a
1246 conditional around just the two extra args, but that might
1247 be undefined if yyoverflow is a macro. */
1248 yyoverflow (YY_("memory exhausted"),
1249 &yyss1
, yysize
* sizeof (*yyssp
),
1250 &yyvs1
, yysize
* sizeof (*yyvsp
),
1257 #else /* no yyoverflow */
1258 # ifndef YYSTACK_RELOCATE
1259 goto yyexhaustedlab
;
1261 /* Extend the stack our own way. */
1262 if (YYMAXDEPTH
<= yystacksize
)
1263 goto yyexhaustedlab
;
1265 if (YYMAXDEPTH
< yystacksize
)
1266 yystacksize
= YYMAXDEPTH
;
1269 short int *yyss1
= yyss
;
1270 union yyalloc
*yyptr
=
1271 (union yyalloc
*) YYSTACK_ALLOC (YYSTACK_BYTES (yystacksize
));
1273 goto yyexhaustedlab
;
1274 YYSTACK_RELOCATE (yyss
);
1275 YYSTACK_RELOCATE (yyvs
);
1277 # undef YYSTACK_RELOCATE
1279 YYSTACK_FREE (yyss1
);
1282 #endif /* no yyoverflow */
1284 yyssp
= yyss
+ yysize
- 1;
1285 yyvsp
= yyvs
+ yysize
- 1;
1288 YYDPRINTF ((stderr
, "Stack size increased to %lu\n",
1289 (unsigned long int) yystacksize
));
1291 if (yyss
+ yystacksize
- 1 <= yyssp
)
1295 YYDPRINTF ((stderr
, "Entering state %d\n", yystate
));
1304 /* Do appropriate processing given the current state. */
1305 /* Read a look-ahead token if we need one and don't already have one. */
1308 /* First try to decide what to do without reference to look-ahead token. */
1310 yyn
= yypact
[yystate
];
1311 if (yyn
== YYPACT_NINF
)
1314 /* Not known => get a look-ahead token if don't already have one. */
1316 /* YYCHAR is either YYEMPTY or YYEOF or a valid look-ahead symbol. */
1317 if (yychar
== YYEMPTY
)
1319 YYDPRINTF ((stderr
, "Reading a token: "));
1323 if (yychar
<= YYEOF
)
1325 yychar
= yytoken
= YYEOF
;
1326 YYDPRINTF ((stderr
, "Now at end of input.\n"));
1330 yytoken
= YYTRANSLATE (yychar
);
1331 YY_SYMBOL_PRINT ("Next token is", yytoken
, &yylval
, &yylloc
);
1334 /* If the proper action on seeing token YYTOKEN is to reduce or to
1335 detect an error, take that action. */
1337 if (yyn
< 0 || YYLAST
< yyn
|| yycheck
[yyn
] != yytoken
)
1342 if (yyn
== 0 || yyn
== YYTABLE_NINF
)
1351 /* Shift the look-ahead token. */
1352 YY_SYMBOL_PRINT ("Shifting", yytoken
, &yylval
, &yylloc
);
1354 /* Discard the token being shifted unless it is eof. */
1355 if (yychar
!= YYEOF
)
1361 /* Count tokens shifted since error; after three, turn off error
1370 /*-----------------------------------------------------------.
1371 | yydefault -- do the default action for the current state. |
1372 `-----------------------------------------------------------*/
1374 yyn
= yydefact
[yystate
];
1380 /*-----------------------------.
1381 | yyreduce -- Do a reduction. |
1382 `-----------------------------*/
1384 /* yyn is the number of a rule to reduce with. */
1387 /* If YYLEN is nonzero, implement the default value of the action:
1390 Otherwise, the following line sets YYVAL to garbage.
1391 This behavior is undocumented and Bison
1392 users should not rely upon it. Assigning to YYVAL
1393 unconditionally makes the parser a bit smaller, and it avoids a
1394 GCC warning that YYVAL may be used uninitialized. */
1395 yyval
= yyvsp
[1-yylen
];
1398 YY_REDUCE_PRINT (yyn
);
1402 #line 309 "itbl-parse.y"
1404 DBG (("line %d: entry pnum=%d type=%d name=%s value=x%x\n",
1405 insntbl_line
, (yyvsp
[-4].num
), (yyvsp
[-3].num
), (yyvsp
[-2].str
), (yyvsp
[-1].val
)));
1406 itbl_add_reg ((yyvsp
[-4].num
), (yyvsp
[-3].num
), (yyvsp
[-2].str
), (yyvsp
[-1].val
));
1411 #line 315 "itbl-parse.y"
1413 DBG (("line %d: entry pnum=%d type=INSN name=%s value=x%x",
1414 insntbl_line
, (yyvsp
[-5].num
), (yyvsp
[-3].str
), (yyvsp
[-2].val
)));
1415 DBG ((" sbit=%d ebit=%d flags=0x%x\n", sbit
, ebit
, (yyvsp
[0].val
)));
1416 insn
=itbl_add_insn ((yyvsp
[-5].num
), (yyvsp
[-3].str
), (yyvsp
[-2].val
), sbit
, ebit
, (yyvsp
[0].val
));
1421 #line 322 "itbl-parse.y"
1426 #line 335 "itbl-parse.y"
1428 DBGL2 (("ftype\n"));
1429 (yyval
.num
) = (yyvsp
[0].num
);
1434 #line 340 "itbl-parse.y"
1442 #line 345 "itbl-parse.y"
1444 DBGL2 (("immed\n"));
1445 (yyval
.num
) = IMMED
;
1450 #line 353 "itbl-parse.y"
1452 DBG (("line %d: field type=%d sbit=%d ebit=%d, flags=0x%x\n",
1453 insntbl_line
, (yyvsp
[-2].num
), sbit
, ebit
, (yyvsp
[0].val
)));
1454 itbl_add_operand (insn
, (yyvsp
[-2].num
), sbit
, ebit
, (yyvsp
[0].val
));
1459 #line 362 "itbl-parse.y"
1461 (yyval
.val
) = (yyvsp
[-2].num
) | (yyvsp
[0].val
);
1466 #line 366 "itbl-parse.y"
1468 (yyval
.val
) = (yyvsp
[-1].val
);
1473 #line 370 "itbl-parse.y"
1475 (yyval
.val
) = (yyvsp
[0].num
);
1480 #line 377 "itbl-parse.y"
1482 DBGL2 (("flags=%d\n", (yyvsp
[0].val
)));
1483 (yyval
.val
) = (yyvsp
[0].val
);
1488 #line 382 "itbl-parse.y"
1495 #line 389 "itbl-parse.y"
1497 DBGL2 (("range %d %d\n", (yyvsp
[-2].num
), (yyvsp
[0].num
)));
1498 sbit
= (yyvsp
[-2].num
);
1499 ebit
= (yyvsp
[0].num
);
1504 #line 395 "itbl-parse.y"
1512 #line 403 "itbl-parse.y"
1514 DBGL2 (("pnum=%d\n",(yyvsp
[0].num
)));
1515 (yyval
.num
) = (yyvsp
[0].num
);
1520 #line 411 "itbl-parse.y"
1528 #line 416 "itbl-parse.y"
1536 #line 421 "itbl-parse.y"
1544 #line 429 "itbl-parse.y"
1546 DBGL2 (("name=%s\n",(yyvsp
[0].str
)));
1547 (yyval
.str
) = (yyvsp
[0].str
);
1552 #line 445 "itbl-parse.y"
1554 DBGL2 (("val=x%x\n",(yyvsp
[0].num
)));
1555 (yyval
.val
) = (yyvsp
[0].num
);
1563 /* Line 1126 of yacc.c. */
1564 #line 1565 "itbl-parse.c"
1570 YY_STACK_PRINT (yyss
, yyssp
);
1575 /* Now `shift' the result of the reduction. Determine what state
1576 that goes to, based on the state we popped back to and the rule
1577 number reduced by. */
1581 yystate
= yypgoto
[yyn
- YYNTOKENS
] + *yyssp
;
1582 if (0 <= yystate
&& yystate
<= YYLAST
&& yycheck
[yystate
] == *yyssp
)
1583 yystate
= yytable
[yystate
];
1585 yystate
= yydefgoto
[yyn
- YYNTOKENS
];
1590 /*------------------------------------.
1591 | yyerrlab -- here on detecting error |
1592 `------------------------------------*/
1594 /* If not already recovering from an error, report this error. */
1599 yyn
= yypact
[yystate
];
1601 if (YYPACT_NINF
< yyn
&& yyn
< YYLAST
)
1603 int yytype
= YYTRANSLATE (yychar
);
1604 YYSIZE_T yysize0
= yytnamerr (0, yytname
[yytype
]);
1605 YYSIZE_T yysize
= yysize0
;
1607 int yysize_overflow
= 0;
1609 # define YYERROR_VERBOSE_ARGS_MAXIMUM 5
1610 char const *yyarg
[YYERROR_VERBOSE_ARGS_MAXIMUM
];
1614 /* This is so xgettext sees the translatable formats that are
1615 constructed on the fly. */
1616 YY_("syntax error, unexpected %s");
1617 YY_("syntax error, unexpected %s, expecting %s");
1618 YY_("syntax error, unexpected %s, expecting %s or %s");
1619 YY_("syntax error, unexpected %s, expecting %s or %s or %s");
1620 YY_("syntax error, unexpected %s, expecting %s or %s or %s or %s");
1624 static char const yyunexpected
[] = "syntax error, unexpected %s";
1625 static char const yyexpecting
[] = ", expecting %s";
1626 static char const yyor
[] = " or %s";
1627 char yyformat
[sizeof yyunexpected
1628 + sizeof yyexpecting
- 1
1629 + ((YYERROR_VERBOSE_ARGS_MAXIMUM
- 2)
1630 * (sizeof yyor
- 1))];
1631 char const *yyprefix
= yyexpecting
;
1633 /* Start YYX at -YYN if negative to avoid negative indexes in
1635 int yyxbegin
= yyn
< 0 ? -yyn
: 0;
1637 /* Stay within bounds of both yycheck and yytname. */
1638 int yychecklim
= YYLAST
- yyn
;
1639 int yyxend
= yychecklim
< YYNTOKENS
? yychecklim
: YYNTOKENS
;
1642 yyarg
[0] = yytname
[yytype
];
1643 yyfmt
= yystpcpy (yyformat
, yyunexpected
);
1645 for (yyx
= yyxbegin
; yyx
< yyxend
; ++yyx
)
1646 if (yycheck
[yyx
+ yyn
] == yyx
&& yyx
!= YYTERROR
)
1648 if (yycount
== YYERROR_VERBOSE_ARGS_MAXIMUM
)
1652 yyformat
[sizeof yyunexpected
- 1] = '\0';
1655 yyarg
[yycount
++] = yytname
[yyx
];
1656 yysize1
= yysize
+ yytnamerr (0, yytname
[yyx
]);
1657 yysize_overflow
|= yysize1
< yysize
;
1659 yyfmt
= yystpcpy (yyfmt
, yyprefix
);
1663 yyf
= YY_(yyformat
);
1664 yysize1
= yysize
+ yystrlen (yyf
);
1665 yysize_overflow
|= yysize1
< yysize
;
1668 if (!yysize_overflow
&& yysize
<= YYSTACK_ALLOC_MAXIMUM
)
1669 yymsg
= (char *) YYSTACK_ALLOC (yysize
);
1672 /* Avoid sprintf, as that infringes on the user's name space.
1673 Don't have undefined behavior even if the translation
1674 produced a string with the wrong number of "%s"s. */
1677 while ((*yyp
= *yyf
))
1679 if (*yyp
== '%' && yyf
[1] == 's' && yyi
< yycount
)
1681 yyp
+= yytnamerr (yyp
, yyarg
[yyi
++]);
1691 YYSTACK_FREE (yymsg
);
1695 yyerror (YY_("syntax error"));
1696 goto yyexhaustedlab
;
1700 #endif /* YYERROR_VERBOSE */
1701 yyerror (YY_("syntax error"));
1706 if (yyerrstatus
== 3)
1708 /* If just tried and failed to reuse look-ahead token after an
1709 error, discard it. */
1711 if (yychar
<= YYEOF
)
1713 /* Return failure if at end of input. */
1714 if (yychar
== YYEOF
)
1719 yydestruct ("Error: discarding", yytoken
, &yylval
);
1724 /* Else will try to reuse look-ahead token after shifting the error
1729 /*---------------------------------------------------.
1730 | yyerrorlab -- error raised explicitly by YYERROR. |
1731 `---------------------------------------------------*/
1734 /* Pacify compilers like GCC when the user code never invokes
1735 YYERROR and the label yyerrorlab therefore never appears in user
1746 /*-------------------------------------------------------------.
1747 | yyerrlab1 -- common code for both syntax error and YYERROR. |
1748 `-------------------------------------------------------------*/
1750 yyerrstatus
= 3; /* Each real token shifted decrements this. */
1754 yyn
= yypact
[yystate
];
1755 if (yyn
!= YYPACT_NINF
)
1758 if (0 <= yyn
&& yyn
<= YYLAST
&& yycheck
[yyn
] == YYTERROR
)
1766 /* Pop the current state because it cannot handle the error token. */
1771 yydestruct ("Error: popping", yystos
[yystate
], yyvsp
);
1774 YY_STACK_PRINT (yyss
, yyssp
);
1783 /* Shift the error token. */
1784 YY_SYMBOL_PRINT ("Shifting", yystos
[yyn
], yyvsp
, yylsp
);
1790 /*-------------------------------------.
1791 | yyacceptlab -- YYACCEPT comes here. |
1792 `-------------------------------------*/
1797 /*-----------------------------------.
1798 | yyabortlab -- YYABORT comes here. |
1799 `-----------------------------------*/
1805 /*-------------------------------------------------.
1806 | yyexhaustedlab -- memory exhaustion comes here. |
1807 `-------------------------------------------------*/
1809 yyerror (YY_("memory exhausted"));
1815 if (yychar
!= YYEOF
&& yychar
!= YYEMPTY
)
1816 yydestruct ("Cleanup: discarding lookahead",
1818 while (yyssp
!= yyss
)
1820 yydestruct ("Cleanup: popping",
1821 yystos
[*yyssp
], yyvsp
);
1826 YYSTACK_FREE (yyss
);
1832 #line 450 "itbl-parse.y"
1839 printf ("line %d: %s\n", insntbl_line
, msg
);