1 /* A Bison parser, made by GNU Bison 3.0.2. */
3 /* Bison implementation for Yacc-like parsers in C
5 Copyright (C) 1984, 1989-1990, 2000-2013 Free Software Foundation, Inc.
7 This program is free software: you can redistribute it and/or modify
8 it under the terms of the GNU General Public License as published by
9 the Free Software Foundation, either version 3 of the License, or
10 (at your option) any later version.
12 This program is distributed in the hope that it will be useful,
13 but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 GNU General Public License for more details.
17 You should have received a copy of the GNU General Public License
18 along with this program. If not, see <http://www.gnu.org/licenses/>. */
20 /* As a special exception, you may create a larger work that contains
21 part or all of the Bison parser skeleton and distribute that work
22 under terms of your choice, so long as that work isn't itself a
23 parser generator using the skeleton or a modified version thereof
24 as a parser skeleton. Alternatively, if you modify or redistribute
25 the parser skeleton itself, you may (at your option) remove this
26 special exception, which will cause the skeleton and the resulting
27 Bison output files to be licensed under the GNU General Public
28 License without this special exception.
30 This special exception was added by the Free Software Foundation in
31 version 2.2 of Bison. */
33 /* C LALR(1) parser skeleton written by Richard Stallman, by
34 simplifying the original so-called "semantic" parser. */
36 /* All symbols defined below should begin with yy or YY, to avoid
37 infringing on user name space. This should be done even for local
38 variables, as they might otherwise be expanded by user macros.
39 There are some unavoidable exceptions within include files to
40 define necessary library symbols; they are noted "INFRINGES ON
41 USER NAME SPACE" below. */
43 /* Identify Bison output. */
47 #define YYBISON_VERSION "3.0.2"
50 #define YYSKELETON_NAME "yacc.c"
64 /* Copy the first part of user declarations. */
73 void yyerror (char const *);
82 extern struct field *sym_table;
83 struct field *putsym (char const *, unsigned int);
84 struct field *getsym (char const *);
86 struct field *sym_table;
87 struct field *sym_table_tail;
91 /* Bit array intermediary representation */
95 unsigned short checksum;
96 unsigned char *actualblob;
97 unsigned int lenactualblob;
100 #define VALID_BIT 0x80
102 #define CHECKSUM_SIZE 16
106 static void check_pointer (void *ptr)
109 printf("Error: Out of memory\n");
114 static unsigned char* value_to_bits (unsigned int v, unsigned int w)
117 unsigned char* bitarr;
119 if (w > MAX_WIDTH) w = MAX_WIDTH;
120 bitarr = (unsigned char *) malloc (w * sizeof (unsigned char));
121 check_pointer(bitarr);
122 memset (bitarr, 0, w);
124 for (i = 0; i < w; i++) {
125 bitarr[i] = VALID_BIT | ((v & (1 << i)) >> i);
130 /* Store each bit of a bitfield in a new byte sequentially 0x80 or 0x81 */
131 static void append_field_to_blob (unsigned char b[], unsigned int w)
134 binary->blb = (unsigned char *) realloc (binary->blb, binary->bloblen + w);
135 check_pointer(binary->blb);
136 for (j = 0, i = binary->bloblen; i < binary->bloblen + w; i++, j++) {
137 binary->blb[i] = VALID_BIT | (b[j] & 1);
138 //fprintf (stderr, "blob[%d] = %d\n", i, binary->blb[i] & 1);
140 binary->bloblen += w;
143 static void set_bitfield(char *name, unsigned int value)
145 unsigned long long i;
146 struct field *bf = getsym (name);
148 bf->value = value & 0xffffffff;
149 i = (1 << bf->width) - 1;
150 if (bf->width > 8 * sizeof (unsigned int)) {
151 fprintf(stderr, "Overflow in bitfield, truncating bits to fit\n");
152 bf->value = value & i;
154 //fprintf(stderr, "Setting `%s` = %d\n", bf->name, bf->value);
156 fprintf(stderr, "Can't find bitfield `%s` in spec\n", name);
160 static void set_bitfield_array(char *name, unsigned int n, unsigned int value)
163 unsigned long len = strlen (name);
164 char *namen = (char *) malloc ((len + 9) * sizeof (char));
165 check_pointer(namen);
166 for (i = 0; i < n; i++) {
167 snprintf (namen, len + 8, "%s%x", name, i);
168 set_bitfield (namen, value);
173 static void create_new_bitfield(char *name, unsigned int width)
177 if (!(bf = putsym (name, width))) return;
178 //fprintf(stderr, "Added bitfield `%s` : %d\n", bf->name, width);
181 static void create_new_bitfields(char *name, unsigned int n, unsigned int width)
184 unsigned long len = strlen (name);
185 char *namen = (char *) malloc ((len + 9) * sizeof (char));
186 check_pointer(namen);
187 for (i = 0; i < n; i++) {
188 snprintf (namen, len + 8, "%s%x", name, i);
189 create_new_bitfield (namen, width);
194 struct field *putsym (char const *sym_name, unsigned int w)
196 if (getsym(sym_name)) {
197 fprintf(stderr, "Cannot add duplicate named bitfield `%s`\n", sym_name);
200 struct field *ptr = (struct field *) malloc (sizeof (struct field));
202 ptr->name = (char *) malloc (strlen (sym_name) + 1);
203 check_pointer(ptr->name);
204 strcpy (ptr->name, sym_name);
207 ptr->next = (struct field *)0;
208 if (sym_table_tail) {
209 sym_table_tail->next = ptr;
213 sym_table_tail = ptr;
217 struct field *getsym (char const *sym_name)
220 for (ptr = sym_table; ptr != (struct field *) 0;
221 ptr = (struct field *)ptr->next) {
222 if (strcmp (ptr->name, sym_name) == 0)
228 static void dump_all_values (void)
231 for (ptr = sym_table; ptr != (struct field *) 0;
232 ptr = (struct field *)ptr->next) {
233 fprintf(stderr, "%s = %d (%d bits)\n",
240 static void empty_field_table(void)
243 struct field *ptrnext;
245 for (ptr = sym_table; ptr != (struct field *) 0; ptr = ptrnext) {
250 ptrnext = (struct field *) 0;
257 static void create_binary_blob (void)
259 if (binary && binary->blb) {
263 binary = (struct blob *) malloc (sizeof (struct blob));
264 check_pointer(binary);
265 binary->blb = (unsigned char *) malloc (sizeof (unsigned char));
266 check_pointer(binary->blb);
268 binary->blb[0] = VALID_BIT;
271 static void interpret_next_blob_value (struct field *f)
276 if (binary->bloblen >= binary->lenactualblob * 8) {
281 for (i = 0; i < f->width; i++) {
282 v |= (binary->blb[binary->bloblen++] & 1) << i;
289 static void generate_setter_bitfields(unsigned char *bin)
294 /* Convert bytes to bit array */
295 for (i = 0; i < binary->lenactualblob; i++) {
296 append_field_to_blob (value_to_bits(bin[i], 8), 8);
299 /* Reset blob position to zero */
302 fprintf (fp, "# AUTOGENERATED SETTER BY BINCFG\n{\n");
304 /* Traverse spec and output bitfield setters based on blob values */
305 for (ptr = sym_table; ptr != (struct field *) 0; ptr = ptr->next) {
307 interpret_next_blob_value(ptr);
308 fprintf (fp, "\t\"%s\" = 0x%x,\n", ptr->name, ptr->value);
310 fseek(fp, -2, SEEK_CUR);
311 fprintf (fp, "\n}\n");
314 static void generate_binary_with_gbe_checksum(void)
317 unsigned short checksum;
319 /* traverse spec, push to blob and add up for checksum */
321 unsigned int uptochksum = 0;
322 for (ptr = sym_table; ptr != (struct field *) 0; ptr = ptr->next) {
323 if (strcmp (ptr->name, "checksum_gbe") == 0) {
324 /* Stop traversing because we hit checksum */
328 append_field_to_blob (
329 value_to_bits(ptr->value, ptr->width),
331 uptochksum += ptr->width;
334 /* deserialize bits of blob up to checksum */
335 for (i = 0; i < uptochksum; i += 8) {
336 unsigned char byte = (((binary->blb[i+0] & 1) << 0)
337 | ((binary->blb[i+1] & 1) << 1)
338 | ((binary->blb[i+2] & 1) << 2)
339 | ((binary->blb[i+3] & 1) << 3)
340 | ((binary->blb[i+4] & 1) << 4)
341 | ((binary->blb[i+5] & 1) << 5)
342 | ((binary->blb[i+6] & 1) << 6)
343 | ((binary->blb[i+7] & 1) << 7)
345 fprintf(fp, "%c", byte);
347 /* incremental 16 bit checksum */
349 binary->checksum += byte;
351 binary->checksum += byte << 8;
355 checksum = (0xbaba - binary->checksum) & 0xffff;
357 /* Now write checksum */
358 set_bitfield ("checksum_gbe", checksum);
360 fprintf(fp, "%c", checksum & 0xff);
361 fprintf(fp, "%c", (checksum & 0xff00) >> 8);
363 append_field_to_blob (value_to_bits(checksum, 16), 16);
365 for (; ptr != (struct field *) 0; ptr = ptr->next) {
366 append_field_to_blob (
367 value_to_bits(ptr->value, ptr->width), ptr->width);
370 /* deserialize rest of blob past checksum */
371 for (i = uptochksum + CHECKSUM_SIZE; i < binary->bloblen; i += 8) {
372 unsigned char byte = (((binary->blb[i+0] & 1) << 0)
373 | ((binary->blb[i+1] & 1) << 1)
374 | ((binary->blb[i+2] & 1) << 2)
375 | ((binary->blb[i+3] & 1) << 3)
376 | ((binary->blb[i+4] & 1) << 4)
377 | ((binary->blb[i+5] & 1) << 5)
378 | ((binary->blb[i+6] & 1) << 6)
379 | ((binary->blb[i+7] & 1) << 7)
381 fprintf(fp, "%c", byte);
386 static void generate_binary(void)
391 if (binary->bloblen % 8) {
392 fprintf (stderr, "ERROR: Spec must be multiple of 8 bits wide\n");
396 if (getsym ("checksum_gbe")) {
397 generate_binary_with_gbe_checksum();
401 /* traverse spec, push to blob */
402 for (ptr = sym_table; ptr != (struct field *) 0; ptr = ptr->next) {
403 append_field_to_blob (
404 value_to_bits(ptr->value, ptr->width),
408 /* deserialize bits of blob */
409 for (i = 0; i < binary->bloblen; i += 8) {
410 unsigned char byte = (((binary->blb[i+0] & 1) << 0)
411 | ((binary->blb[i+1] & 1) << 1)
412 | ((binary->blb[i+2] & 1) << 2)
413 | ((binary->blb[i+3] & 1) << 3)
414 | ((binary->blb[i+4] & 1) << 4)
415 | ((binary->blb[i+5] & 1) << 5)
416 | ((binary->blb[i+6] & 1) << 6)
417 | ((binary->blb[i+7] & 1) << 7)
419 fprintf(fp, "%c", byte);
427 # if defined __cplusplus && 201103L <= __cplusplus
428 # define YY_NULLPTR nullptr
430 # define YY_NULLPTR 0
434 /* Enabling verbose error messages. */
435 #ifdef YYERROR_VERBOSE
436 # undef YYERROR_VERBOSE
437 # define YYERROR_VERBOSE 1
439 # define YYERROR_VERBOSE 0
442 /* In a future release of Bison, this section will be replaced
443 by #include "bincfg.tab.h_shipped". */
444 #ifndef YY_YY_COREBOOT_UTIL_BINCFG_BINCFG_TAB_H_SHIPPED_INCLUDED
445 # define YY_YY_COREBOOT_UTIL_BINCFG_BINCFG_TAB_H_SHIPPED_INCLUDED
469 #if ! defined YYSTYPE && ! defined YYSTYPE_IS_DECLARED
470 typedef union YYSTYPE YYSTYPE;
477 unsigned int *u32array;
479 unsigned char *u8array;
483 # define YYSTYPE_IS_TRIVIAL 1
484 # define YYSTYPE_IS_DECLARED 1
488 extern YYSTYPE yylval;
492 #endif /* !YY_YY_COREBOOT_UTIL_BINCFG_BINCFG_TAB_H_SHIPPED_INCLUDED */
494 /* Copy the second part of user declarations. */
503 typedef YYTYPE_UINT8 yytype_uint8;
505 typedef unsigned char yytype_uint8;
509 typedef YYTYPE_INT8 yytype_int8;
511 typedef signed char yytype_int8;
515 typedef YYTYPE_UINT16 yytype_uint16;
517 typedef unsigned short int yytype_uint16;
521 typedef YYTYPE_INT16 yytype_int16;
523 typedef short int yytype_int16;
527 # ifdef __SIZE_TYPE__
528 # define YYSIZE_T __SIZE_TYPE__
529 # elif defined size_t
530 # define YYSIZE_T size_t
531 # elif ! defined YYSIZE_T
532 # include <stddef.h> /* INFRINGES ON USER NAME SPACE */
533 # define YYSIZE_T size_t
535 # define YYSIZE_T unsigned int
539 #define YYSIZE_MAXIMUM ((YYSIZE_T) -1)
542 # if defined YYENABLE_NLS && YYENABLE_NLS
544 # include <libintl.h> /* INFRINGES ON USER NAME SPACE */
545 # define YY_(Msgid) dgettext ("bison-runtime", Msgid)
549 # define YY_(Msgid) Msgid
554 # if (defined __GNUC__ \
555 && (2 < __GNUC__ || (__GNUC__ == 2 && 96 <= __GNUC_MINOR__))) \
556 || defined __SUNPRO_C && 0x5110 <= __SUNPRO_C
557 # define YY_ATTRIBUTE(Spec) __attribute__(Spec)
559 # define YY_ATTRIBUTE(Spec) /* empty */
563 #ifndef YY_ATTRIBUTE_PURE
564 # define YY_ATTRIBUTE_PURE YY_ATTRIBUTE ((__pure__))
567 #ifndef YY_ATTRIBUTE_UNUSED
568 # define YY_ATTRIBUTE_UNUSED YY_ATTRIBUTE ((__unused__))
571 #if !defined _Noreturn \
572 && (!defined __STDC_VERSION__ || __STDC_VERSION__ < 201112)
573 # if defined _MSC_VER && 1200 <= _MSC_VER
574 # define _Noreturn __declspec (noreturn)
576 # define _Noreturn YY_ATTRIBUTE ((__noreturn__))
580 /* Suppress unused-variable warnings by "using" E. */
581 #if ! defined lint || defined __GNUC__
582 # define YYUSE(E) ((void) (E))
584 # define YYUSE(E) /* empty */
587 #if defined __GNUC__ && 407 <= __GNUC__ * 100 + __GNUC_MINOR__
588 /* Suppress an incorrect diagnostic about yylval being uninitialized. */
589 # define YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN \
590 _Pragma ("GCC diagnostic push") \
591 _Pragma ("GCC diagnostic ignored \"-Wuninitialized\"")\
592 _Pragma ("GCC diagnostic ignored \"-Wmaybe-uninitialized\"")
593 # define YY_IGNORE_MAYBE_UNINITIALIZED_END \
594 _Pragma ("GCC diagnostic pop")
596 # define YY_INITIAL_VALUE(Value) Value
598 #ifndef YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN
599 # define YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN
600 # define YY_IGNORE_MAYBE_UNINITIALIZED_END
602 #ifndef YY_INITIAL_VALUE
603 # define YY_INITIAL_VALUE(Value) /* Nothing. */
607 #if ! defined yyoverflow || YYERROR_VERBOSE
609 /* The parser invokes alloca or malloc; define the necessary symbols. */
611 # ifdef YYSTACK_USE_ALLOCA
612 # if YYSTACK_USE_ALLOCA
614 # define YYSTACK_ALLOC __builtin_alloca
615 # elif defined __BUILTIN_VA_ARG_INCR
616 # include <alloca.h> /* INFRINGES ON USER NAME SPACE */
618 # define YYSTACK_ALLOC __alloca
619 # elif defined _MSC_VER
620 # include <malloc.h> /* INFRINGES ON USER NAME SPACE */
621 # define alloca _alloca
623 # define YYSTACK_ALLOC alloca
624 # if ! defined _ALLOCA_H && ! defined EXIT_SUCCESS
625 # include <stdlib.h> /* INFRINGES ON USER NAME SPACE */
626 /* Use EXIT_SUCCESS as a witness for stdlib.h. */
627 # ifndef EXIT_SUCCESS
628 # define EXIT_SUCCESS 0
635 # ifdef YYSTACK_ALLOC
636 /* Pacify GCC's 'empty if-body' warning. */
637 # define YYSTACK_FREE(Ptr) do { /* empty */; } while (0)
638 # ifndef YYSTACK_ALLOC_MAXIMUM
639 /* The OS might guarantee only one guard page at the bottom of the stack,
640 and a page size can be as small as 4096 bytes. So we cannot safely
641 invoke alloca (N) if N exceeds 4096. Use a slightly smaller number
642 to allow for a few compiler-allocated temporary stack slots. */
643 # define YYSTACK_ALLOC_MAXIMUM 4032 /* reasonable circa 2006 */
646 # define YYSTACK_ALLOC YYMALLOC
647 # define YYSTACK_FREE YYFREE
648 # ifndef YYSTACK_ALLOC_MAXIMUM
649 # define YYSTACK_ALLOC_MAXIMUM YYSIZE_MAXIMUM
651 # if (defined __cplusplus && ! defined EXIT_SUCCESS \
652 && ! ((defined YYMALLOC || defined malloc) \
653 && (defined YYFREE || defined free)))
654 # include <stdlib.h> /* INFRINGES ON USER NAME SPACE */
655 # ifndef EXIT_SUCCESS
656 # define EXIT_SUCCESS 0
660 # define YYMALLOC malloc
661 # if ! defined malloc && ! defined EXIT_SUCCESS
662 void *malloc (YYSIZE_T); /* INFRINGES ON USER NAME SPACE */
667 # if ! defined free && ! defined EXIT_SUCCESS
668 void free (void *); /* INFRINGES ON USER NAME SPACE */
672 #endif /* ! defined yyoverflow || YYERROR_VERBOSE */
675 #if (! defined yyoverflow \
676 && (! defined __cplusplus \
677 || (defined YYSTYPE_IS_TRIVIAL && YYSTYPE_IS_TRIVIAL)))
679 /* A type that is properly aligned for any stack member. */
682 yytype_int16 yyss_alloc;
686 /* The size of the maximum gap between one aligned stack and the next. */
687 # define YYSTACK_GAP_MAXIMUM (sizeof (union yyalloc) - 1)
689 /* The size of an array large to enough to hold all stacks, each with
691 # define YYSTACK_BYTES(N) \
692 ((N) * (sizeof (yytype_int16) + sizeof (YYSTYPE)) \
693 + YYSTACK_GAP_MAXIMUM)
695 # define YYCOPY_NEEDED 1
697 /* Relocate STACK from its old location to the new one. The
698 local variables YYSIZE and YYSTACKSIZE give the old and new number of
699 elements in the stack, and YYPTR gives the new location of the
700 stack. Advance YYPTR to a properly aligned location for the next
702 # define YYSTACK_RELOCATE(Stack_alloc, Stack) \
705 YYSIZE_T yynewbytes; \
706 YYCOPY (&yyptr->Stack_alloc, Stack, yysize); \
707 Stack = &yyptr->Stack_alloc; \
708 yynewbytes = yystacksize * sizeof (*Stack) + YYSTACK_GAP_MAXIMUM; \
709 yyptr += yynewbytes / sizeof (*yyptr); \
715 #if defined YYCOPY_NEEDED && YYCOPY_NEEDED
716 /* Copy COUNT objects from SRC to DST. The source and destination do
719 # if defined __GNUC__ && 1 < __GNUC__
720 # define YYCOPY(Dst, Src, Count) \
721 __builtin_memcpy (Dst, Src, (Count) * sizeof (*(Src)))
723 # define YYCOPY(Dst, Src, Count) \
727 for (yyi = 0; yyi < (Count); yyi++) \
728 (Dst)[yyi] = (Src)[yyi]; \
733 #endif /* !YYCOPY_NEEDED */
735 /* YYFINAL -- State number of the termination state. */
737 /* YYLAST -- Last index in YYTABLE. */
740 /* YYNTOKENS -- Number of terminals. */
742 /* YYNNTS -- Number of nonterminals. */
744 /* YYNRULES -- Number of rules. */
746 /* YYNSTATES -- Number of states. */
749 /* YYTRANSLATE[YYX] -- Symbol number corresponding to YYX as returned
750 by yylex, with out-of-bounds checking. */
752 #define YYMAXUTOK 263
754 #define YYTRANSLATE(YYX) \
755 ((unsigned int) (YYX) <= YYMAXUTOK ? yytranslate[YYX] : YYUNDEFTOK)
757 /* YYTRANSLATE[TOKEN-NUM] -- Symbol number corresponding to TOKEN-NUM
758 as returned by yylex, without out-of-bounds checking. */
759 static const yytype_uint8 yytranslate[] =
761 0, 2, 2, 2, 2, 2, 2, 2, 2, 2,
762 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
763 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
764 2, 2, 2, 2, 2, 2, 2, 9, 2, 2,
765 2, 2, 2, 2, 12, 2, 2, 2, 2, 2,
766 2, 2, 2, 2, 2, 2, 2, 2, 13, 2,
767 2, 14, 2, 2, 2, 2, 2, 2, 2, 2,
768 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
769 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
770 2, 15, 2, 16, 2, 2, 2, 2, 2, 2,
771 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
772 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
773 2, 2, 2, 10, 2, 11, 2, 2, 2, 2,
774 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
775 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
776 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
777 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
778 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
779 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
780 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
781 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
782 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
783 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
784 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
785 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
786 2, 2, 2, 2, 2, 2, 1, 2, 3, 4,
791 /* YYRLINE[YYN] -- Source line where rule number YYN was defined. */
792 static const yytype_uint16 yyrline[] =
794 0, 399, 399, 401, 402, 407, 411, 412, 417, 418,
795 422, 423, 427, 428, 433, 434, 438, 439
799 #if YYDEBUG || YYERROR_VERBOSE || 0
800 /* YYTNAME[SYMBOL-NUM] -- String name of the symbol SYMBOL-NUM.
801 First, the terminals, then, starting at YYNTOKENS, nonterminals. */
802 static const char *const yytname[] =
804 "$end", "error", "$undefined", "name", "val", "vals", "hexbyte",
805 "binblob", "eof", "'%'", "'{'", "'}'", "','", "':'", "'='", "'['", "']'",
806 "$accept", "input", "blob", "spec", "specmembers", "specpair", "setter",
807 "valuemembers", "setpair", YY_NULLPTR
812 /* YYTOKNUM[NUM] -- (External) token number corresponding to the
813 (internal) symbol number NUM (which must be that of a token). */
814 static const yytype_uint16 yytoknum[] =
816 0, 256, 257, 258, 259, 260, 261, 262, 263, 37,
817 123, 125, 44, 58, 61, 91, 93
821 #define YYPACT_NINF -11
823 #define yypact_value_is_default(Yystate) \
824 (!!((Yystate) == (-11)))
826 #define YYTABLE_NINF -1
828 #define yytable_value_is_error(Yytable_value) \
831 /* YYPACT[STATE-NUM] -- Index in YYTABLE of the portion describing
833 static const yytype_int8 yypact[] =
835 -11, 0, -11, -2, -3, -10, -11, -9, -4, 3,
836 1, -11, 7, 12, 13, -11, 15, -11, -1, -11,
837 8, 9, -11, -11, 4, -11, 18, 19, -11, 21,
838 14, -11, 10, -11, 24, 11, -11, 25, -11
841 /* YYDEFACT[STATE-NUM] -- Default reduction number in state STATE-NUM.
842 Performed when YYTABLE does not specify something else to do. Zero
843 means the default is an error. */
844 static const yytype_uint8 yydefact[] =
846 2, 0, 1, 0, 0, 0, 6, 0, 8, 0,
847 0, 4, 0, 0, 0, 7, 0, 5, 0, 12,
848 0, 14, 3, 10, 0, 9, 0, 0, 13, 0,
849 0, 16, 0, 15, 0, 0, 11, 0, 17
852 /* YYPGOTO[NTERM-NUM]. */
853 static const yytype_int8 yypgoto[] =
855 -11, -11, -11, -11, 16, -11, -11, 2, -11
858 /* YYDEFGOTO[NTERM-NUM]. */
859 static const yytype_int8 yydefgoto[] =
861 -1, 1, 11, 4, 7, 8, 12, 20, 21
864 /* YYTABLE[YYPACT[STATE-NUM]] -- What to do in state STATE-NUM. If
865 positive, shift that token. If negative, reduce the rule whose
866 number is the opposite. If YYTABLE_NINF, syntax error. */
867 static const yytype_uint8 yytable[] =
869 2, 5, 15, 13, 18, 14, 9, 10, 16, 6,
870 3, 17, 19, 26, 27, 22, 23, 24, 5, 28,
871 30, 29, 31, 32, 18, 37, 35, 34, 36, 38,
875 static const yytype_int8 yycheck[] =
877 0, 3, 11, 13, 3, 15, 9, 10, 12, 11,
878 10, 8, 11, 14, 15, 8, 4, 4, 3, 11,
879 16, 12, 4, 4, 3, 14, 16, 13, 4, 4,
883 /* YYSTOS[STATE-NUM] -- The (internal number of the) accessing
884 symbol of state STATE-NUM. */
885 static const yytype_uint8 yystos[] =
887 0, 18, 0, 10, 20, 3, 11, 21, 22, 9,
888 10, 19, 23, 13, 15, 11, 12, 8, 3, 11,
889 24, 25, 8, 4, 4, 21, 14, 15, 11, 12,
890 16, 4, 4, 24, 13, 16, 4, 14, 4
893 /* YYR1[YYN] -- Symbol number of symbol that rule YYN derives. */
894 static const yytype_uint8 yyr1[] =
896 0, 17, 18, 18, 18, 19, 20, 20, 21, 21,
897 22, 22, 23, 23, 24, 24, 25, 25
900 /* YYR2[YYN] -- Number of symbols on the right hand side of rule YYN. */
901 static const yytype_uint8 yyr2[] =
903 0, 2, 0, 4, 3, 2, 2, 3, 1, 3,
904 3, 6, 2, 3, 1, 3, 3, 6
908 #define yyerrok (yyerrstatus = 0)
909 #define yyclearin (yychar = YYEMPTY)
913 #define YYACCEPT goto yyacceptlab
914 #define YYABORT goto yyabortlab
915 #define YYERROR goto yyerrorlab
918 #define YYRECOVERING() (!!yyerrstatus)
920 #define YYBACKUP(Token, Value) \
922 if (yychar == YYEMPTY) \
926 YYPOPSTACK (yylen); \
932 yyerror (YY_("syntax error: cannot back up")); \
937 /* Error token number */
939 #define YYERRCODE 256
943 /* Enable debugging if requested. */
947 # include <stdio.h> /* INFRINGES ON USER NAME SPACE */
948 # define YYFPRINTF fprintf
951 # define YYDPRINTF(Args) \
957 /* This macro is provided for backward compatibility. */
958 #ifndef YY_LOCATION_PRINT
959 # define YY_LOCATION_PRINT(File, Loc) ((void) 0)
963 # define YY_SYMBOL_PRINT(Title, Type, Value, Location) \
967 YYFPRINTF (stderr, "%s ", Title); \
968 yy_symbol_print (stderr, \
970 YYFPRINTF (stderr, "\n"); \
975 /*----------------------------------------.
976 | Print this symbol's value on YYOUTPUT. |
977 `----------------------------------------*/
980 yy_symbol_value_print (FILE *yyoutput, int yytype, YYSTYPE const * const yyvaluep)
982 FILE *yyo = yyoutput;
987 if (yytype < YYNTOKENS)
988 YYPRINT (yyoutput, yytoknum[yytype], *yyvaluep);
994 /*--------------------------------.
995 | Print this symbol on YYOUTPUT. |
996 `--------------------------------*/
999 yy_symbol_print (FILE *yyoutput, int yytype, YYSTYPE const * const yyvaluep)
1001 YYFPRINTF (yyoutput, "%s %s (",
1002 yytype < YYNTOKENS ? "token" : "nterm", yytname[yytype]);
1004 yy_symbol_value_print (yyoutput, yytype, yyvaluep);
1005 YYFPRINTF (yyoutput, ")");
1008 /*------------------------------------------------------------------.
1009 | yy_stack_print -- Print the state stack from its BOTTOM up to its |
1011 `------------------------------------------------------------------*/
1014 yy_stack_print (yytype_int16 *yybottom, yytype_int16 *yytop)
1016 YYFPRINTF (stderr, "Stack now");
1017 for (; yybottom <= yytop; yybottom++)
1019 int yybot = *yybottom;
1020 YYFPRINTF (stderr, " %d", yybot);
1022 YYFPRINTF (stderr, "\n");
1025 # define YY_STACK_PRINT(Bottom, Top) \
1028 yy_stack_print ((Bottom), (Top)); \
1032 /*------------------------------------------------.
1033 | Report that the YYRULE is going to be reduced. |
1034 `------------------------------------------------*/
1037 yy_reduce_print (yytype_int16 *yyssp, YYSTYPE *yyvsp, int yyrule)
1039 unsigned long int yylno = yyrline[yyrule];
1040 int yynrhs = yyr2[yyrule];
1042 YYFPRINTF (stderr, "Reducing stack by rule %d (line %lu):\n",
1044 /* The symbols being reduced. */
1045 for (yyi = 0; yyi < yynrhs; yyi++)
1047 YYFPRINTF (stderr, " $%d = ", yyi + 1);
1048 yy_symbol_print (stderr,
1049 yystos[yyssp[yyi + 1 - yynrhs]],
1050 &(yyvsp[(yyi + 1) - (yynrhs)])
1052 YYFPRINTF (stderr, "\n");
1056 # define YY_REDUCE_PRINT(Rule) \
1059 yy_reduce_print (yyssp, yyvsp, Rule); \
1062 /* Nonzero means print parse trace. It is left uninitialized so that
1063 multiple parsers can coexist. */
1065 #else /* !YYDEBUG */
1066 # define YYDPRINTF(Args)
1067 # define YY_SYMBOL_PRINT(Title, Type, Value, Location)
1068 # define YY_STACK_PRINT(Bottom, Top)
1069 # define YY_REDUCE_PRINT(Rule)
1070 #endif /* !YYDEBUG */
1073 /* YYINITDEPTH -- initial size of the parser's stacks. */
1075 # define YYINITDEPTH 200
1078 /* YYMAXDEPTH -- maximum size the stacks can grow to (effective only
1079 if the built-in stack extension method is used).
1081 Do not make this value too large; the results are undefined if
1082 YYSTACK_ALLOC_MAXIMUM < YYSTACK_BYTES (YYMAXDEPTH)
1083 evaluated with infinite-precision integer arithmetic. */
1086 # define YYMAXDEPTH 10000
1093 # if defined __GLIBC__ && defined _STRING_H
1094 # define yystrlen strlen
1096 /* Return the length of YYSTR. */
1098 yystrlen (const char *yystr)
1101 for (yylen = 0; yystr[yylen]; yylen++)
1109 # if defined __GLIBC__ && defined _STRING_H && defined _GNU_SOURCE
1110 # define yystpcpy stpcpy
1112 /* Copy YYSRC to YYDEST, returning the address of the terminating '\0' in
1115 yystpcpy (char *yydest, const char *yysrc)
1118 const char *yys = yysrc;
1120 while ((*yyd++ = *yys++) != '\0')
1129 /* Copy to YYRES the contents of YYSTR after stripping away unnecessary
1130 quotes and backslashes, so that it's suitable for yyerror. The
1131 heuristic is that double-quoting is unnecessary unless the string
1132 contains an apostrophe, a comma, or backslash (other than
1133 backslash-backslash). YYSTR is taken from yytname. If YYRES is
1134 null, do not copy; instead, return the length of what the result
1137 yytnamerr (char *yyres, const char *yystr)
1142 char const *yyp = yystr;
1149 goto do_not_strip_quotes;
1153 goto do_not_strip_quotes;
1166 do_not_strip_quotes: ;
1170 return yystrlen (yystr);
1172 return yystpcpy (yyres, yystr) - yyres;
1176 /* Copy into *YYMSG, which is of size *YYMSG_ALLOC, an error message
1177 about the unexpected token YYTOKEN for the state stack whose top is
1180 Return 0 if *YYMSG was successfully written. Return 1 if *YYMSG is
1181 not large enough to hold the message. In that case, also set
1182 *YYMSG_ALLOC to the required number of bytes. Return 2 if the
1183 required number of bytes is too large to store. */
1185 yysyntax_error (YYSIZE_T *yymsg_alloc, char **yymsg,
1186 yytype_int16 *yyssp, int yytoken)
1188 YYSIZE_T yysize0 = yytnamerr (YY_NULLPTR, yytname[yytoken]);
1189 YYSIZE_T yysize = yysize0;
1190 enum { YYERROR_VERBOSE_ARGS_MAXIMUM = 5 };
1191 /* Internationalized format string. */
1192 const char *yyformat = YY_NULLPTR;
1193 /* Arguments of yyformat. */
1194 char const *yyarg[YYERROR_VERBOSE_ARGS_MAXIMUM];
1195 /* Number of reported tokens (one for the "unexpected", one per
1199 /* There are many possibilities here to consider:
1200 - If this state is a consistent state with a default action, then
1201 the only way this function was invoked is if the default action
1202 is an error action. In that case, don't check for expected
1203 tokens because there are none.
1204 - The only way there can be no lookahead present (in yychar) is if
1205 this state is a consistent state with a default action. Thus,
1206 detecting the absence of a lookahead is sufficient to determine
1207 that there is no unexpected or expected token to report. In that
1208 case, just report a simple "syntax error".
1209 - Don't assume there isn't a lookahead just because this state is a
1210 consistent state with a default action. There might have been a
1211 previous inconsistent state, consistent state with a non-default
1212 action, or user semantic action that manipulated yychar.
1213 - Of course, the expected token list depends on states to have
1214 correct lookahead information, and it depends on the parser not
1215 to perform extra reductions after fetching a lookahead from the
1216 scanner and before detecting a syntax error. Thus, state merging
1217 (from LALR or IELR) and default reductions corrupt the expected
1218 token list. However, the list is correct for canonical LR with
1219 one exception: it will still contain any token that will not be
1220 accepted due to an error action in a later state.
1222 if (yytoken != YYEMPTY)
1224 int yyn = yypact[*yyssp];
1225 yyarg[yycount++] = yytname[yytoken];
1226 if (!yypact_value_is_default (yyn))
1228 /* Start YYX at -YYN if negative to avoid negative indexes in
1229 YYCHECK. In other words, skip the first -YYN actions for
1230 this state because they are default actions. */
1231 int yyxbegin = yyn < 0 ? -yyn : 0;
1232 /* Stay within bounds of both yycheck and yytname. */
1233 int yychecklim = YYLAST - yyn + 1;
1234 int yyxend = yychecklim < YYNTOKENS ? yychecklim : YYNTOKENS;
1237 for (yyx = yyxbegin; yyx < yyxend; ++yyx)
1238 if (yycheck[yyx + yyn] == yyx && yyx != YYTERROR
1239 && !yytable_value_is_error (yytable[yyx + yyn]))
1241 if (yycount == YYERROR_VERBOSE_ARGS_MAXIMUM)
1247 yyarg[yycount++] = yytname[yyx];
1249 YYSIZE_T yysize1 = yysize + yytnamerr (YY_NULLPTR, yytname[yyx]);
1250 if (! (yysize <= yysize1
1251 && yysize1 <= YYSTACK_ALLOC_MAXIMUM))
1261 # define YYCASE_(N, S) \
1265 YYCASE_(0, YY_("syntax error"));
1266 YYCASE_(1, YY_("syntax error, unexpected %s"));
1267 YYCASE_(2, YY_("syntax error, unexpected %s, expecting %s"));
1268 YYCASE_(3, YY_("syntax error, unexpected %s, expecting %s or %s"));
1269 YYCASE_(4, YY_("syntax error, unexpected %s, expecting %s or %s or %s"));
1270 YYCASE_(5, YY_("syntax error, unexpected %s, expecting %s or %s or %s or %s"));
1275 YYSIZE_T yysize1 = yysize + yystrlen (yyformat);
1276 if (! (yysize <= yysize1 && yysize1 <= YYSTACK_ALLOC_MAXIMUM))
1281 if (*yymsg_alloc < yysize)
1283 *yymsg_alloc = 2 * yysize;
1284 if (! (yysize <= *yymsg_alloc
1285 && *yymsg_alloc <= YYSTACK_ALLOC_MAXIMUM))
1286 *yymsg_alloc = YYSTACK_ALLOC_MAXIMUM;
1290 /* Avoid sprintf, as that infringes on the user's name space.
1291 Don't have undefined behavior even if the translation
1292 produced a string with the wrong number of "%s"s. */
1296 while ((*yyp = *yyformat) != '\0')
1297 if (*yyp == '%' && yyformat[1] == 's' && yyi < yycount)
1299 yyp += yytnamerr (yyp, yyarg[yyi++]);
1310 #endif /* YYERROR_VERBOSE */
1312 /*-----------------------------------------------.
1313 | Release the memory associated to this symbol. |
1314 `-----------------------------------------------*/
1317 yydestruct (const char *yymsg, int yytype, YYSTYPE *yyvaluep)
1322 YY_SYMBOL_PRINT (yymsg, yytype, yyvaluep, yylocationp);
1324 YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN
1326 YY_IGNORE_MAYBE_UNINITIALIZED_END
1332 /* The lookahead symbol. */
1335 /* The semantic value of the lookahead symbol. */
1337 /* Number of syntax errors so far. */
1349 /* Number of tokens to shift before error messages enabled. */
1352 /* The stacks and their tools:
1353 'yyss': related to states.
1354 'yyvs': related to semantic values.
1356 Refer to the stacks through separate pointers, to allow yyoverflow
1357 to reallocate them elsewhere. */
1359 /* The state stack. */
1360 yytype_int16 yyssa[YYINITDEPTH];
1362 yytype_int16 *yyssp;
1364 /* The semantic value stack. */
1365 YYSTYPE yyvsa[YYINITDEPTH];
1369 YYSIZE_T yystacksize;
1373 /* Lookahead token as an internal (translated) token number. */
1375 /* The variables used to return semantic value and location from the
1380 /* Buffer for error messages, and its allocated size. */
1382 char *yymsg = yymsgbuf;
1383 YYSIZE_T yymsg_alloc = sizeof yymsgbuf;
1386 #define YYPOPSTACK(N) (yyvsp -= (N), yyssp -= (N))
1388 /* The number of symbols on the RHS of the reduced rule.
1389 Keep to zero when no symbol should be popped. */
1392 yyssp = yyss = yyssa;
1393 yyvsp = yyvs = yyvsa;
1394 yystacksize = YYINITDEPTH;
1396 YYDPRINTF ((stderr, "Starting parse\n"));
1401 yychar = YYEMPTY; /* Cause a token to be read. */
1404 /*------------------------------------------------------------.
1405 | yynewstate -- Push a new state, which is found in yystate. |
1406 `------------------------------------------------------------*/
1408 /* In all cases, when you get here, the value and location stacks
1409 have just been pushed. So pushing a state here evens the stacks. */
1415 if (yyss + yystacksize - 1 <= yyssp)
1417 /* Get the current used size of the three stacks, in elements. */
1418 YYSIZE_T yysize = yyssp - yyss + 1;
1422 /* Give user a chance to reallocate the stack. Use copies of
1423 these so that the &'s don't force the real ones into
1425 YYSTYPE *yyvs1 = yyvs;
1426 yytype_int16 *yyss1 = yyss;
1428 /* Each stack pointer address is followed by the size of the
1429 data in use in that stack, in bytes. This used to be a
1430 conditional around just the two extra args, but that might
1431 be undefined if yyoverflow is a macro. */
1432 yyoverflow (YY_("memory exhausted"),
1433 &yyss1, yysize * sizeof (*yyssp),
1434 &yyvs1, yysize * sizeof (*yyvsp),
1440 #else /* no yyoverflow */
1441 # ifndef YYSTACK_RELOCATE
1442 goto yyexhaustedlab;
1444 /* Extend the stack our own way. */
1445 if (YYMAXDEPTH <= yystacksize)
1446 goto yyexhaustedlab;
1448 if (YYMAXDEPTH < yystacksize)
1449 yystacksize = YYMAXDEPTH;
1452 yytype_int16 *yyss1 = yyss;
1453 union yyalloc *yyptr =
1454 (union yyalloc *) YYSTACK_ALLOC (YYSTACK_BYTES (yystacksize));
1456 goto yyexhaustedlab;
1457 YYSTACK_RELOCATE (yyss_alloc, yyss);
1458 YYSTACK_RELOCATE (yyvs_alloc, yyvs);
1459 # undef YYSTACK_RELOCATE
1461 YYSTACK_FREE (yyss1);
1464 #endif /* no yyoverflow */
1466 yyssp = yyss + yysize - 1;
1467 yyvsp = yyvs + yysize - 1;
1469 YYDPRINTF ((stderr, "Stack size increased to %lu\n",
1470 (unsigned long int) yystacksize));
1472 if (yyss + yystacksize - 1 <= yyssp)
1476 YYDPRINTF ((stderr, "Entering state %d\n", yystate));
1478 if (yystate == YYFINAL)
1488 /* Do appropriate processing given the current state. Read a
1489 lookahead token if we need one and don't already have one. */
1491 /* First try to decide what to do without reference to lookahead token. */
1492 yyn = yypact[yystate];
1493 if (yypact_value_is_default (yyn))
1496 /* Not known => get a lookahead token if don't already have one. */
1498 /* YYCHAR is either YYEMPTY or YYEOF or a valid lookahead symbol. */
1499 if (yychar == YYEMPTY)
1501 YYDPRINTF ((stderr, "Reading a token: "));
1505 if (yychar <= YYEOF)
1507 yychar = yytoken = YYEOF;
1508 YYDPRINTF ((stderr, "Now at end of input.\n"));
1512 yytoken = YYTRANSLATE (yychar);
1513 YY_SYMBOL_PRINT ("Next token is", yytoken, &yylval, &yylloc);
1516 /* If the proper action on seeing token YYTOKEN is to reduce or to
1517 detect an error, take that action. */
1519 if (yyn < 0 || YYLAST < yyn || yycheck[yyn] != yytoken)
1524 if (yytable_value_is_error (yyn))
1530 /* Count tokens shifted since error; after three, turn off error
1535 /* Shift the lookahead token. */
1536 YY_SYMBOL_PRINT ("Shifting", yytoken, &yylval, &yylloc);
1538 /* Discard the shifted token. */
1542 YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN
1544 YY_IGNORE_MAYBE_UNINITIALIZED_END
1549 /*-----------------------------------------------------------.
1550 | yydefault -- do the default action for the current state. |
1551 `-----------------------------------------------------------*/
1553 yyn = yydefact[yystate];
1559 /*-----------------------------.
1560 | yyreduce -- Do a reduction. |
1561 `-----------------------------*/
1563 /* yyn is the number of a rule to reduce with. */
1566 /* If YYLEN is nonzero, implement the default value of the action:
1569 Otherwise, the following line sets YYVAL to garbage.
1570 This behavior is undocumented and Bison
1571 users should not rely upon it. Assigning to YYVAL
1572 unconditionally makes the parser a bit smaller, and it avoids a
1573 GCC warning that YYVAL may be used uninitialized. */
1574 yyval = yyvsp[1-yylen];
1577 YY_REDUCE_PRINT (yyn);
1582 { empty_field_table(); YYACCEPT;}
1588 { fprintf (stderr, "Parsed all bytes\n");
1589 empty_field_table(); YYACCEPT;}
1595 { generate_setter_bitfields(binary->actualblob); }
1601 { fprintf (stderr, "No spec\n"); }
1607 { fprintf (stderr, "Parsed all spec\n");
1608 create_binary_blob(); }
1614 { create_new_bitfield((yyvsp[-2].str), (yyvsp[0].u32)); }
1620 { create_new_bitfields((yyvsp[-5].str), (yyvsp[-3].u32), (yyvsp[0].u32)); }
1626 { fprintf (stderr, "No values\n"); }
1632 { fprintf (stderr, "Parsed all values\n");
1633 generate_binary(); }
1639 { set_bitfield((yyvsp[-2].str), (yyvsp[0].u32)); }
1645 { set_bitfield_array((yyvsp[-5].str), (yyvsp[-3].u32), (yyvsp[0].u32)); }
1653 /* User semantic actions sometimes alter yychar, and that requires
1654 that yytoken be updated with the new translation. We take the
1655 approach of translating immediately before every use of yytoken.
1656 One alternative is translating here after every semantic action,
1657 but that translation would be missed if the semantic action invokes
1658 YYABORT, YYACCEPT, or YYERROR immediately after altering yychar or
1659 if it invokes YYBACKUP. In the case of YYABORT or YYACCEPT, an
1660 incorrect destructor might then be invoked immediately. In the
1661 case of YYERROR or YYBACKUP, subsequent parser actions might lead
1662 to an incorrect destructor call or verbose syntax error message
1663 before the lookahead is translated. */
1664 YY_SYMBOL_PRINT ("-> $$ =", yyr1[yyn], &yyval, &yyloc);
1668 YY_STACK_PRINT (yyss, yyssp);
1672 /* Now 'shift' the result of the reduction. Determine what state
1673 that goes to, based on the state we popped back to and the rule
1674 number reduced by. */
1678 yystate = yypgoto[yyn - YYNTOKENS] + *yyssp;
1679 if (0 <= yystate && yystate <= YYLAST && yycheck[yystate] == *yyssp)
1680 yystate = yytable[yystate];
1682 yystate = yydefgoto[yyn - YYNTOKENS];
1687 /*--------------------------------------.
1688 | yyerrlab -- here on detecting error. |
1689 `--------------------------------------*/
1691 /* Make sure we have latest lookahead translation. See comments at
1692 user semantic actions for why this is necessary. */
1693 yytoken = yychar == YYEMPTY ? YYEMPTY : YYTRANSLATE (yychar);
1695 /* If not already recovering from an error, report this error. */
1699 #if ! YYERROR_VERBOSE
1700 yyerror (YY_("syntax error"));
1702 # define YYSYNTAX_ERROR yysyntax_error (&yymsg_alloc, &yymsg, \
1705 char const *yymsgp = YY_("syntax error");
1706 int yysyntax_error_status;
1707 yysyntax_error_status = YYSYNTAX_ERROR;
1708 if (yysyntax_error_status == 0)
1710 else if (yysyntax_error_status == 1)
1712 if (yymsg != yymsgbuf)
1713 YYSTACK_FREE (yymsg);
1714 yymsg = (char *) YYSTACK_ALLOC (yymsg_alloc);
1718 yymsg_alloc = sizeof yymsgbuf;
1719 yysyntax_error_status = 2;
1723 yysyntax_error_status = YYSYNTAX_ERROR;
1728 if (yysyntax_error_status == 2)
1729 goto yyexhaustedlab;
1731 # undef YYSYNTAX_ERROR
1737 if (yyerrstatus == 3)
1739 /* If just tried and failed to reuse lookahead token after an
1740 error, discard it. */
1742 if (yychar <= YYEOF)
1744 /* Return failure if at end of input. */
1745 if (yychar == YYEOF)
1750 yydestruct ("Error: discarding",
1756 /* Else will try to reuse lookahead token after shifting the error
1761 /*---------------------------------------------------.
1762 | yyerrorlab -- error raised explicitly by YYERROR. |
1763 `---------------------------------------------------*/
1766 /* Pacify compilers like GCC when the user code never invokes
1767 YYERROR and the label yyerrorlab therefore never appears in user
1769 if (/*CONSTCOND*/ 0)
1772 /* Do not reclaim the symbols of the rule whose action triggered
1776 YY_STACK_PRINT (yyss, yyssp);
1781 /*-------------------------------------------------------------.
1782 | yyerrlab1 -- common code for both syntax error and YYERROR. |
1783 `-------------------------------------------------------------*/
1785 yyerrstatus = 3; /* Each real token shifted decrements this. */
1789 yyn = yypact[yystate];
1790 if (!yypact_value_is_default (yyn))
1793 if (0 <= yyn && yyn <= YYLAST && yycheck[yyn] == YYTERROR)
1801 /* Pop the current state because it cannot handle the error token. */
1806 yydestruct ("Error: popping",
1807 yystos[yystate], yyvsp);
1810 YY_STACK_PRINT (yyss, yyssp);
1813 YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN
1815 YY_IGNORE_MAYBE_UNINITIALIZED_END
1818 /* Shift the error token. */
1819 YY_SYMBOL_PRINT ("Shifting", yystos[yyn], yyvsp, yylsp);
1825 /*-------------------------------------.
1826 | yyacceptlab -- YYACCEPT comes here. |
1827 `-------------------------------------*/
1832 /*-----------------------------------.
1833 | yyabortlab -- YYABORT comes here. |
1834 `-----------------------------------*/
1839 #if !defined yyoverflow || YYERROR_VERBOSE
1840 /*-------------------------------------------------.
1841 | yyexhaustedlab -- memory exhaustion comes here. |
1842 `-------------------------------------------------*/
1844 yyerror (YY_("memory exhausted"));
1850 if (yychar != YYEMPTY)
1852 /* Make sure we have latest lookahead translation. See comments at
1853 user semantic actions for why this is necessary. */
1854 yytoken = YYTRANSLATE (yychar);
1855 yydestruct ("Cleanup: discarding lookahead",
1858 /* Do not reclaim the symbols of the rule whose action triggered
1859 this YYABORT or YYACCEPT. */
1861 YY_STACK_PRINT (yyss, yyssp);
1862 while (yyssp != yyss)
1864 yydestruct ("Cleanup: popping",
1865 yystos[*yyssp], yyvsp);
1870 YYSTACK_FREE (yyss);
1873 if (yymsg != yymsgbuf)
1874 YYSTACK_FREE (yymsg);
1881 /* Called by yyparse on error. */
1882 void yyerror (char const *s)
1884 fprintf (stderr, "yyerror: %s\n", s);
1888 void set_input_string(char* in);
1890 /* This function parses a string */
1891 static int parse_string(unsigned char* in) {
1892 set_input_string ((char *)in);
1896 static unsigned int loadfile (char *file, char *filetype,
1897 unsigned char **parsestring, unsigned int lenstr)
1899 unsigned int lenfile;
1901 if ((fp = fopen(file, "r")) == NULL) {
1902 printf("Error: Could not open %s file: %s\n",filetype,file);
1905 fseek(fp, 0, SEEK_END);
1906 lenfile = ftell(fp);
1907 fseek(fp, 0, SEEK_SET);
1910 *parsestring = (unsigned char *) malloc (lenfile + 2);
1912 *parsestring = (unsigned char *) realloc (*parsestring,
1915 check_pointer(*parsestring);
1916 fread(*parsestring + lenstr, 1, lenfile, fp);
1921 int main (int argc, char *argv[])
1923 unsigned int lenspec;
1924 unsigned char *parsestring;
1926 unsigned int pos = 0;
1932 create_binary_blob();
1933 binary->lenactualblob = 0;
1935 if (argc == 4 && strcmp(argv[1], "-d") != 0) {
1939 lenspec = loadfile(argv[1], "spec", &parsestring, 0);
1940 loadfile(argv[2], "setter", &parsestring, lenspec);
1942 /* Open output and parse string - output to fp */
1943 if ((fp = fopen(argv[3], "wb")) == NULL) {
1944 printf("Error: Could not open output file: %s\n",argv[3]);
1947 ret = parse_string(parsestring);
1949 } else if (argc == 5 && strcmp (argv[1], "-d") == 0) {
1950 /* Decompile mode */
1953 lenspec = loadfile(argv[2], "spec", &parsestring, 0);
1955 parsestring[lenspec] = '%';
1956 parsestring[lenspec + 1] = '\0';
1958 /* Load Actual Binary */
1959 if ((fp = fopen(argv[3], "rb")) == NULL) {
1960 printf("Error: Could not open binary file: %s\n",argv[3]);
1963 fseek(fp, 0, SEEK_END);
1964 binary->lenactualblob = ftell(fp);
1965 fseek(fp, 0, SEEK_SET);
1966 binary->actualblob = (unsigned char *) malloc (binary->lenactualblob);
1967 check_pointer(binary->actualblob);
1968 fread(binary->actualblob, 1, binary->lenactualblob, fp);
1971 /* Open output and parse - output to fp */
1972 if ((fp = fopen(argv[4], "w")) == NULL) {
1973 printf("Error: Could not open output file: %s\n",argv[4]);
1976 ret = parse_string(parsestring);
1978 free(binary->actualblob);
1981 printf("Usage: Compile mode\n\n");
1982 printf(" bincfg spec setter binaryoutput\n");
1983 printf(" (file) (file) (file)\n");
1984 printf(" OR : Decompile mode\n\n");
1985 printf(" bincfg -d spec binary setteroutput\n");