1 /* A Bison parser, made from itbl-parse.y
4 #define YYBISON 1 /* Identify Bison output. */
17 #line 21 "itbl-parse.y"
22 Yacc grammar for instruction table entries.
24 =======================================================================
25 Original Instruction table specification document:
27 MIPS Coprocessor Table Specification
28 ====================================
30 This document describes the format of the MIPS coprocessor table. The
31 table specifies a list of valid functions, data registers and control
32 registers that can be used in coprocessor instructions. This list,
33 together with the coprocessor instruction classes listed below,
34 specifies the complete list of coprocessor instructions that will
35 be recognized and assembled by the GNU assembler. In effect,
36 this makes the GNU assembler table-driven, where the table is
37 specified by the programmer.
39 The table is an ordinary text file that the GNU assembler reads when
40 it starts. Using the information in the table, the assembler
41 generates an internal list of valid coprocessor registers and
42 functions. The assembler uses this internal list in addition to the
43 standard MIPS registers and instructions which are built-in to the
44 assembler during code generation.
46 To specify the coprocessor table when invoking the GNU assembler, use
47 the command line option "--itbl file", where file is the
48 complete name of the table, including path and extension.
52 gas -t cop.tbl test.s -o test.o
53 gas -t /usr/local/lib/cop.tbl test.s -o test.o
54 gas --itbl d:\gnu\data\cop.tbl test.s -o test.o
56 Only one table may be supplied during a single invocation of
63 Below is a list of the valid coprocessor instruction classes for
64 any given coprocessor "z". These instructions are already recognized
65 by the assembler, and are listed here only for reference.
67 Class format instructions
68 -------------------------------------------------
99 The coprocessor table defines coprocessor-specific registers that can
100 be used with all of the above classes of instructions, where
101 appropriate. It also defines additional coprocessor-specific
102 functions for Class3 (COPz cofun) instructions, Thus, the table allows
103 the programmer to use convenient mnemonics and operands for these
104 functions, instead of the COPz mmenmonic and cofun operand.
106 The names of the MIPS general registers and their aliases are defined
107 by the assembler and will be recognized as valid register names by the
108 assembler when used (where allowed) in coprocessor instructions.
109 However, the names and values of all coprocessor data and control
110 register mnemonics must be specified in the coprocessor table.
116 Here is the grammar for the coprocessor table:
120 entry -> [z entrydef] [comment] '\n'
122 entrydef -> type name val
123 entrydef -> 'insn' name val funcdef ; type of entry (instruction)
125 z -> 'p'['0'..'3'] ; processor number
126 type -> ['dreg' | 'creg' | 'greg' ] ; type of entry (register)
127 ; 'dreg', 'creg' or 'greg' specifies a data, control, or general
128 ; register mnemonic, respectively
129 name -> [ltr|dec]* ; mnemonic of register/function
130 val -> [dec|hex] ; register/function number (integer constant)
132 funcdef -> frange flags fields
133 ; bitfield range for opcode
134 ; list of fields' formats
136 field -> [','] ftype frange flags
137 flags -> ['*' flagexpr]
138 flagexpr -> '[' flagexpr ']'
139 flagexpr -> val '|' flagexpr
140 ftype -> [ type | 'immed' | 'addr' ]
141 ; 'immed' specifies an immediate value; see grammar for "val" above
142 ; 'addr' specifies a C identifier; name of symbol to be resolved at
144 frange -> ':' val '-' val ; starting to ending bit positions, where
145 ; where 0 is least significant bit
146 frange -> (null) ; default range of 31-0 will be assumed
148 comment -> [';'|'#'] [char]*
149 char -> any printable character
150 ltr -> ['a'..'z'|'A'..'Z']
151 dec -> ['0'..'9']* ; value in decimal
152 hex -> '0x'['0'..'9' | 'a'..'f' | 'A'..'F']* ; value in hexadecimal
162 p1 dreg d1 1 ; data register "d1" for COP1 has value 1
163 p1 creg c3 3 ; ctrl register "c3" for COP1 has value 3
164 p3 func fill 0x1f:24-20 ; function "fill" for COP3 has value 31 and
167 will allow the assembler to accept the following coprocessor instructions:
172 Here, the general purpose register "$2", and instruction "LWC1", are standard
173 mnemonics built-in to the MIPS assembler.
180 p3 dreg d3 3 ; data register "d3" for COP3 has value 3
181 p3 creg c2 22 ; control register "c2" for COP3 has value 22
182 p3 func fee 0x1f:24-20 dreg:17-13 creg:12-8 immed:7-0
183 ; function "fee" for COP3 has value 31, and 3 fields
184 ; consisting of a data register, a control register,
185 ; and an immediate value.
187 will allow the assembler to accept the following coprocessor instruction:
191 and will emit the object code:
193 31-26 25 24-20 19-18 17-13 12-8 7-0
194 COPz CO fun dreg creg immed
195 010011 1 11111 00 00011 10110 00000001
204 p3 dreg d3 3 ; data register "d3" for COP3 has value 3
205 p3 creg c2 22 ; control register "c2" for COP3 has value 22
206 p3 func fuu 0x01f00001 dreg:17-13 creg:12-8
208 will allow the assembler to accept the following coprocessor
213 and will emit the object code:
215 31-26 25 24-20 19-18 17-13 12-8 7-0
216 COPz CO fun dreg creg
217 010011 1 11111 00 00011 10110 00000001
221 In this way, the programmer can force arbitrary bits of an instruction
222 to have predefined values.
224 =======================================================================
228 To handle more than one bit position range within an instruction,
229 use 0s to mask out the ranges which don't apply.
230 May decide to modify the syntax to allow commas separate multiple
231 ranges within an instruction (range','range).
234 The number of parms argument to the function entry
235 was deleted from the original format such that we now count the fields.
238 FIXME! should really change lexical analyzer
239 to recognize 'dreg' etc. in context sensitive way.
240 Currently function names or mnemonics may be incorrectly parsed as keywords
242 FIXME! hex is ambiguous with any digit
247 #include "itbl-lex.h"
248 #include "itbl-ops.h"
261 #define DBG(x) printf x
267 #define DBGL2(x) printf x
272 static int sbit
, ebit
;
273 static struct itbl_entry
*insn
=0;
274 static int yyerror
PARAMS ((const char *));
277 #line 281 "itbl-parse.y"
286 # define YYSTYPE yystype
287 # define YYSTYPE_IS_TRIVIAL 1
296 #define YYFLAG -32768
299 /* YYTRANSLATE(YYLEX) -- Bison token number corresponding to YYLEX. */
300 #define YYTRANSLATE(x) ((unsigned)(x) <= 266 ? yytranslate[x] : 34)
302 /* YYTRANSLATE[YYLEX] -- Bison token number corresponding to YYLEX. */
303 static const char yytranslate
[] =
305 0, 2, 2, 2, 2, 2, 2, 2, 2, 2,
306 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
307 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
308 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
309 2, 2, 17, 2, 13, 19, 2, 2, 2, 2,
310 2, 2, 2, 2, 2, 2, 2, 2, 18, 2,
311 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
312 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
313 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
314 2, 15, 2, 16, 2, 2, 2, 2, 2, 2,
315 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
316 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
317 2, 2, 2, 2, 14, 2, 2, 2, 2, 2,
318 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
319 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
320 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
321 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
322 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
323 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
324 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
325 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
326 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
327 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
328 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
329 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
330 2, 2, 2, 2, 2, 2, 1, 3, 4, 5,
331 6, 7, 8, 9, 10, 11, 12
335 static const short yyprhs
[] =
337 0, 0, 2, 5, 6, 12, 13, 23, 25, 28,
338 32, 35, 36, 38, 40, 42, 46, 50, 54, 56,
339 59, 60, 65, 66, 68, 70, 72, 74, 76, 78
341 static const short yyrhs
[] =
343 21, 0, 22, 21, 0, 0, 30, 31, 32, 33,
344 11, 0, 0, 30, 8, 32, 33, 29, 28, 23,
345 24, 11, 0, 11, 0, 1, 11, 0, 13, 26,
346 24, 0, 26, 24, 0, 0, 31, 0, 7, 0,
347 6, 0, 25, 29, 28, 0, 9, 14, 27, 0,
348 15, 27, 16, 0, 9, 0, 17, 27, 0, 0,
349 18, 9, 19, 9, 0, 0, 12, 0, 3, 0,
350 4, 0, 5, 0, 10, 0, 9, 0, 9, 0
356 /* YYRLINE[YYN] -- source line where rule number YYN was defined. */
357 static const short yyrline
[] =
359 0, 298, 302, 304, 307, 314, 314, 323, 324, 327,
360 329, 330, 333, 339, 344, 351, 360, 365, 369, 375,
361 381, 387, 394, 401, 409, 415, 420, 427, 435, 443
366 #if (YYDEBUG) || defined YYERROR_VERBOSE
368 /* YYTNAME[TOKEN_NUM] -- String name of the token TOKEN_NUM. */
369 static const char *const yytname
[] =
371 "$", "error", "$undefined.", "DREG", "CREG", "GREG", "IMMED", "ADDR",
372 "INSN", "NUM", "ID", "NL", "PNUM", "','", "'|'", "'['", "']'", "'*'",
373 "':'", "'-'", "insntbl", "entrys", "entry", "@1", "fieldspecs", "ftype",
374 "fieldspec", "flagexpr", "flags", "range", "pnum", "regtype", "name",
379 /* YYR1[YYN] -- Symbol number of symbol that rule YYN derives. */
380 static const short yyr1
[] =
382 0, 20, 21, 21, 22, 23, 22, 22, 22, 24,
383 24, 24, 25, 25, 25, 26, 27, 27, 27, 28,
384 28, 29, 29, 30, 31, 31, 31, 32, 34, 33
387 /* YYR2[YYN] -- Number of symbols composing right hand side of rule YYN. */
388 static const short yyr2
[] =
390 0, 1, 2, 0, 5, 0, 9, 1, 2, 3,
391 2, 0, 1, 1, 1, 3, 3, 3, 1, 2,
392 0, 4, 0, 1, 1, 1, 1, 1, 1, 1
395 /* YYDEFACT[S] -- default rule to reduce with in state S when YYTABLE
396 doesn't specify something else to do. Zero means the default is an
398 static const short yydefact
[] =
400 0, 0, 7, 23, 1, 0, 0, 8, 2, 24,
401 25, 26, 0, 0, 27, 0, 0, 29, 22, 0,
402 0, 20, 4, 0, 0, 5, 0, 18, 0, 19,
403 11, 21, 0, 0, 14, 13, 0, 0, 22, 11,
404 12, 16, 17, 11, 6, 20, 10, 9, 15, 0,
408 static const short yydefgoto
[] =
410 49, 4, 5, 30, 37, 38, 39, 29, 25, 21,
414 static const short yypact
[] =
416 0, -9,-32768,-32768,-32768, 0, 12,-32768,-32768,-32768,
417 -32768,-32768, 3, 3,-32768, 9, 9,-32768, -8, 8,
418 19, 15,-32768, 10, -6,-32768, 24, 20, -6,-32768,
419 1,-32768, -6, 21,-32768,-32768, 18, 25, -8, 1,
420 -32768,-32768,-32768, 1,-32768, 15,-32768,-32768,-32768, 35,
424 static const short yypgoto
[] =
426 -32768, 34,-32768,-32768, -13,-32768, 4, -1, -4, 5,
434 static const short yytable
[] =
436 -3, 1, 7, 27, 9, 10, 11, 34, 35, 28,
437 20, 2, 3, 14, 36, 9, 10, 11, 17, 22,
438 12, 9, 10, 11, 34, 35, 46, 33, 23, 26,
439 47, 41, 24, 31, 32, 50, 44, 42, 51, 8,
440 43, 48, 13, 45, 16, 19
443 static const short yycheck
[] =
445 0, 1, 11, 9, 3, 4, 5, 6, 7, 15,
446 18, 11, 12, 10, 13, 3, 4, 5, 9, 11,
447 8, 3, 4, 5, 6, 7, 39, 28, 9, 19,
448 43, 32, 17, 9, 14, 0, 11, 16, 0, 5,
449 36, 45, 6, 38, 13, 16
451 /* -*-C-*- Note some compilers choke on comments on `#line' lines. */
452 #line 3 "/usr/share/bison/bison.simple"
454 /* Skeleton output parser for bison,
456 Copyright (C) 1984, 1989, 1990, 2000, 2001, 2002 Free Software
459 This program is free software; you can redistribute it and/or modify
460 it under the terms of the GNU General Public License as published by
461 the Free Software Foundation; either version 2, or (at your option)
464 This program is distributed in the hope that it will be useful,
465 but WITHOUT ANY WARRANTY; without even the implied warranty of
466 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
467 GNU General Public License for more details.
469 You should have received a copy of the GNU General Public License
470 along with this program; if not, write to the Free Software
471 Foundation, Inc., 59 Temple Place - Suite 330,
472 Boston, MA 02111-1307, USA. */
474 /* As a special exception, when this file is copied by Bison into a
475 Bison output file, you may use that output file without restriction.
476 This special exception was added by the Free Software Foundation
477 in version 1.24 of Bison. */
479 /* This is the parser code that is written into each bison parser when
480 the %semantic_parser declaration is not specified in the grammar.
481 It was written by Richard Stallman by simplifying the hairy parser
482 used when %semantic_parser is specified. */
484 /* All symbols defined below should begin with yy or YY, to avoid
485 infringing on user name space. This should be done even for local
486 variables, as they might otherwise be expanded by user macros.
487 There are some unavoidable exceptions within include files to
488 define necessary library symbols; they are noted "INFRINGES ON
489 USER NAME SPACE" below. */
491 #if ! defined (yyoverflow) || defined (YYERROR_VERBOSE)
493 /* The parser invokes alloca or malloc; define the necessary symbols. */
495 # if YYSTACK_USE_ALLOCA
496 # define YYSTACK_ALLOC alloca
498 # ifndef YYSTACK_USE_ALLOCA
499 # if defined (alloca) || defined (_ALLOCA_H)
500 # define YYSTACK_ALLOC alloca
503 # define YYSTACK_ALLOC __builtin_alloca
509 # ifdef YYSTACK_ALLOC
510 /* Pacify GCC's `empty if-body' warning. */
511 # define YYSTACK_FREE(Ptr) do { /* empty */; } while (0)
513 # if defined (__STDC__) || defined (__cplusplus)
514 # include <stdlib.h> /* INFRINGES ON USER NAME SPACE */
515 # define YYSIZE_T size_t
517 # define YYSTACK_ALLOC malloc
518 # define YYSTACK_FREE free
520 #endif /* ! defined (yyoverflow) || defined (YYERROR_VERBOSE) */
523 #if (! defined (yyoverflow) \
524 && (! defined (__cplusplus) \
525 || (YYLTYPE_IS_TRIVIAL && YYSTYPE_IS_TRIVIAL)))
527 /* A type that is properly aligned for any stack member. */
537 /* The size of the maximum gap between one aligned stack and the next. */
538 # define YYSTACK_GAP_MAX (sizeof (union yyalloc) - 1)
540 /* The size of an array large to enough to hold all stacks, each with
543 # define YYSTACK_BYTES(N) \
544 ((N) * (sizeof (short) + sizeof (YYSTYPE) + sizeof (YYLTYPE)) \
545 + 2 * YYSTACK_GAP_MAX)
547 # define YYSTACK_BYTES(N) \
548 ((N) * (sizeof (short) + sizeof (YYSTYPE)) \
552 /* Copy COUNT objects from FROM to TO. The source and destination do
556 # define YYCOPY(To, From, Count) \
557 __builtin_memcpy (To, From, (Count) * sizeof (*(From)))
559 # define YYCOPY(To, From, Count) \
562 register YYSIZE_T yyi; \
563 for (yyi = 0; yyi < (Count); yyi++) \
564 (To)[yyi] = (From)[yyi]; \
570 /* Relocate STACK from its old location to the new one. The
571 local variables YYSIZE and YYSTACKSIZE give the old and new number of
572 elements in the stack, and YYPTR gives the new location of the
573 stack. Advance YYPTR to a properly aligned location for the next
575 # define YYSTACK_RELOCATE(Stack) \
578 YYSIZE_T yynewbytes; \
579 YYCOPY (&yyptr->Stack, Stack, yysize); \
580 Stack = &yyptr->Stack; \
581 yynewbytes = yystacksize * sizeof (*Stack) + YYSTACK_GAP_MAX; \
582 yyptr += yynewbytes / sizeof (*yyptr); \
589 #if ! defined (YYSIZE_T) && defined (__SIZE_TYPE__)
590 # define YYSIZE_T __SIZE_TYPE__
592 #if ! defined (YYSIZE_T) && defined (size_t)
593 # define YYSIZE_T size_t
595 #if ! defined (YYSIZE_T)
596 # if defined (__STDC__) || defined (__cplusplus)
597 # include <stddef.h> /* INFRINGES ON USER NAME SPACE */
598 # define YYSIZE_T size_t
601 #if ! defined (YYSIZE_T)
602 # define YYSIZE_T unsigned int
605 #define yyerrok (yyerrstatus = 0)
606 #define yyclearin (yychar = YYEMPTY)
609 #define YYACCEPT goto yyacceptlab
610 #define YYABORT goto yyabortlab
611 #define YYERROR goto yyerrlab1
612 /* Like YYERROR except do call yyerror. This remains here temporarily
613 to ease the transition to the new meaning of YYERROR, for GCC.
614 Once GCC version 2 has supplanted version 1, this can go. */
615 #define YYFAIL goto yyerrlab
616 #define YYRECOVERING() (!!yyerrstatus)
617 #define YYBACKUP(Token, Value) \
619 if (yychar == YYEMPTY && yylen == 1) \
623 yychar1 = YYTRANSLATE (yychar); \
629 yyerror ("syntax error: cannot back up"); \
635 #define YYERRCODE 256
638 /* YYLLOC_DEFAULT -- Compute the default location (before the actions
641 When YYLLOC_DEFAULT is run, CURRENT is set the location of the
642 first token. By default, to implement support for ranges, extend
643 its range to the last symbol. */
645 #ifndef YYLLOC_DEFAULT
646 # define YYLLOC_DEFAULT(Current, Rhs, N) \
647 Current.last_line = Rhs[N].last_line; \
648 Current.last_column = Rhs[N].last_column;
652 /* YYLEX -- calling `yylex' with the right arguments. */
657 # define YYLEX yylex (&yylval, &yylloc, YYLEX_PARAM)
659 # define YYLEX yylex (&yylval, &yylloc)
661 # else /* !YYLSP_NEEDED */
663 # define YYLEX yylex (&yylval, YYLEX_PARAM)
665 # define YYLEX yylex (&yylval)
667 # endif /* !YYLSP_NEEDED */
669 # define YYLEX yylex ()
673 /* Enable debugging if requested. */
677 # include <stdio.h> /* INFRINGES ON USER NAME SPACE */
678 # define YYFPRINTF fprintf
681 # define YYDPRINTF(Args) \
686 /* Nonzero means print parse trace. It is left uninitialized so that
687 multiple parsers can coexist. */
690 # define YYDPRINTF(Args)
691 #endif /* !YYDEBUG */
693 /* YYINITDEPTH -- initial size of the parser's stacks. */
695 # define YYINITDEPTH 200
698 /* YYMAXDEPTH -- maximum size the stacks can grow to (effective only
699 if the built-in stack extension method is used).
701 Do not make this value too large; the results are undefined if
702 SIZE_MAX < YYSTACK_BYTES (YYMAXDEPTH)
703 evaluated with infinite-precision integer arithmetic. */
710 # define YYMAXDEPTH 10000
713 #ifdef YYERROR_VERBOSE
716 # if defined (__GLIBC__) && defined (_STRING_H)
717 # define yystrlen strlen
719 /* Return the length of YYSTR. */
721 # if defined (__STDC__) || defined (__cplusplus)
722 yystrlen (const char *yystr
)
728 register const char *yys
= yystr
;
730 while (*yys
++ != '\0')
733 return yys
- yystr
- 1;
739 # if defined (__GLIBC__) && defined (_STRING_H) && defined (_GNU_SOURCE)
741 # define yystpcpy stpcpy
743 /* Copy YYSRC to YYDEST, returning the address of the terminating '\0' in
746 # if defined (__STDC__) || defined (__cplusplus)
747 yystpcpy (char *yydest
, const char *yysrc
)
749 yystpcpy (yydest
, yysrc
)
754 register char *yyd
= yydest
;
755 register const char *yys
= yysrc
;
757 while ((*yyd
++ = *yys
++) != '\0')
766 #line 316 "/usr/share/bison/bison.simple"
769 /* The user can define YYPARSE_PARAM as the name of an argument to be passed
770 into yyparse. The argument should have type void *.
771 It should actually point to an object.
772 Grammar actions can access the variable by casting it
773 to the proper pointer type. */
776 # if defined (__STDC__) || defined (__cplusplus)
777 # define YYPARSE_PARAM_ARG void *YYPARSE_PARAM
778 # define YYPARSE_PARAM_DECL
780 # define YYPARSE_PARAM_ARG YYPARSE_PARAM
781 # define YYPARSE_PARAM_DECL void *YYPARSE_PARAM;
783 #else /* !YYPARSE_PARAM */
784 # define YYPARSE_PARAM_ARG
785 # define YYPARSE_PARAM_DECL
786 #endif /* !YYPARSE_PARAM */
788 /* Prevent warning if -Wstrict-prototypes. */
790 # ifdef YYPARSE_PARAM
791 int yyparse (void *);
797 /* YY_DECL_VARIABLES -- depending whether we use a pure parser,
798 variables are global, or local to YYPARSE. */
800 #define YY_DECL_NON_LSP_VARIABLES \
801 /* The lookahead symbol. */ \
804 /* The semantic value of the lookahead symbol. */ \
807 /* Number of parse errors so far. */ \
811 # define YY_DECL_VARIABLES \
812 YY_DECL_NON_LSP_VARIABLES \
814 /* Location data for the lookahead symbol. */ \
817 # define YY_DECL_VARIABLES \
818 YY_DECL_NON_LSP_VARIABLES
822 /* If nonreentrant, generate the variables here. */
829 yyparse (YYPARSE_PARAM_ARG
)
832 /* If reentrant, generate the variables here. */
837 register int yystate
;
840 /* Number of tokens to shift before error messages enabled. */
842 /* Lookahead token as an internal (translated) token number. */
845 /* Three stacks and their tools:
846 `yyss': related to states,
847 `yyvs': related to semantic values,
848 `yyls': related to locations.
850 Refer to the stacks thru separate pointers, to allow yyoverflow
851 to reallocate them elsewhere. */
853 /* The state stack. */
854 short yyssa
[YYINITDEPTH
];
856 register short *yyssp
;
858 /* The semantic value stack. */
859 YYSTYPE yyvsa
[YYINITDEPTH
];
860 YYSTYPE
*yyvs
= yyvsa
;
861 register YYSTYPE
*yyvsp
;
864 /* The location stack. */
865 YYLTYPE yylsa
[YYINITDEPTH
];
866 YYLTYPE
*yyls
= yylsa
;
871 # define YYPOPSTACK (yyvsp--, yyssp--, yylsp--)
873 # define YYPOPSTACK (yyvsp--, yyssp--)
876 YYSIZE_T yystacksize
= YYINITDEPTH
;
879 /* The variables used to return semantic value and location from the
886 /* When reducing, the number of symbols on the RHS of the reduced
890 YYDPRINTF ((stderr
, "Starting parse\n"));
895 yychar
= YYEMPTY
; /* Cause a token to be read. */
897 /* Initialize stack pointers.
898 Waste one element of value and location stack
899 so that they stay on the same level as the state stack.
900 The wasted elements are never initialized. */
909 /*------------------------------------------------------------.
910 | yynewstate -- Push a new state, which is found in yystate. |
911 `------------------------------------------------------------*/
913 /* In all cases, when you get here, the value and location stacks
914 have just been pushed. so pushing a state here evens the stacks.
921 if (yyssp
>= yyss
+ yystacksize
- 1)
923 /* Get the current used size of the three stacks, in elements. */
924 YYSIZE_T yysize
= yyssp
- yyss
+ 1;
928 /* Give user a chance to reallocate the stack. Use copies of
929 these so that the &'s don't force the real ones into
931 YYSTYPE
*yyvs1
= yyvs
;
934 /* Each stack pointer address is followed by the size of the
935 data in use in that stack, in bytes. */
937 YYLTYPE
*yyls1
= yyls
;
938 /* This used to be a conditional around just the two extra args,
939 but that might be undefined if yyoverflow is a macro. */
940 yyoverflow ("parser stack overflow",
941 &yyss1
, yysize
* sizeof (*yyssp
),
942 &yyvs1
, yysize
* sizeof (*yyvsp
),
943 &yyls1
, yysize
* sizeof (*yylsp
),
947 yyoverflow ("parser stack overflow",
948 &yyss1
, yysize
* sizeof (*yyssp
),
949 &yyvs1
, yysize
* sizeof (*yyvsp
),
955 #else /* no yyoverflow */
956 # ifndef YYSTACK_RELOCATE
959 /* Extend the stack our own way. */
960 if (yystacksize
>= YYMAXDEPTH
)
963 if (yystacksize
> YYMAXDEPTH
)
964 yystacksize
= YYMAXDEPTH
;
968 union yyalloc
*yyptr
=
969 (union yyalloc
*) YYSTACK_ALLOC (YYSTACK_BYTES (yystacksize
));
972 YYSTACK_RELOCATE (yyss
);
973 YYSTACK_RELOCATE (yyvs
);
975 YYSTACK_RELOCATE (yyls
);
977 # undef YYSTACK_RELOCATE
979 YYSTACK_FREE (yyss1
);
982 #endif /* no yyoverflow */
984 yyssp
= yyss
+ yysize
- 1;
985 yyvsp
= yyvs
+ yysize
- 1;
987 yylsp
= yyls
+ yysize
- 1;
990 YYDPRINTF ((stderr
, "Stack size increased to %lu\n",
991 (unsigned long int) yystacksize
));
993 if (yyssp
>= yyss
+ yystacksize
- 1)
997 YYDPRINTF ((stderr
, "Entering state %d\n", yystate
));
1007 /* Do appropriate processing given the current state. */
1008 /* Read a lookahead token if we need one and don't already have one. */
1011 /* First try to decide what to do without reference to lookahead token. */
1013 yyn
= yypact
[yystate
];
1017 /* Not known => get a lookahead token if don't already have one. */
1019 /* yychar is either YYEMPTY or YYEOF
1020 or a valid token in external form. */
1022 if (yychar
== YYEMPTY
)
1024 YYDPRINTF ((stderr
, "Reading a token: "));
1028 /* Convert token to internal form (in yychar1) for indexing tables with */
1030 if (yychar
<= 0) /* This means end of input. */
1033 yychar
= YYEOF
; /* Don't call YYLEX any more */
1035 YYDPRINTF ((stderr
, "Now at end of input.\n"));
1039 yychar1
= YYTRANSLATE (yychar
);
1042 /* We have to keep this `#if YYDEBUG', since we use variables
1043 which are defined only if `YYDEBUG' is set. */
1046 YYFPRINTF (stderr
, "Next token is %d (%s",
1047 yychar
, yytname
[yychar1
]);
1048 /* Give the individual parser a way to print the precise
1049 meaning of a token, for further debugging info. */
1051 YYPRINT (stderr
, yychar
, yylval
);
1053 YYFPRINTF (stderr
, ")\n");
1059 if (yyn
< 0 || yyn
> YYLAST
|| yycheck
[yyn
] != yychar1
)
1064 /* yyn is what to do for this token type in this state.
1065 Negative => reduce, -yyn is rule number.
1066 Positive => shift, yyn is new state.
1067 New state is final state => don't bother to shift,
1068 just return success.
1069 0, or most negative number => error. */
1084 /* Shift the lookahead token. */
1085 YYDPRINTF ((stderr
, "Shifting token %d (%s), ",
1086 yychar
, yytname
[yychar1
]));
1088 /* Discard the token being shifted unless it is eof. */
1089 if (yychar
!= YYEOF
)
1097 /* Count tokens shifted since error; after three, turn off error
1106 /*-----------------------------------------------------------.
1107 | yydefault -- do the default action for the current state. |
1108 `-----------------------------------------------------------*/
1110 yyn
= yydefact
[yystate
];
1116 /*-----------------------------.
1117 | yyreduce -- Do a reduction. |
1118 `-----------------------------*/
1120 /* yyn is the number of a rule to reduce with. */
1123 /* If YYLEN is nonzero, implement the default value of the action:
1126 Otherwise, the following line sets YYVAL to the semantic value of
1127 the lookahead token. This behavior is undocumented and Bison
1128 users should not rely upon it. Assigning to YYVAL
1129 unconditionally makes the parser a bit smaller, and it avoids a
1130 GCC warning that YYVAL may be used uninitialized. */
1131 yyval
= yyvsp
[1-yylen
];
1134 /* Similarly for the default location. Let the user run additional
1135 commands if for instance locations are ranges. */
1136 yyloc
= yylsp
[1-yylen
];
1137 YYLLOC_DEFAULT (yyloc
, (yylsp
- yylen
), yylen
);
1141 /* We have to keep this `#if YYDEBUG', since we use variables which
1142 are defined only if `YYDEBUG' is set. */
1147 YYFPRINTF (stderr
, "Reducing via rule %d (line %d), ",
1150 /* Print the symbols being reduced, and their result. */
1151 for (yyi
= yyprhs
[yyn
]; yyrhs
[yyi
] > 0; yyi
++)
1152 YYFPRINTF (stderr
, "%s ", yytname
[yyrhs
[yyi
]]);
1153 YYFPRINTF (stderr
, " -> %s\n", yytname
[yyr1
[yyn
]]);
1160 #line 309 "itbl-parse.y"
1162 DBG (("line %d: entry pnum=%d type=%d name=%s value=x%x\n",
1163 insntbl_line
, yyvsp
[-4].num
, yyvsp
[-3].num
, yyvsp
[-2].str
, yyvsp
[-1].val
));
1164 itbl_add_reg (yyvsp
[-4].num
, yyvsp
[-3].num
, yyvsp
[-2].str
, yyvsp
[-1].val
);
1168 #line 315 "itbl-parse.y"
1170 DBG (("line %d: entry pnum=%d type=INSN name=%s value=x%x",
1171 insntbl_line
, yyvsp
[-5].num
, yyvsp
[-3].str
, yyvsp
[-2].val
));
1172 DBG ((" sbit=%d ebit=%d flags=0x%x\n", sbit
, ebit
, yyvsp
[0].val
));
1173 insn
=itbl_add_insn (yyvsp
[-5].num
, yyvsp
[-3].str
, yyvsp
[-2].val
, sbit
, ebit
, yyvsp
[0].val
);
1177 #line 322 "itbl-parse.y"
1181 #line 335 "itbl-parse.y"
1183 DBGL2 (("ftype\n"));
1184 yyval
.num
= yyvsp
[0].num
;
1188 #line 340 "itbl-parse.y"
1195 #line 345 "itbl-parse.y"
1197 DBGL2 (("immed\n"));
1202 #line 353 "itbl-parse.y"
1204 DBG (("line %d: field type=%d sbit=%d ebit=%d, flags=0x%x\n",
1205 insntbl_line
, yyvsp
[-2].num
, sbit
, ebit
, yyvsp
[0].val
));
1206 itbl_add_operand (insn
, yyvsp
[-2].num
, sbit
, ebit
, yyvsp
[0].val
);
1210 #line 362 "itbl-parse.y"
1212 yyval
.val
= yyvsp
[-2].num
| yyvsp
[0].val
;
1216 #line 366 "itbl-parse.y"
1218 yyval
.val
= yyvsp
[-1].val
;
1222 #line 370 "itbl-parse.y"
1224 yyval
.val
= yyvsp
[0].num
;
1228 #line 377 "itbl-parse.y"
1230 DBGL2 (("flags=%d\n", yyvsp
[0].val
));
1231 yyval
.val
= yyvsp
[0].val
;
1235 #line 382 "itbl-parse.y"
1241 #line 389 "itbl-parse.y"
1243 DBGL2 (("range %d %d\n", yyvsp
[-2].num
, yyvsp
[0].num
));
1244 sbit
= yyvsp
[-2].num
;
1245 ebit
= yyvsp
[0].num
;
1249 #line 395 "itbl-parse.y"
1256 #line 403 "itbl-parse.y"
1258 DBGL2 (("pnum=%d\n",yyvsp
[0].num
));
1259 yyval
.num
= yyvsp
[0].num
;
1263 #line 411 "itbl-parse.y"
1270 #line 416 "itbl-parse.y"
1277 #line 421 "itbl-parse.y"
1284 #line 429 "itbl-parse.y"
1286 DBGL2 (("name=%s\n",yyvsp
[0].str
));
1287 yyval
.str
= yyvsp
[0].str
;
1291 #line 437 "itbl-parse.y"
1293 DBGL2 (("num=%d\n",yyvsp
[0].num
));
1294 yyval
.num
= yyvsp
[0].num
;
1298 #line 445 "itbl-parse.y"
1300 DBGL2 (("val=x%x\n",yyvsp
[0].num
));
1301 yyval
.val
= yyvsp
[0].num
;
1306 #line 706 "/usr/share/bison/bison.simple"
1318 short *yyssp1
= yyss
- 1;
1319 YYFPRINTF (stderr
, "state stack now");
1320 while (yyssp1
!= yyssp
)
1321 YYFPRINTF (stderr
, " %d", *++yyssp1
);
1322 YYFPRINTF (stderr
, "\n");
1331 /* Now `shift' the result of the reduction. Determine what state
1332 that goes to, based on the state we popped back to and the rule
1333 number reduced by. */
1337 yystate
= yypgoto
[yyn
- YYNTBASE
] + *yyssp
;
1338 if (yystate
>= 0 && yystate
<= YYLAST
&& yycheck
[yystate
] == *yyssp
)
1339 yystate
= yytable
[yystate
];
1341 yystate
= yydefgoto
[yyn
- YYNTBASE
];
1346 /*------------------------------------.
1347 | yyerrlab -- here on detecting error |
1348 `------------------------------------*/
1350 /* If not already recovering from an error, report this error. */
1355 #ifdef YYERROR_VERBOSE
1356 yyn
= yypact
[yystate
];
1358 if (yyn
> YYFLAG
&& yyn
< YYLAST
)
1360 YYSIZE_T yysize
= 0;
1365 /* Start YYX at -YYN if negative to avoid negative indexes in
1367 for (yyx
= yyn
< 0 ? -yyn
: 0;
1368 yyx
< (int) (sizeof (yytname
) / sizeof (char *)); yyx
++)
1369 if (yycheck
[yyx
+ yyn
] == yyx
)
1370 yysize
+= yystrlen (yytname
[yyx
]) + 15, yycount
++;
1371 yysize
+= yystrlen ("parse error, unexpected ") + 1;
1372 yysize
+= yystrlen (yytname
[YYTRANSLATE (yychar
)]);
1373 yymsg
= (char *) YYSTACK_ALLOC (yysize
);
1376 char *yyp
= yystpcpy (yymsg
, "parse error, unexpected ");
1377 yyp
= yystpcpy (yyp
, yytname
[YYTRANSLATE (yychar
)]);
1382 for (yyx
= yyn
< 0 ? -yyn
: 0;
1383 yyx
< (int) (sizeof (yytname
) / sizeof (char *));
1385 if (yycheck
[yyx
+ yyn
] == yyx
)
1387 const char *yyq
= ! yycount
? ", expecting " : " or ";
1388 yyp
= yystpcpy (yyp
, yyq
);
1389 yyp
= yystpcpy (yyp
, yytname
[yyx
]);
1394 YYSTACK_FREE (yymsg
);
1397 yyerror ("parse error; also virtual memory exhausted");
1400 #endif /* defined (YYERROR_VERBOSE) */
1401 yyerror ("parse error");
1406 /*--------------------------------------------------.
1407 | yyerrlab1 -- error raised explicitly by an action |
1408 `--------------------------------------------------*/
1410 if (yyerrstatus
== 3)
1412 /* If just tried and failed to reuse lookahead token after an
1413 error, discard it. */
1415 /* return failure if at end of input */
1416 if (yychar
== YYEOF
)
1418 YYDPRINTF ((stderr
, "Discarding token %d (%s).\n",
1419 yychar
, yytname
[yychar1
]));
1423 /* Else will try to reuse lookahead token after shifting the error
1426 yyerrstatus
= 3; /* Each real token shifted decrements this */
1431 /*-------------------------------------------------------------------.
1432 | yyerrdefault -- current state does not do anything special for the |
1434 `-------------------------------------------------------------------*/
1437 /* This is wrong; only states that explicitly want error tokens
1438 should shift them. */
1440 /* If its default is to accept any token, ok. Otherwise pop it. */
1441 yyn
= yydefact
[yystate
];
1447 /*---------------------------------------------------------------.
1448 | yyerrpop -- pop the current state because it cannot handle the |
1450 `---------------------------------------------------------------*/
1463 short *yyssp1
= yyss
- 1;
1464 YYFPRINTF (stderr
, "Error: state stack now");
1465 while (yyssp1
!= yyssp
)
1466 YYFPRINTF (stderr
, " %d", *++yyssp1
);
1467 YYFPRINTF (stderr
, "\n");
1475 yyn
= yypact
[yystate
];
1480 if (yyn
< 0 || yyn
> YYLAST
|| yycheck
[yyn
] != YYTERROR
)
1497 YYDPRINTF ((stderr
, "Shifting error token, "));
1508 /*-------------------------------------.
1509 | yyacceptlab -- YYACCEPT comes here. |
1510 `-------------------------------------*/
1515 /*-----------------------------------.
1516 | yyabortlab -- YYABORT comes here. |
1517 `-----------------------------------*/
1522 /*---------------------------------------------.
1523 | yyoverflowab -- parser overflow comes here. |
1524 `---------------------------------------------*/
1526 yyerror ("parser stack overflow");
1533 YYSTACK_FREE (yyss
);
1537 #line 450 "itbl-parse.y"
1544 printf ("line %d: %s\n", insntbl_line
, msg
);