Martin Roth | cfce793 | 2017-04-09 19:05:10 -0600 | [diff] [blame] | 1 | /* A Bison parser, made by GNU Bison 3.0.2. */ |
| 2 | |
| 3 | /* Bison implementation for Yacc-like parsers in C |
| 4 | |
| 5 | Copyright (C) 1984, 1989-1990, 2000-2013 Free Software Foundation, Inc. |
| 6 | |
| 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. |
| 11 | |
| 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. |
| 16 | |
| 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/>. */ |
| 19 | |
| 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. |
| 29 | |
| 30 | This special exception was added by the Free Software Foundation in |
| 31 | version 2.2 of Bison. */ |
| 32 | |
| 33 | /* C LALR(1) parser skeleton written by Richard Stallman, by |
| 34 | simplifying the original so-called "semantic" parser. */ |
| 35 | |
| 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. */ |
| 42 | |
| 43 | /* Identify Bison output. */ |
| 44 | #define YYBISON 1 |
| 45 | |
| 46 | /* Bison version. */ |
| 47 | #define YYBISON_VERSION "3.0.2" |
| 48 | |
| 49 | /* Skeleton name. */ |
| 50 | #define YYSKELETON_NAME "yacc.c" |
| 51 | |
| 52 | /* Pure parsers. */ |
| 53 | #define YYPURE 0 |
| 54 | |
| 55 | /* Push parsers. */ |
| 56 | #define YYPUSH 0 |
| 57 | |
| 58 | /* Pull parsers. */ |
| 59 | #define YYPULL 1 |
| 60 | |
| 61 | |
| 62 | |
| 63 | |
| 64 | /* Copy the first part of user declarations. */ |
| 65 | |
| 66 | |
| 67 | #include <stdio.h> |
| 68 | #include <inttypes.h> |
| 69 | #include <stdlib.h> |
| 70 | #include <string.h> |
| 71 | //#define YYDEBUG 1 |
| 72 | int yylex (void); |
| 73 | void yyerror (char const *); |
| 74 | |
| 75 | struct field { |
| 76 | char *name; |
| 77 | unsigned int width; |
| 78 | unsigned int value; |
| 79 | struct field *next; |
| 80 | }; |
| 81 | |
| 82 | extern struct field *sym_table; |
| 83 | struct field *putsym (char const *, unsigned int); |
| 84 | struct field *getsym (char const *); |
| 85 | |
| 86 | struct field *sym_table; |
| 87 | struct field *sym_table_tail; |
| 88 | |
| 89 | FILE* fp; |
| 90 | |
| 91 | /* Bit array intermediary representation */ |
| 92 | struct blob { |
| 93 | unsigned int bloblen; |
| 94 | unsigned char *blb; |
| 95 | unsigned short checksum; |
| 96 | unsigned char *actualblob; |
| 97 | unsigned int lenactualblob; |
| 98 | }; |
| 99 | |
| 100 | #define VALID_BIT 0x80 |
| 101 | #define MAX_WIDTH 32 |
| 102 | #define CHECKSUM_SIZE 16 |
| 103 | |
| 104 | struct blob *binary; |
| 105 | |
Martin Roth | 6338189 | 2017-04-09 13:30:17 -0600 | [diff] [blame] | 106 | static void check_pointer (void *ptr) |
| 107 | { |
| 108 | if (ptr == NULL) { |
| 109 | printf("Error: Out of memory\n"); |
| 110 | exit(1); |
| 111 | } |
| 112 | } |
| 113 | |
| 114 | static unsigned char* value_to_bits (unsigned int v, unsigned int w) |
Martin Roth | cfce793 | 2017-04-09 19:05:10 -0600 | [diff] [blame] | 115 | { |
| 116 | unsigned int i; |
| 117 | unsigned char* bitarr; |
| 118 | |
| 119 | if (w > MAX_WIDTH) w = MAX_WIDTH; |
| 120 | bitarr = (unsigned char *) malloc (w * sizeof (unsigned char)); |
Martin Roth | 6338189 | 2017-04-09 13:30:17 -0600 | [diff] [blame] | 121 | check_pointer(bitarr); |
Martin Roth | cfce793 | 2017-04-09 19:05:10 -0600 | [diff] [blame] | 122 | memset (bitarr, 0, w); |
| 123 | |
| 124 | for (i = 0; i < w; i++) { |
| 125 | bitarr[i] = VALID_BIT | ((v & (1 << i)) >> i); |
| 126 | } |
| 127 | return bitarr; |
| 128 | } |
| 129 | |
| 130 | /* Store each bit of a bitfield in a new byte sequentially 0x80 or 0x81 */ |
Martin Roth | 6338189 | 2017-04-09 13:30:17 -0600 | [diff] [blame] | 131 | static void append_field_to_blob (unsigned char b[], unsigned int w) |
Martin Roth | cfce793 | 2017-04-09 19:05:10 -0600 | [diff] [blame] | 132 | { |
| 133 | unsigned int i, j; |
| 134 | binary->blb = (unsigned char *) realloc (binary->blb, binary->bloblen + w); |
Martin Roth | 6338189 | 2017-04-09 13:30:17 -0600 | [diff] [blame] | 135 | check_pointer(binary->blb); |
Martin Roth | cfce793 | 2017-04-09 19:05:10 -0600 | [diff] [blame] | 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); |
| 139 | } |
| 140 | binary->bloblen += w; |
| 141 | } |
| 142 | |
Martin Roth | 6338189 | 2017-04-09 13:30:17 -0600 | [diff] [blame] | 143 | static void set_bitfield(char *name, unsigned int value) |
Martin Roth | cfce793 | 2017-04-09 19:05:10 -0600 | [diff] [blame] | 144 | { |
| 145 | unsigned long long i; |
| 146 | struct field *bf = getsym (name); |
| 147 | if (bf) { |
| 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; |
| 153 | } |
| 154 | //fprintf(stderr, "Setting `%s` = %d\n", bf->name, bf->value); |
| 155 | } else { |
| 156 | fprintf(stderr, "Can't find bitfield `%s` in spec\n", name); |
| 157 | } |
| 158 | } |
| 159 | |
Martin Roth | 6338189 | 2017-04-09 13:30:17 -0600 | [diff] [blame] | 160 | static void set_bitfield_array(char *name, unsigned int n, unsigned int value) |
Martin Roth | cfce793 | 2017-04-09 19:05:10 -0600 | [diff] [blame] | 161 | { |
| 162 | unsigned int i; |
Martin Roth | 6338189 | 2017-04-09 13:30:17 -0600 | [diff] [blame] | 163 | unsigned long len = strlen (name); |
Martin Roth | cfce793 | 2017-04-09 19:05:10 -0600 | [diff] [blame] | 164 | char *namen = (char *) malloc ((len + 9) * sizeof (char)); |
Martin Roth | 6338189 | 2017-04-09 13:30:17 -0600 | [diff] [blame] | 165 | check_pointer(namen); |
Martin Roth | cfce793 | 2017-04-09 19:05:10 -0600 | [diff] [blame] | 166 | for (i = 0; i < n; i++) { |
| 167 | snprintf (namen, len + 8, "%s%x", name, i); |
| 168 | set_bitfield (namen, value); |
| 169 | } |
| 170 | free(namen); |
| 171 | } |
| 172 | |
Martin Roth | 6338189 | 2017-04-09 13:30:17 -0600 | [diff] [blame] | 173 | static void create_new_bitfield(char *name, unsigned int width) |
Martin Roth | cfce793 | 2017-04-09 19:05:10 -0600 | [diff] [blame] | 174 | { |
| 175 | struct field *bf; |
| 176 | |
| 177 | if (!(bf = putsym (name, width))) return; |
| 178 | //fprintf(stderr, "Added bitfield `%s` : %d\n", bf->name, width); |
| 179 | } |
| 180 | |
Martin Roth | 6338189 | 2017-04-09 13:30:17 -0600 | [diff] [blame] | 181 | static void create_new_bitfields(char *name, unsigned int n, unsigned int width) |
Martin Roth | cfce793 | 2017-04-09 19:05:10 -0600 | [diff] [blame] | 182 | { |
| 183 | unsigned int i; |
Martin Roth | 6338189 | 2017-04-09 13:30:17 -0600 | [diff] [blame] | 184 | unsigned long len = strlen (name); |
Martin Roth | cfce793 | 2017-04-09 19:05:10 -0600 | [diff] [blame] | 185 | char *namen = (char *) malloc ((len + 9) * sizeof (char)); |
Martin Roth | 6338189 | 2017-04-09 13:30:17 -0600 | [diff] [blame] | 186 | check_pointer(namen); |
Martin Roth | cfce793 | 2017-04-09 19:05:10 -0600 | [diff] [blame] | 187 | for (i = 0; i < n; i++) { |
| 188 | snprintf (namen, len + 8, "%s%x", name, i); |
| 189 | create_new_bitfield (namen, width); |
| 190 | } |
| 191 | free(namen); |
| 192 | } |
| 193 | |
| 194 | struct field *putsym (char const *sym_name, unsigned int w) |
| 195 | { |
| 196 | if (getsym(sym_name)) { |
| 197 | fprintf(stderr, "Cannot add duplicate named bitfield `%s`\n", sym_name); |
| 198 | return 0; |
| 199 | } |
| 200 | struct field *ptr = (struct field *) malloc (sizeof (struct field)); |
Martin Roth | 6338189 | 2017-04-09 13:30:17 -0600 | [diff] [blame] | 201 | check_pointer(ptr); |
Martin Roth | cfce793 | 2017-04-09 19:05:10 -0600 | [diff] [blame] | 202 | ptr->name = (char *) malloc (strlen (sym_name) + 1); |
Martin Roth | 6338189 | 2017-04-09 13:30:17 -0600 | [diff] [blame] | 203 | check_pointer(ptr->name); |
Martin Roth | cfce793 | 2017-04-09 19:05:10 -0600 | [diff] [blame] | 204 | strcpy (ptr->name, sym_name); |
| 205 | ptr->width = w; |
| 206 | ptr->value = 0; |
| 207 | ptr->next = (struct field *)0; |
| 208 | if (sym_table_tail) { |
| 209 | sym_table_tail->next = ptr; |
| 210 | } else { |
| 211 | sym_table = ptr; |
| 212 | } |
| 213 | sym_table_tail = ptr; |
| 214 | return ptr; |
| 215 | } |
| 216 | |
| 217 | struct field *getsym (char const *sym_name) |
| 218 | { |
| 219 | struct field *ptr; |
| 220 | for (ptr = sym_table; ptr != (struct field *) 0; |
| 221 | ptr = (struct field *)ptr->next) { |
| 222 | if (strcmp (ptr->name, sym_name) == 0) |
| 223 | return ptr; |
| 224 | } |
| 225 | return 0; |
| 226 | } |
| 227 | |
Martin Roth | 6338189 | 2017-04-09 13:30:17 -0600 | [diff] [blame] | 228 | static void dump_all_values (void) |
Martin Roth | cfce793 | 2017-04-09 19:05:10 -0600 | [diff] [blame] | 229 | { |
| 230 | struct field *ptr; |
| 231 | for (ptr = sym_table; ptr != (struct field *) 0; |
| 232 | ptr = (struct field *)ptr->next) { |
| 233 | fprintf(stderr, "%s = %d (%d bits)\n", |
| 234 | ptr->name, |
| 235 | ptr->value, |
| 236 | ptr->width); |
| 237 | } |
| 238 | } |
| 239 | |
Martin Roth | 6338189 | 2017-04-09 13:30:17 -0600 | [diff] [blame] | 240 | static void empty_field_table(void) |
Martin Roth | cfce793 | 2017-04-09 19:05:10 -0600 | [diff] [blame] | 241 | { |
| 242 | struct field *ptr; |
| 243 | struct field *ptrnext; |
| 244 | |
| 245 | for (ptr = sym_table; ptr != (struct field *) 0; ptr = ptrnext) { |
| 246 | if (ptr) { |
| 247 | ptrnext = ptr->next; |
| 248 | free(ptr); |
| 249 | } else { |
| 250 | ptrnext = (struct field *) 0; |
| 251 | } |
| 252 | } |
| 253 | sym_table = 0; |
| 254 | sym_table_tail = 0; |
| 255 | } |
| 256 | |
Martin Roth | 6338189 | 2017-04-09 13:30:17 -0600 | [diff] [blame] | 257 | static void create_binary_blob (void) |
Martin Roth | cfce793 | 2017-04-09 19:05:10 -0600 | [diff] [blame] | 258 | { |
| 259 | if (binary && binary->blb) { |
| 260 | free(binary->blb); |
| 261 | free(binary); |
| 262 | } |
| 263 | binary = (struct blob *) malloc (sizeof (struct blob)); |
Martin Roth | 6338189 | 2017-04-09 13:30:17 -0600 | [diff] [blame] | 264 | check_pointer(binary); |
Martin Roth | cfce793 | 2017-04-09 19:05:10 -0600 | [diff] [blame] | 265 | binary->blb = (unsigned char *) malloc (sizeof (unsigned char)); |
Martin Roth | 6338189 | 2017-04-09 13:30:17 -0600 | [diff] [blame] | 266 | check_pointer(binary->blb); |
Martin Roth | cfce793 | 2017-04-09 19:05:10 -0600 | [diff] [blame] | 267 | binary->bloblen = 0; |
| 268 | binary->blb[0] = VALID_BIT; |
| 269 | } |
| 270 | |
Martin Roth | 6338189 | 2017-04-09 13:30:17 -0600 | [diff] [blame] | 271 | static void interpret_next_blob_value (struct field *f) |
Martin Roth | cfce793 | 2017-04-09 19:05:10 -0600 | [diff] [blame] | 272 | { |
Martin Roth | 6338189 | 2017-04-09 13:30:17 -0600 | [diff] [blame] | 273 | unsigned int i; |
Martin Roth | cfce793 | 2017-04-09 19:05:10 -0600 | [diff] [blame] | 274 | unsigned int v = 0; |
| 275 | |
| 276 | if (binary->bloblen >= binary->lenactualblob * 8) { |
| 277 | f->value = 0; |
| 278 | return; |
| 279 | } |
| 280 | |
| 281 | for (i = 0; i < f->width; i++) { |
| 282 | v |= (binary->blb[binary->bloblen++] & 1) << i; |
| 283 | } |
| 284 | |
| 285 | f->value = v; |
| 286 | } |
| 287 | |
| 288 | /* {}%BIN -> {} */ |
Martin Roth | 6338189 | 2017-04-09 13:30:17 -0600 | [diff] [blame] | 289 | static void generate_setter_bitfields(unsigned char *bin) |
Martin Roth | cfce793 | 2017-04-09 19:05:10 -0600 | [diff] [blame] | 290 | { |
| 291 | unsigned int i; |
| 292 | struct field *ptr; |
| 293 | |
| 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); |
| 297 | } |
| 298 | |
| 299 | /* Reset blob position to zero */ |
| 300 | binary->bloblen = 0; |
| 301 | |
Denis 'GNUtoo' Carikli | 780e931 | 2018-01-10 14:35:55 +0100 | [diff] [blame] | 302 | fprintf (fp, "# AUTOGENERATED SETTER BY BINCFG\n{\n"); |
Martin Roth | cfce793 | 2017-04-09 19:05:10 -0600 | [diff] [blame] | 303 | |
| 304 | /* Traverse spec and output bitfield setters based on blob values */ |
| 305 | for (ptr = sym_table; ptr != (struct field *) 0; ptr = ptr->next) { |
| 306 | |
| 307 | interpret_next_blob_value(ptr); |
| 308 | fprintf (fp, "\t\"%s\" = 0x%x,\n", ptr->name, ptr->value); |
| 309 | } |
| 310 | fseek(fp, -2, SEEK_CUR); |
| 311 | fprintf (fp, "\n}\n"); |
| 312 | } |
| 313 | |
Martin Roth | 6338189 | 2017-04-09 13:30:17 -0600 | [diff] [blame] | 314 | static void generate_binary_with_gbe_checksum(void) |
Martin Roth | cfce793 | 2017-04-09 19:05:10 -0600 | [diff] [blame] | 315 | { |
| 316 | int i; |
| 317 | unsigned short checksum; |
| 318 | |
| 319 | /* traverse spec, push to blob and add up for checksum */ |
| 320 | struct field *ptr; |
| 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 */ |
| 325 | ptr = ptr->next; |
| 326 | break; |
| 327 | } |
| 328 | append_field_to_blob ( |
| 329 | value_to_bits(ptr->value, ptr->width), |
| 330 | ptr->width); |
| 331 | uptochksum += ptr->width; |
| 332 | } |
| 333 | |
| 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) |
| 344 | ); |
| 345 | fprintf(fp, "%c", byte); |
| 346 | |
| 347 | /* incremental 16 bit checksum */ |
| 348 | if ((i % 16) < 8) { |
| 349 | binary->checksum += byte; |
| 350 | } else { |
| 351 | binary->checksum += byte << 8; |
| 352 | } |
| 353 | } |
| 354 | |
| 355 | checksum = (0xbaba - binary->checksum) & 0xffff; |
| 356 | |
| 357 | /* Now write checksum */ |
| 358 | set_bitfield ("checksum_gbe", checksum); |
| 359 | |
| 360 | fprintf(fp, "%c", checksum & 0xff); |
| 361 | fprintf(fp, "%c", (checksum & 0xff00) >> 8); |
| 362 | |
| 363 | append_field_to_blob (value_to_bits(checksum, 16), 16); |
| 364 | |
| 365 | for (; ptr != (struct field *) 0; ptr = ptr->next) { |
| 366 | append_field_to_blob ( |
| 367 | value_to_bits(ptr->value, ptr->width), ptr->width); |
| 368 | } |
| 369 | |
| 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) |
| 380 | ); |
| 381 | fprintf(fp, "%c", byte); |
| 382 | } |
| 383 | } |
| 384 | |
| 385 | /* {}{} -> BIN */ |
Martin Roth | 6338189 | 2017-04-09 13:30:17 -0600 | [diff] [blame] | 386 | static void generate_binary(void) |
Martin Roth | cfce793 | 2017-04-09 19:05:10 -0600 | [diff] [blame] | 387 | { |
| 388 | unsigned int i; |
| 389 | struct field *ptr; |
| 390 | |
| 391 | if (binary->bloblen % 8) { |
| 392 | fprintf (stderr, "ERROR: Spec must be multiple of 8 bits wide\n"); |
| 393 | exit (1); |
| 394 | } |
| 395 | |
| 396 | if (getsym ("checksum_gbe")) { |
| 397 | generate_binary_with_gbe_checksum(); |
| 398 | return; |
| 399 | } |
| 400 | |
| 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), |
| 405 | ptr->width); |
| 406 | } |
| 407 | |
| 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) |
| 418 | ); |
| 419 | fprintf(fp, "%c", byte); |
| 420 | } |
| 421 | } |
| 422 | |
| 423 | |
| 424 | |
| 425 | |
| 426 | # ifndef YY_NULLPTR |
| 427 | # if defined __cplusplus && 201103L <= __cplusplus |
| 428 | # define YY_NULLPTR nullptr |
| 429 | # else |
| 430 | # define YY_NULLPTR 0 |
| 431 | # endif |
| 432 | # endif |
| 433 | |
| 434 | /* Enabling verbose error messages. */ |
| 435 | #ifdef YYERROR_VERBOSE |
| 436 | # undef YYERROR_VERBOSE |
| 437 | # define YYERROR_VERBOSE 1 |
| 438 | #else |
| 439 | # define YYERROR_VERBOSE 0 |
| 440 | #endif |
| 441 | |
| 442 | /* In a future release of Bison, this section will be replaced |
Denis 'GNUtoo' Carikli | 780e931 | 2018-01-10 14:35:55 +0100 | [diff] [blame] | 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 |
Martin Roth | cfce793 | 2017-04-09 19:05:10 -0600 | [diff] [blame] | 446 | /* Debug traces. */ |
| 447 | #ifndef YYDEBUG |
| 448 | # define YYDEBUG 0 |
| 449 | #endif |
| 450 | #if YYDEBUG |
| 451 | extern int yydebug; |
| 452 | #endif |
| 453 | |
| 454 | /* Token type. */ |
| 455 | #ifndef YYTOKENTYPE |
| 456 | # define YYTOKENTYPE |
| 457 | enum yytokentype |
| 458 | { |
| 459 | name = 258, |
| 460 | val = 259, |
| 461 | vals = 260, |
| 462 | hexbyte = 261, |
| 463 | binblob = 262, |
| 464 | eof = 263 |
| 465 | }; |
| 466 | #endif |
| 467 | |
| 468 | /* Value type. */ |
| 469 | #if ! defined YYSTYPE && ! defined YYSTYPE_IS_DECLARED |
| 470 | typedef union YYSTYPE YYSTYPE; |
| 471 | union YYSTYPE |
| 472 | { |
| 473 | |
| 474 | |
| 475 | char *str; |
| 476 | unsigned int u32; |
| 477 | unsigned int *u32array; |
| 478 | unsigned char u8; |
| 479 | unsigned char *u8array; |
| 480 | |
| 481 | |
| 482 | }; |
| 483 | # define YYSTYPE_IS_TRIVIAL 1 |
| 484 | # define YYSTYPE_IS_DECLARED 1 |
| 485 | #endif |
| 486 | |
| 487 | |
| 488 | extern YYSTYPE yylval; |
| 489 | |
| 490 | int yyparse (void); |
| 491 | |
Denis 'GNUtoo' Carikli | 780e931 | 2018-01-10 14:35:55 +0100 | [diff] [blame] | 492 | #endif /* !YY_YY_COREBOOT_UTIL_BINCFG_BINCFG_TAB_H_SHIPPED_INCLUDED */ |
Martin Roth | cfce793 | 2017-04-09 19:05:10 -0600 | [diff] [blame] | 493 | |
| 494 | /* Copy the second part of user declarations. */ |
| 495 | |
| 496 | |
| 497 | |
| 498 | #ifdef short |
| 499 | # undef short |
| 500 | #endif |
| 501 | |
| 502 | #ifdef YYTYPE_UINT8 |
| 503 | typedef YYTYPE_UINT8 yytype_uint8; |
| 504 | #else |
| 505 | typedef unsigned char yytype_uint8; |
| 506 | #endif |
| 507 | |
| 508 | #ifdef YYTYPE_INT8 |
| 509 | typedef YYTYPE_INT8 yytype_int8; |
| 510 | #else |
| 511 | typedef signed char yytype_int8; |
| 512 | #endif |
| 513 | |
| 514 | #ifdef YYTYPE_UINT16 |
| 515 | typedef YYTYPE_UINT16 yytype_uint16; |
| 516 | #else |
| 517 | typedef unsigned short int yytype_uint16; |
| 518 | #endif |
| 519 | |
| 520 | #ifdef YYTYPE_INT16 |
| 521 | typedef YYTYPE_INT16 yytype_int16; |
| 522 | #else |
| 523 | typedef short int yytype_int16; |
| 524 | #endif |
| 525 | |
| 526 | #ifndef YYSIZE_T |
| 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 |
| 534 | # else |
| 535 | # define YYSIZE_T unsigned int |
| 536 | # endif |
| 537 | #endif |
| 538 | |
| 539 | #define YYSIZE_MAXIMUM ((YYSIZE_T) -1) |
| 540 | |
| 541 | #ifndef YY_ |
| 542 | # if defined YYENABLE_NLS && YYENABLE_NLS |
| 543 | # if ENABLE_NLS |
| 544 | # include <libintl.h> /* INFRINGES ON USER NAME SPACE */ |
| 545 | # define YY_(Msgid) dgettext ("bison-runtime", Msgid) |
| 546 | # endif |
| 547 | # endif |
| 548 | # ifndef YY_ |
| 549 | # define YY_(Msgid) Msgid |
| 550 | # endif |
| 551 | #endif |
| 552 | |
| 553 | #ifndef YY_ATTRIBUTE |
| 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) |
| 558 | # else |
| 559 | # define YY_ATTRIBUTE(Spec) /* empty */ |
| 560 | # endif |
| 561 | #endif |
| 562 | |
| 563 | #ifndef YY_ATTRIBUTE_PURE |
| 564 | # define YY_ATTRIBUTE_PURE YY_ATTRIBUTE ((__pure__)) |
| 565 | #endif |
| 566 | |
| 567 | #ifndef YY_ATTRIBUTE_UNUSED |
| 568 | # define YY_ATTRIBUTE_UNUSED YY_ATTRIBUTE ((__unused__)) |
| 569 | #endif |
| 570 | |
| 571 | #if !defined _Noreturn \ |
| 572 | && (!defined __STDC_VERSION__ || __STDC_VERSION__ < 201112) |
| 573 | # if defined _MSC_VER && 1200 <= _MSC_VER |
| 574 | # define _Noreturn __declspec (noreturn) |
| 575 | # else |
| 576 | # define _Noreturn YY_ATTRIBUTE ((__noreturn__)) |
| 577 | # endif |
| 578 | #endif |
| 579 | |
| 580 | /* Suppress unused-variable warnings by "using" E. */ |
| 581 | #if ! defined lint || defined __GNUC__ |
| 582 | # define YYUSE(E) ((void) (E)) |
| 583 | #else |
| 584 | # define YYUSE(E) /* empty */ |
| 585 | #endif |
| 586 | |
| 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") |
| 595 | #else |
| 596 | # define YY_INITIAL_VALUE(Value) Value |
| 597 | #endif |
| 598 | #ifndef YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN |
| 599 | # define YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN |
| 600 | # define YY_IGNORE_MAYBE_UNINITIALIZED_END |
| 601 | #endif |
| 602 | #ifndef YY_INITIAL_VALUE |
| 603 | # define YY_INITIAL_VALUE(Value) /* Nothing. */ |
| 604 | #endif |
| 605 | |
| 606 | |
| 607 | #if ! defined yyoverflow || YYERROR_VERBOSE |
| 608 | |
| 609 | /* The parser invokes alloca or malloc; define the necessary symbols. */ |
| 610 | |
| 611 | # ifdef YYSTACK_USE_ALLOCA |
| 612 | # if YYSTACK_USE_ALLOCA |
| 613 | # ifdef __GNUC__ |
| 614 | # define YYSTACK_ALLOC __builtin_alloca |
| 615 | # elif defined __BUILTIN_VA_ARG_INCR |
| 616 | # include <alloca.h> /* INFRINGES ON USER NAME SPACE */ |
| 617 | # elif defined _AIX |
| 618 | # define YYSTACK_ALLOC __alloca |
| 619 | # elif defined _MSC_VER |
| 620 | # include <malloc.h> /* INFRINGES ON USER NAME SPACE */ |
| 621 | # define alloca _alloca |
| 622 | # else |
| 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 |
| 629 | # endif |
| 630 | # endif |
| 631 | # endif |
| 632 | # endif |
| 633 | # endif |
| 634 | |
| 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 */ |
| 644 | # endif |
| 645 | # else |
| 646 | # define YYSTACK_ALLOC YYMALLOC |
| 647 | # define YYSTACK_FREE YYFREE |
| 648 | # ifndef YYSTACK_ALLOC_MAXIMUM |
| 649 | # define YYSTACK_ALLOC_MAXIMUM YYSIZE_MAXIMUM |
| 650 | # endif |
| 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 |
| 657 | # endif |
| 658 | # endif |
| 659 | # ifndef YYMALLOC |
| 660 | # define YYMALLOC malloc |
| 661 | # if ! defined malloc && ! defined EXIT_SUCCESS |
| 662 | void *malloc (YYSIZE_T); /* INFRINGES ON USER NAME SPACE */ |
| 663 | # endif |
| 664 | # endif |
| 665 | # ifndef YYFREE |
| 666 | # define YYFREE free |
| 667 | # if ! defined free && ! defined EXIT_SUCCESS |
| 668 | void free (void *); /* INFRINGES ON USER NAME SPACE */ |
| 669 | # endif |
| 670 | # endif |
| 671 | # endif |
| 672 | #endif /* ! defined yyoverflow || YYERROR_VERBOSE */ |
| 673 | |
| 674 | |
| 675 | #if (! defined yyoverflow \ |
| 676 | && (! defined __cplusplus \ |
| 677 | || (defined YYSTYPE_IS_TRIVIAL && YYSTYPE_IS_TRIVIAL))) |
| 678 | |
| 679 | /* A type that is properly aligned for any stack member. */ |
| 680 | union yyalloc |
| 681 | { |
| 682 | yytype_int16 yyss_alloc; |
| 683 | YYSTYPE yyvs_alloc; |
| 684 | }; |
| 685 | |
| 686 | /* The size of the maximum gap between one aligned stack and the next. */ |
| 687 | # define YYSTACK_GAP_MAXIMUM (sizeof (union yyalloc) - 1) |
| 688 | |
| 689 | /* The size of an array large to enough to hold all stacks, each with |
| 690 | N elements. */ |
| 691 | # define YYSTACK_BYTES(N) \ |
| 692 | ((N) * (sizeof (yytype_int16) + sizeof (YYSTYPE)) \ |
| 693 | + YYSTACK_GAP_MAXIMUM) |
| 694 | |
| 695 | # define YYCOPY_NEEDED 1 |
| 696 | |
| 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 |
| 701 | stack. */ |
| 702 | # define YYSTACK_RELOCATE(Stack_alloc, Stack) \ |
| 703 | do \ |
| 704 | { \ |
| 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); \ |
| 710 | } \ |
| 711 | while (0) |
| 712 | |
| 713 | #endif |
| 714 | |
| 715 | #if defined YYCOPY_NEEDED && YYCOPY_NEEDED |
| 716 | /* Copy COUNT objects from SRC to DST. The source and destination do |
| 717 | not overlap. */ |
| 718 | # ifndef YYCOPY |
| 719 | # if defined __GNUC__ && 1 < __GNUC__ |
| 720 | # define YYCOPY(Dst, Src, Count) \ |
| 721 | __builtin_memcpy (Dst, Src, (Count) * sizeof (*(Src))) |
| 722 | # else |
| 723 | # define YYCOPY(Dst, Src, Count) \ |
| 724 | do \ |
| 725 | { \ |
| 726 | YYSIZE_T yyi; \ |
| 727 | for (yyi = 0; yyi < (Count); yyi++) \ |
| 728 | (Dst)[yyi] = (Src)[yyi]; \ |
| 729 | } \ |
| 730 | while (0) |
| 731 | # endif |
| 732 | # endif |
| 733 | #endif /* !YYCOPY_NEEDED */ |
| 734 | |
| 735 | /* YYFINAL -- State number of the termination state. */ |
| 736 | #define YYFINAL 2 |
| 737 | /* YYLAST -- Last index in YYTABLE. */ |
| 738 | #define YYLAST 32 |
| 739 | |
| 740 | /* YYNTOKENS -- Number of terminals. */ |
| 741 | #define YYNTOKENS 17 |
| 742 | /* YYNNTS -- Number of nonterminals. */ |
| 743 | #define YYNNTS 9 |
| 744 | /* YYNRULES -- Number of rules. */ |
| 745 | #define YYNRULES 17 |
| 746 | /* YYNSTATES -- Number of states. */ |
| 747 | #define YYNSTATES 39 |
| 748 | |
| 749 | /* YYTRANSLATE[YYX] -- Symbol number corresponding to YYX as returned |
| 750 | by yylex, with out-of-bounds checking. */ |
| 751 | #define YYUNDEFTOK 2 |
| 752 | #define YYMAXUTOK 263 |
| 753 | |
| 754 | #define YYTRANSLATE(YYX) \ |
| 755 | ((unsigned int) (YYX) <= YYMAXUTOK ? yytranslate[YYX] : YYUNDEFTOK) |
| 756 | |
| 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[] = |
| 760 | { |
| 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, |
| 787 | 5, 6, 7, 8 |
| 788 | }; |
| 789 | |
| 790 | #if YYDEBUG |
| 791 | /* YYRLINE[YYN] -- Source line where rule number YYN was defined. */ |
| 792 | static const yytype_uint16 yyrline[] = |
| 793 | { |
Martin Roth | 6338189 | 2017-04-09 13:30:17 -0600 | [diff] [blame] | 794 | 0, 399, 399, 401, 402, 407, 411, 412, 417, 418, |
| 795 | 422, 423, 427, 428, 433, 434, 438, 439 |
Martin Roth | cfce793 | 2017-04-09 19:05:10 -0600 | [diff] [blame] | 796 | }; |
| 797 | #endif |
| 798 | |
| 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[] = |
| 803 | { |
| 804 | "$end", "error", "$undefined", "name", "val", "vals", "hexbyte", |
| 805 | "binblob", "eof", "'%'", "'{'", "'}'", "','", "':'", "'='", "'['", "']'", |
| 806 | "$accept", "input", "blob", "spec", "specmembers", "specpair", "setter", |
| 807 | "valuemembers", "setpair", YY_NULLPTR |
| 808 | }; |
| 809 | #endif |
| 810 | |
| 811 | # ifdef YYPRINT |
| 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[] = |
| 815 | { |
| 816 | 0, 256, 257, 258, 259, 260, 261, 262, 263, 37, |
| 817 | 123, 125, 44, 58, 61, 91, 93 |
| 818 | }; |
| 819 | # endif |
| 820 | |
| 821 | #define YYPACT_NINF -11 |
| 822 | |
| 823 | #define yypact_value_is_default(Yystate) \ |
| 824 | (!!((Yystate) == (-11))) |
| 825 | |
| 826 | #define YYTABLE_NINF -1 |
| 827 | |
| 828 | #define yytable_value_is_error(Yytable_value) \ |
| 829 | 0 |
| 830 | |
| 831 | /* YYPACT[STATE-NUM] -- Index in YYTABLE of the portion describing |
| 832 | STATE-NUM. */ |
| 833 | static const yytype_int8 yypact[] = |
| 834 | { |
| 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 |
| 839 | }; |
| 840 | |
| 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[] = |
| 845 | { |
| 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 |
| 850 | }; |
| 851 | |
| 852 | /* YYPGOTO[NTERM-NUM]. */ |
| 853 | static const yytype_int8 yypgoto[] = |
| 854 | { |
| 855 | -11, -11, -11, -11, 16, -11, -11, 2, -11 |
| 856 | }; |
| 857 | |
| 858 | /* YYDEFGOTO[NTERM-NUM]. */ |
| 859 | static const yytype_int8 yydefgoto[] = |
| 860 | { |
| 861 | -1, 1, 11, 4, 7, 8, 12, 20, 21 |
| 862 | }; |
| 863 | |
| 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[] = |
| 868 | { |
| 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, |
| 872 | 0, 33, 25 |
| 873 | }; |
| 874 | |
| 875 | static const yytype_int8 yycheck[] = |
| 876 | { |
| 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, |
| 880 | -1, 29, 16 |
| 881 | }; |
| 882 | |
| 883 | /* YYSTOS[STATE-NUM] -- The (internal number of the) accessing |
| 884 | symbol of state STATE-NUM. */ |
| 885 | static const yytype_uint8 yystos[] = |
| 886 | { |
| 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 |
| 891 | }; |
| 892 | |
| 893 | /* YYR1[YYN] -- Symbol number of symbol that rule YYN derives. */ |
| 894 | static const yytype_uint8 yyr1[] = |
| 895 | { |
| 896 | 0, 17, 18, 18, 18, 19, 20, 20, 21, 21, |
| 897 | 22, 22, 23, 23, 24, 24, 25, 25 |
| 898 | }; |
| 899 | |
| 900 | /* YYR2[YYN] -- Number of symbols on the right hand side of rule YYN. */ |
| 901 | static const yytype_uint8 yyr2[] = |
| 902 | { |
| 903 | 0, 2, 0, 4, 3, 2, 2, 3, 1, 3, |
| 904 | 3, 6, 2, 3, 1, 3, 3, 6 |
| 905 | }; |
| 906 | |
| 907 | |
| 908 | #define yyerrok (yyerrstatus = 0) |
| 909 | #define yyclearin (yychar = YYEMPTY) |
| 910 | #define YYEMPTY (-2) |
| 911 | #define YYEOF 0 |
| 912 | |
| 913 | #define YYACCEPT goto yyacceptlab |
| 914 | #define YYABORT goto yyabortlab |
| 915 | #define YYERROR goto yyerrorlab |
| 916 | |
| 917 | |
| 918 | #define YYRECOVERING() (!!yyerrstatus) |
| 919 | |
| 920 | #define YYBACKUP(Token, Value) \ |
| 921 | do \ |
| 922 | if (yychar == YYEMPTY) \ |
| 923 | { \ |
| 924 | yychar = (Token); \ |
| 925 | yylval = (Value); \ |
| 926 | YYPOPSTACK (yylen); \ |
| 927 | yystate = *yyssp; \ |
| 928 | goto yybackup; \ |
| 929 | } \ |
| 930 | else \ |
| 931 | { \ |
| 932 | yyerror (YY_("syntax error: cannot back up")); \ |
| 933 | YYERROR; \ |
| 934 | } \ |
| 935 | while (0) |
| 936 | |
| 937 | /* Error token number */ |
| 938 | #define YYTERROR 1 |
| 939 | #define YYERRCODE 256 |
| 940 | |
| 941 | |
| 942 | |
| 943 | /* Enable debugging if requested. */ |
| 944 | #if YYDEBUG |
| 945 | |
| 946 | # ifndef YYFPRINTF |
| 947 | # include <stdio.h> /* INFRINGES ON USER NAME SPACE */ |
| 948 | # define YYFPRINTF fprintf |
| 949 | # endif |
| 950 | |
| 951 | # define YYDPRINTF(Args) \ |
| 952 | do { \ |
| 953 | if (yydebug) \ |
| 954 | YYFPRINTF Args; \ |
| 955 | } while (0) |
| 956 | |
| 957 | /* This macro is provided for backward compatibility. */ |
| 958 | #ifndef YY_LOCATION_PRINT |
| 959 | # define YY_LOCATION_PRINT(File, Loc) ((void) 0) |
| 960 | #endif |
| 961 | |
| 962 | |
| 963 | # define YY_SYMBOL_PRINT(Title, Type, Value, Location) \ |
| 964 | do { \ |
| 965 | if (yydebug) \ |
| 966 | { \ |
| 967 | YYFPRINTF (stderr, "%s ", Title); \ |
| 968 | yy_symbol_print (stderr, \ |
| 969 | Type, Value); \ |
| 970 | YYFPRINTF (stderr, "\n"); \ |
| 971 | } \ |
| 972 | } while (0) |
| 973 | |
| 974 | |
| 975 | /*----------------------------------------. |
| 976 | | Print this symbol's value on YYOUTPUT. | |
| 977 | `----------------------------------------*/ |
| 978 | |
| 979 | static void |
| 980 | yy_symbol_value_print (FILE *yyoutput, int yytype, YYSTYPE const * const yyvaluep) |
| 981 | { |
| 982 | FILE *yyo = yyoutput; |
| 983 | YYUSE (yyo); |
| 984 | if (!yyvaluep) |
| 985 | return; |
| 986 | # ifdef YYPRINT |
| 987 | if (yytype < YYNTOKENS) |
| 988 | YYPRINT (yyoutput, yytoknum[yytype], *yyvaluep); |
| 989 | # endif |
| 990 | YYUSE (yytype); |
| 991 | } |
| 992 | |
| 993 | |
| 994 | /*--------------------------------. |
| 995 | | Print this symbol on YYOUTPUT. | |
| 996 | `--------------------------------*/ |
| 997 | |
| 998 | static void |
| 999 | yy_symbol_print (FILE *yyoutput, int yytype, YYSTYPE const * const yyvaluep) |
| 1000 | { |
| 1001 | YYFPRINTF (yyoutput, "%s %s (", |
| 1002 | yytype < YYNTOKENS ? "token" : "nterm", yytname[yytype]); |
| 1003 | |
| 1004 | yy_symbol_value_print (yyoutput, yytype, yyvaluep); |
| 1005 | YYFPRINTF (yyoutput, ")"); |
| 1006 | } |
| 1007 | |
| 1008 | /*------------------------------------------------------------------. |
| 1009 | | yy_stack_print -- Print the state stack from its BOTTOM up to its | |
| 1010 | | TOP (included). | |
| 1011 | `------------------------------------------------------------------*/ |
| 1012 | |
| 1013 | static void |
| 1014 | yy_stack_print (yytype_int16 *yybottom, yytype_int16 *yytop) |
| 1015 | { |
| 1016 | YYFPRINTF (stderr, "Stack now"); |
| 1017 | for (; yybottom <= yytop; yybottom++) |
| 1018 | { |
| 1019 | int yybot = *yybottom; |
| 1020 | YYFPRINTF (stderr, " %d", yybot); |
| 1021 | } |
| 1022 | YYFPRINTF (stderr, "\n"); |
| 1023 | } |
| 1024 | |
| 1025 | # define YY_STACK_PRINT(Bottom, Top) \ |
| 1026 | do { \ |
| 1027 | if (yydebug) \ |
| 1028 | yy_stack_print ((Bottom), (Top)); \ |
| 1029 | } while (0) |
| 1030 | |
| 1031 | |
| 1032 | /*------------------------------------------------. |
| 1033 | | Report that the YYRULE is going to be reduced. | |
| 1034 | `------------------------------------------------*/ |
| 1035 | |
| 1036 | static void |
| 1037 | yy_reduce_print (yytype_int16 *yyssp, YYSTYPE *yyvsp, int yyrule) |
| 1038 | { |
| 1039 | unsigned long int yylno = yyrline[yyrule]; |
| 1040 | int yynrhs = yyr2[yyrule]; |
| 1041 | int yyi; |
| 1042 | YYFPRINTF (stderr, "Reducing stack by rule %d (line %lu):\n", |
| 1043 | yyrule - 1, yylno); |
| 1044 | /* The symbols being reduced. */ |
| 1045 | for (yyi = 0; yyi < yynrhs; yyi++) |
| 1046 | { |
| 1047 | YYFPRINTF (stderr, " $%d = ", yyi + 1); |
| 1048 | yy_symbol_print (stderr, |
| 1049 | yystos[yyssp[yyi + 1 - yynrhs]], |
| 1050 | &(yyvsp[(yyi + 1) - (yynrhs)]) |
| 1051 | ); |
| 1052 | YYFPRINTF (stderr, "\n"); |
| 1053 | } |
| 1054 | } |
| 1055 | |
| 1056 | # define YY_REDUCE_PRINT(Rule) \ |
| 1057 | do { \ |
| 1058 | if (yydebug) \ |
| 1059 | yy_reduce_print (yyssp, yyvsp, Rule); \ |
| 1060 | } while (0) |
| 1061 | |
| 1062 | /* Nonzero means print parse trace. It is left uninitialized so that |
| 1063 | multiple parsers can coexist. */ |
| 1064 | int yydebug; |
| 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 */ |
| 1071 | |
| 1072 | |
| 1073 | /* YYINITDEPTH -- initial size of the parser's stacks. */ |
| 1074 | #ifndef YYINITDEPTH |
| 1075 | # define YYINITDEPTH 200 |
| 1076 | #endif |
| 1077 | |
| 1078 | /* YYMAXDEPTH -- maximum size the stacks can grow to (effective only |
| 1079 | if the built-in stack extension method is used). |
| 1080 | |
| 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. */ |
| 1084 | |
| 1085 | #ifndef YYMAXDEPTH |
| 1086 | # define YYMAXDEPTH 10000 |
| 1087 | #endif |
| 1088 | |
| 1089 | |
| 1090 | #if YYERROR_VERBOSE |
| 1091 | |
| 1092 | # ifndef yystrlen |
| 1093 | # if defined __GLIBC__ && defined _STRING_H |
| 1094 | # define yystrlen strlen |
| 1095 | # else |
| 1096 | /* Return the length of YYSTR. */ |
| 1097 | static YYSIZE_T |
| 1098 | yystrlen (const char *yystr) |
| 1099 | { |
| 1100 | YYSIZE_T yylen; |
| 1101 | for (yylen = 0; yystr[yylen]; yylen++) |
| 1102 | continue; |
| 1103 | return yylen; |
| 1104 | } |
| 1105 | # endif |
| 1106 | # endif |
| 1107 | |
| 1108 | # ifndef yystpcpy |
| 1109 | # if defined __GLIBC__ && defined _STRING_H && defined _GNU_SOURCE |
| 1110 | # define yystpcpy stpcpy |
| 1111 | # else |
| 1112 | /* Copy YYSRC to YYDEST, returning the address of the terminating '\0' in |
| 1113 | YYDEST. */ |
| 1114 | static char * |
| 1115 | yystpcpy (char *yydest, const char *yysrc) |
| 1116 | { |
| 1117 | char *yyd = yydest; |
| 1118 | const char *yys = yysrc; |
| 1119 | |
| 1120 | while ((*yyd++ = *yys++) != '\0') |
| 1121 | continue; |
| 1122 | |
| 1123 | return yyd - 1; |
| 1124 | } |
| 1125 | # endif |
| 1126 | # endif |
| 1127 | |
| 1128 | # ifndef yytnamerr |
| 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 |
| 1135 | would have been. */ |
| 1136 | static YYSIZE_T |
| 1137 | yytnamerr (char *yyres, const char *yystr) |
| 1138 | { |
| 1139 | if (*yystr == '"') |
| 1140 | { |
| 1141 | YYSIZE_T yyn = 0; |
| 1142 | char const *yyp = yystr; |
| 1143 | |
| 1144 | for (;;) |
| 1145 | switch (*++yyp) |
| 1146 | { |
| 1147 | case '\'': |
| 1148 | case ',': |
| 1149 | goto do_not_strip_quotes; |
| 1150 | |
| 1151 | case '\\': |
| 1152 | if (*++yyp != '\\') |
| 1153 | goto do_not_strip_quotes; |
| 1154 | /* Fall through. */ |
| 1155 | default: |
| 1156 | if (yyres) |
| 1157 | yyres[yyn] = *yyp; |
| 1158 | yyn++; |
| 1159 | break; |
| 1160 | |
| 1161 | case '"': |
| 1162 | if (yyres) |
| 1163 | yyres[yyn] = '\0'; |
| 1164 | return yyn; |
| 1165 | } |
| 1166 | do_not_strip_quotes: ; |
| 1167 | } |
| 1168 | |
| 1169 | if (! yyres) |
| 1170 | return yystrlen (yystr); |
| 1171 | |
| 1172 | return yystpcpy (yyres, yystr) - yyres; |
| 1173 | } |
| 1174 | # endif |
| 1175 | |
| 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 |
| 1178 | YYSSP. |
| 1179 | |
| 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. */ |
| 1184 | static int |
| 1185 | yysyntax_error (YYSIZE_T *yymsg_alloc, char **yymsg, |
| 1186 | yytype_int16 *yyssp, int yytoken) |
| 1187 | { |
| 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 |
| 1196 | "expected"). */ |
| 1197 | int yycount = 0; |
| 1198 | |
| 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. |
| 1221 | */ |
| 1222 | if (yytoken != YYEMPTY) |
| 1223 | { |
| 1224 | int yyn = yypact[*yyssp]; |
| 1225 | yyarg[yycount++] = yytname[yytoken]; |
| 1226 | if (!yypact_value_is_default (yyn)) |
| 1227 | { |
| 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; |
| 1235 | int yyx; |
| 1236 | |
| 1237 | for (yyx = yyxbegin; yyx < yyxend; ++yyx) |
| 1238 | if (yycheck[yyx + yyn] == yyx && yyx != YYTERROR |
| 1239 | && !yytable_value_is_error (yytable[yyx + yyn])) |
| 1240 | { |
| 1241 | if (yycount == YYERROR_VERBOSE_ARGS_MAXIMUM) |
| 1242 | { |
| 1243 | yycount = 1; |
| 1244 | yysize = yysize0; |
| 1245 | break; |
| 1246 | } |
| 1247 | yyarg[yycount++] = yytname[yyx]; |
| 1248 | { |
| 1249 | YYSIZE_T yysize1 = yysize + yytnamerr (YY_NULLPTR, yytname[yyx]); |
| 1250 | if (! (yysize <= yysize1 |
| 1251 | && yysize1 <= YYSTACK_ALLOC_MAXIMUM)) |
| 1252 | return 2; |
| 1253 | yysize = yysize1; |
| 1254 | } |
| 1255 | } |
| 1256 | } |
| 1257 | } |
| 1258 | |
| 1259 | switch (yycount) |
| 1260 | { |
| 1261 | # define YYCASE_(N, S) \ |
| 1262 | case N: \ |
| 1263 | yyformat = S; \ |
| 1264 | break |
| 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")); |
| 1271 | # undef YYCASE_ |
| 1272 | } |
| 1273 | |
| 1274 | { |
| 1275 | YYSIZE_T yysize1 = yysize + yystrlen (yyformat); |
| 1276 | if (! (yysize <= yysize1 && yysize1 <= YYSTACK_ALLOC_MAXIMUM)) |
| 1277 | return 2; |
| 1278 | yysize = yysize1; |
| 1279 | } |
| 1280 | |
| 1281 | if (*yymsg_alloc < yysize) |
| 1282 | { |
| 1283 | *yymsg_alloc = 2 * yysize; |
| 1284 | if (! (yysize <= *yymsg_alloc |
| 1285 | && *yymsg_alloc <= YYSTACK_ALLOC_MAXIMUM)) |
| 1286 | *yymsg_alloc = YYSTACK_ALLOC_MAXIMUM; |
| 1287 | return 1; |
| 1288 | } |
| 1289 | |
| 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. */ |
| 1293 | { |
| 1294 | char *yyp = *yymsg; |
| 1295 | int yyi = 0; |
| 1296 | while ((*yyp = *yyformat) != '\0') |
| 1297 | if (*yyp == '%' && yyformat[1] == 's' && yyi < yycount) |
| 1298 | { |
| 1299 | yyp += yytnamerr (yyp, yyarg[yyi++]); |
| 1300 | yyformat += 2; |
| 1301 | } |
| 1302 | else |
| 1303 | { |
| 1304 | yyp++; |
| 1305 | yyformat++; |
| 1306 | } |
| 1307 | } |
| 1308 | return 0; |
| 1309 | } |
| 1310 | #endif /* YYERROR_VERBOSE */ |
| 1311 | |
| 1312 | /*-----------------------------------------------. |
| 1313 | | Release the memory associated to this symbol. | |
| 1314 | `-----------------------------------------------*/ |
| 1315 | |
| 1316 | static void |
| 1317 | yydestruct (const char *yymsg, int yytype, YYSTYPE *yyvaluep) |
| 1318 | { |
| 1319 | YYUSE (yyvaluep); |
| 1320 | if (!yymsg) |
| 1321 | yymsg = "Deleting"; |
| 1322 | YY_SYMBOL_PRINT (yymsg, yytype, yyvaluep, yylocationp); |
| 1323 | |
| 1324 | YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN |
| 1325 | YYUSE (yytype); |
| 1326 | YY_IGNORE_MAYBE_UNINITIALIZED_END |
| 1327 | } |
| 1328 | |
| 1329 | |
| 1330 | |
| 1331 | |
| 1332 | /* The lookahead symbol. */ |
| 1333 | int yychar; |
| 1334 | |
| 1335 | /* The semantic value of the lookahead symbol. */ |
| 1336 | YYSTYPE yylval; |
| 1337 | /* Number of syntax errors so far. */ |
| 1338 | int yynerrs; |
| 1339 | |
| 1340 | |
| 1341 | /*----------. |
| 1342 | | yyparse. | |
| 1343 | `----------*/ |
| 1344 | |
| 1345 | int |
| 1346 | yyparse (void) |
| 1347 | { |
| 1348 | int yystate; |
| 1349 | /* Number of tokens to shift before error messages enabled. */ |
| 1350 | int yyerrstatus; |
| 1351 | |
| 1352 | /* The stacks and their tools: |
| 1353 | 'yyss': related to states. |
| 1354 | 'yyvs': related to semantic values. |
| 1355 | |
| 1356 | Refer to the stacks through separate pointers, to allow yyoverflow |
| 1357 | to reallocate them elsewhere. */ |
| 1358 | |
| 1359 | /* The state stack. */ |
| 1360 | yytype_int16 yyssa[YYINITDEPTH]; |
| 1361 | yytype_int16 *yyss; |
| 1362 | yytype_int16 *yyssp; |
| 1363 | |
| 1364 | /* The semantic value stack. */ |
| 1365 | YYSTYPE yyvsa[YYINITDEPTH]; |
| 1366 | YYSTYPE *yyvs; |
| 1367 | YYSTYPE *yyvsp; |
| 1368 | |
| 1369 | YYSIZE_T yystacksize; |
| 1370 | |
| 1371 | int yyn; |
| 1372 | int yyresult; |
| 1373 | /* Lookahead token as an internal (translated) token number. */ |
| 1374 | int yytoken = 0; |
| 1375 | /* The variables used to return semantic value and location from the |
| 1376 | action routines. */ |
| 1377 | YYSTYPE yyval; |
| 1378 | |
| 1379 | #if YYERROR_VERBOSE |
| 1380 | /* Buffer for error messages, and its allocated size. */ |
| 1381 | char yymsgbuf[128]; |
| 1382 | char *yymsg = yymsgbuf; |
| 1383 | YYSIZE_T yymsg_alloc = sizeof yymsgbuf; |
| 1384 | #endif |
| 1385 | |
| 1386 | #define YYPOPSTACK(N) (yyvsp -= (N), yyssp -= (N)) |
| 1387 | |
| 1388 | /* The number of symbols on the RHS of the reduced rule. |
| 1389 | Keep to zero when no symbol should be popped. */ |
| 1390 | int yylen = 0; |
| 1391 | |
| 1392 | yyssp = yyss = yyssa; |
| 1393 | yyvsp = yyvs = yyvsa; |
| 1394 | yystacksize = YYINITDEPTH; |
| 1395 | |
| 1396 | YYDPRINTF ((stderr, "Starting parse\n")); |
| 1397 | |
| 1398 | yystate = 0; |
| 1399 | yyerrstatus = 0; |
| 1400 | yynerrs = 0; |
| 1401 | yychar = YYEMPTY; /* Cause a token to be read. */ |
| 1402 | goto yysetstate; |
| 1403 | |
| 1404 | /*------------------------------------------------------------. |
| 1405 | | yynewstate -- Push a new state, which is found in yystate. | |
| 1406 | `------------------------------------------------------------*/ |
| 1407 | yynewstate: |
| 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. */ |
| 1410 | yyssp++; |
| 1411 | |
| 1412 | yysetstate: |
| 1413 | *yyssp = yystate; |
| 1414 | |
| 1415 | if (yyss + yystacksize - 1 <= yyssp) |
| 1416 | { |
| 1417 | /* Get the current used size of the three stacks, in elements. */ |
| 1418 | YYSIZE_T yysize = yyssp - yyss + 1; |
| 1419 | |
| 1420 | #ifdef yyoverflow |
| 1421 | { |
| 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 |
| 1424 | memory. */ |
| 1425 | YYSTYPE *yyvs1 = yyvs; |
| 1426 | yytype_int16 *yyss1 = yyss; |
| 1427 | |
| 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), |
| 1435 | &yystacksize); |
| 1436 | |
| 1437 | yyss = yyss1; |
| 1438 | yyvs = yyvs1; |
| 1439 | } |
| 1440 | #else /* no yyoverflow */ |
| 1441 | # ifndef YYSTACK_RELOCATE |
| 1442 | goto yyexhaustedlab; |
| 1443 | # else |
| 1444 | /* Extend the stack our own way. */ |
| 1445 | if (YYMAXDEPTH <= yystacksize) |
| 1446 | goto yyexhaustedlab; |
| 1447 | yystacksize *= 2; |
| 1448 | if (YYMAXDEPTH < yystacksize) |
| 1449 | yystacksize = YYMAXDEPTH; |
| 1450 | |
| 1451 | { |
| 1452 | yytype_int16 *yyss1 = yyss; |
| 1453 | union yyalloc *yyptr = |
| 1454 | (union yyalloc *) YYSTACK_ALLOC (YYSTACK_BYTES (yystacksize)); |
| 1455 | if (! yyptr) |
| 1456 | goto yyexhaustedlab; |
| 1457 | YYSTACK_RELOCATE (yyss_alloc, yyss); |
| 1458 | YYSTACK_RELOCATE (yyvs_alloc, yyvs); |
| 1459 | # undef YYSTACK_RELOCATE |
| 1460 | if (yyss1 != yyssa) |
| 1461 | YYSTACK_FREE (yyss1); |
| 1462 | } |
| 1463 | # endif |
| 1464 | #endif /* no yyoverflow */ |
| 1465 | |
| 1466 | yyssp = yyss + yysize - 1; |
| 1467 | yyvsp = yyvs + yysize - 1; |
| 1468 | |
| 1469 | YYDPRINTF ((stderr, "Stack size increased to %lu\n", |
| 1470 | (unsigned long int) yystacksize)); |
| 1471 | |
| 1472 | if (yyss + yystacksize - 1 <= yyssp) |
| 1473 | YYABORT; |
| 1474 | } |
| 1475 | |
| 1476 | YYDPRINTF ((stderr, "Entering state %d\n", yystate)); |
| 1477 | |
| 1478 | if (yystate == YYFINAL) |
| 1479 | YYACCEPT; |
| 1480 | |
| 1481 | goto yybackup; |
| 1482 | |
| 1483 | /*-----------. |
| 1484 | | yybackup. | |
| 1485 | `-----------*/ |
| 1486 | yybackup: |
| 1487 | |
| 1488 | /* Do appropriate processing given the current state. Read a |
| 1489 | lookahead token if we need one and don't already have one. */ |
| 1490 | |
| 1491 | /* First try to decide what to do without reference to lookahead token. */ |
| 1492 | yyn = yypact[yystate]; |
| 1493 | if (yypact_value_is_default (yyn)) |
| 1494 | goto yydefault; |
| 1495 | |
| 1496 | /* Not known => get a lookahead token if don't already have one. */ |
| 1497 | |
| 1498 | /* YYCHAR is either YYEMPTY or YYEOF or a valid lookahead symbol. */ |
| 1499 | if (yychar == YYEMPTY) |
| 1500 | { |
| 1501 | YYDPRINTF ((stderr, "Reading a token: ")); |
| 1502 | yychar = yylex (); |
| 1503 | } |
| 1504 | |
| 1505 | if (yychar <= YYEOF) |
| 1506 | { |
| 1507 | yychar = yytoken = YYEOF; |
| 1508 | YYDPRINTF ((stderr, "Now at end of input.\n")); |
| 1509 | } |
| 1510 | else |
| 1511 | { |
| 1512 | yytoken = YYTRANSLATE (yychar); |
| 1513 | YY_SYMBOL_PRINT ("Next token is", yytoken, &yylval, &yylloc); |
| 1514 | } |
| 1515 | |
| 1516 | /* If the proper action on seeing token YYTOKEN is to reduce or to |
| 1517 | detect an error, take that action. */ |
| 1518 | yyn += yytoken; |
| 1519 | if (yyn < 0 || YYLAST < yyn || yycheck[yyn] != yytoken) |
| 1520 | goto yydefault; |
| 1521 | yyn = yytable[yyn]; |
| 1522 | if (yyn <= 0) |
| 1523 | { |
| 1524 | if (yytable_value_is_error (yyn)) |
| 1525 | goto yyerrlab; |
| 1526 | yyn = -yyn; |
| 1527 | goto yyreduce; |
| 1528 | } |
| 1529 | |
| 1530 | /* Count tokens shifted since error; after three, turn off error |
| 1531 | status. */ |
| 1532 | if (yyerrstatus) |
| 1533 | yyerrstatus--; |
| 1534 | |
| 1535 | /* Shift the lookahead token. */ |
| 1536 | YY_SYMBOL_PRINT ("Shifting", yytoken, &yylval, &yylloc); |
| 1537 | |
| 1538 | /* Discard the shifted token. */ |
| 1539 | yychar = YYEMPTY; |
| 1540 | |
| 1541 | yystate = yyn; |
| 1542 | YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN |
| 1543 | *++yyvsp = yylval; |
| 1544 | YY_IGNORE_MAYBE_UNINITIALIZED_END |
| 1545 | |
| 1546 | goto yynewstate; |
| 1547 | |
| 1548 | |
| 1549 | /*-----------------------------------------------------------. |
| 1550 | | yydefault -- do the default action for the current state. | |
| 1551 | `-----------------------------------------------------------*/ |
| 1552 | yydefault: |
| 1553 | yyn = yydefact[yystate]; |
| 1554 | if (yyn == 0) |
| 1555 | goto yyerrlab; |
| 1556 | goto yyreduce; |
| 1557 | |
| 1558 | |
| 1559 | /*-----------------------------. |
| 1560 | | yyreduce -- Do a reduction. | |
| 1561 | `-----------------------------*/ |
| 1562 | yyreduce: |
| 1563 | /* yyn is the number of a rule to reduce with. */ |
| 1564 | yylen = yyr2[yyn]; |
| 1565 | |
| 1566 | /* If YYLEN is nonzero, implement the default value of the action: |
| 1567 | '$$ = $1'. |
| 1568 | |
| 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]; |
| 1575 | |
| 1576 | |
| 1577 | YY_REDUCE_PRINT (yyn); |
| 1578 | switch (yyn) |
| 1579 | { |
| 1580 | case 3: |
| 1581 | |
| 1582 | { empty_field_table(); YYACCEPT;} |
| 1583 | |
| 1584 | break; |
| 1585 | |
| 1586 | case 4: |
| 1587 | |
| 1588 | { fprintf (stderr, "Parsed all bytes\n"); |
| 1589 | empty_field_table(); YYACCEPT;} |
| 1590 | |
| 1591 | break; |
| 1592 | |
| 1593 | case 5: |
| 1594 | |
| 1595 | { generate_setter_bitfields(binary->actualblob); } |
| 1596 | |
| 1597 | break; |
| 1598 | |
| 1599 | case 6: |
| 1600 | |
| 1601 | { fprintf (stderr, "No spec\n"); } |
| 1602 | |
| 1603 | break; |
| 1604 | |
| 1605 | case 7: |
| 1606 | |
| 1607 | { fprintf (stderr, "Parsed all spec\n"); |
| 1608 | create_binary_blob(); } |
| 1609 | |
| 1610 | break; |
| 1611 | |
| 1612 | case 10: |
| 1613 | |
| 1614 | { create_new_bitfield((yyvsp[-2].str), (yyvsp[0].u32)); } |
| 1615 | |
| 1616 | break; |
| 1617 | |
| 1618 | case 11: |
| 1619 | |
| 1620 | { create_new_bitfields((yyvsp[-5].str), (yyvsp[-3].u32), (yyvsp[0].u32)); } |
| 1621 | |
| 1622 | break; |
| 1623 | |
| 1624 | case 12: |
| 1625 | |
| 1626 | { fprintf (stderr, "No values\n"); } |
| 1627 | |
| 1628 | break; |
| 1629 | |
| 1630 | case 13: |
| 1631 | |
| 1632 | { fprintf (stderr, "Parsed all values\n"); |
| 1633 | generate_binary(); } |
| 1634 | |
| 1635 | break; |
| 1636 | |
| 1637 | case 16: |
| 1638 | |
| 1639 | { set_bitfield((yyvsp[-2].str), (yyvsp[0].u32)); } |
| 1640 | |
| 1641 | break; |
| 1642 | |
| 1643 | case 17: |
| 1644 | |
| 1645 | { set_bitfield_array((yyvsp[-5].str), (yyvsp[-3].u32), (yyvsp[0].u32)); } |
| 1646 | |
| 1647 | break; |
| 1648 | |
| 1649 | |
| 1650 | |
| 1651 | default: break; |
| 1652 | } |
| 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); |
| 1665 | |
| 1666 | YYPOPSTACK (yylen); |
| 1667 | yylen = 0; |
| 1668 | YY_STACK_PRINT (yyss, yyssp); |
| 1669 | |
| 1670 | *++yyvsp = yyval; |
| 1671 | |
| 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. */ |
| 1675 | |
| 1676 | yyn = yyr1[yyn]; |
| 1677 | |
| 1678 | yystate = yypgoto[yyn - YYNTOKENS] + *yyssp; |
| 1679 | if (0 <= yystate && yystate <= YYLAST && yycheck[yystate] == *yyssp) |
| 1680 | yystate = yytable[yystate]; |
| 1681 | else |
| 1682 | yystate = yydefgoto[yyn - YYNTOKENS]; |
| 1683 | |
| 1684 | goto yynewstate; |
| 1685 | |
| 1686 | |
| 1687 | /*--------------------------------------. |
| 1688 | | yyerrlab -- here on detecting error. | |
| 1689 | `--------------------------------------*/ |
| 1690 | yyerrlab: |
| 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); |
| 1694 | |
| 1695 | /* If not already recovering from an error, report this error. */ |
| 1696 | if (!yyerrstatus) |
| 1697 | { |
| 1698 | ++yynerrs; |
| 1699 | #if ! YYERROR_VERBOSE |
| 1700 | yyerror (YY_("syntax error")); |
| 1701 | #else |
| 1702 | # define YYSYNTAX_ERROR yysyntax_error (&yymsg_alloc, &yymsg, \ |
| 1703 | yyssp, yytoken) |
| 1704 | { |
| 1705 | char const *yymsgp = YY_("syntax error"); |
| 1706 | int yysyntax_error_status; |
| 1707 | yysyntax_error_status = YYSYNTAX_ERROR; |
| 1708 | if (yysyntax_error_status == 0) |
| 1709 | yymsgp = yymsg; |
| 1710 | else if (yysyntax_error_status == 1) |
| 1711 | { |
| 1712 | if (yymsg != yymsgbuf) |
| 1713 | YYSTACK_FREE (yymsg); |
| 1714 | yymsg = (char *) YYSTACK_ALLOC (yymsg_alloc); |
| 1715 | if (!yymsg) |
| 1716 | { |
| 1717 | yymsg = yymsgbuf; |
| 1718 | yymsg_alloc = sizeof yymsgbuf; |
| 1719 | yysyntax_error_status = 2; |
| 1720 | } |
| 1721 | else |
| 1722 | { |
| 1723 | yysyntax_error_status = YYSYNTAX_ERROR; |
| 1724 | yymsgp = yymsg; |
| 1725 | } |
| 1726 | } |
| 1727 | yyerror (yymsgp); |
| 1728 | if (yysyntax_error_status == 2) |
| 1729 | goto yyexhaustedlab; |
| 1730 | } |
| 1731 | # undef YYSYNTAX_ERROR |
| 1732 | #endif |
| 1733 | } |
| 1734 | |
| 1735 | |
| 1736 | |
| 1737 | if (yyerrstatus == 3) |
| 1738 | { |
| 1739 | /* If just tried and failed to reuse lookahead token after an |
| 1740 | error, discard it. */ |
| 1741 | |
| 1742 | if (yychar <= YYEOF) |
| 1743 | { |
| 1744 | /* Return failure if at end of input. */ |
| 1745 | if (yychar == YYEOF) |
| 1746 | YYABORT; |
| 1747 | } |
| 1748 | else |
| 1749 | { |
| 1750 | yydestruct ("Error: discarding", |
| 1751 | yytoken, &yylval); |
| 1752 | yychar = YYEMPTY; |
| 1753 | } |
| 1754 | } |
| 1755 | |
| 1756 | /* Else will try to reuse lookahead token after shifting the error |
| 1757 | token. */ |
| 1758 | goto yyerrlab1; |
| 1759 | |
| 1760 | |
| 1761 | /*---------------------------------------------------. |
| 1762 | | yyerrorlab -- error raised explicitly by YYERROR. | |
| 1763 | `---------------------------------------------------*/ |
| 1764 | yyerrorlab: |
| 1765 | |
| 1766 | /* Pacify compilers like GCC when the user code never invokes |
| 1767 | YYERROR and the label yyerrorlab therefore never appears in user |
| 1768 | code. */ |
| 1769 | if (/*CONSTCOND*/ 0) |
| 1770 | goto yyerrorlab; |
| 1771 | |
| 1772 | /* Do not reclaim the symbols of the rule whose action triggered |
| 1773 | this YYERROR. */ |
| 1774 | YYPOPSTACK (yylen); |
| 1775 | yylen = 0; |
| 1776 | YY_STACK_PRINT (yyss, yyssp); |
| 1777 | yystate = *yyssp; |
| 1778 | goto yyerrlab1; |
| 1779 | |
| 1780 | |
| 1781 | /*-------------------------------------------------------------. |
| 1782 | | yyerrlab1 -- common code for both syntax error and YYERROR. | |
| 1783 | `-------------------------------------------------------------*/ |
| 1784 | yyerrlab1: |
| 1785 | yyerrstatus = 3; /* Each real token shifted decrements this. */ |
| 1786 | |
| 1787 | for (;;) |
| 1788 | { |
| 1789 | yyn = yypact[yystate]; |
| 1790 | if (!yypact_value_is_default (yyn)) |
| 1791 | { |
| 1792 | yyn += YYTERROR; |
| 1793 | if (0 <= yyn && yyn <= YYLAST && yycheck[yyn] == YYTERROR) |
| 1794 | { |
| 1795 | yyn = yytable[yyn]; |
| 1796 | if (0 < yyn) |
| 1797 | break; |
| 1798 | } |
| 1799 | } |
| 1800 | |
| 1801 | /* Pop the current state because it cannot handle the error token. */ |
| 1802 | if (yyssp == yyss) |
| 1803 | YYABORT; |
| 1804 | |
| 1805 | |
| 1806 | yydestruct ("Error: popping", |
| 1807 | yystos[yystate], yyvsp); |
| 1808 | YYPOPSTACK (1); |
| 1809 | yystate = *yyssp; |
| 1810 | YY_STACK_PRINT (yyss, yyssp); |
| 1811 | } |
| 1812 | |
| 1813 | YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN |
| 1814 | *++yyvsp = yylval; |
| 1815 | YY_IGNORE_MAYBE_UNINITIALIZED_END |
| 1816 | |
| 1817 | |
| 1818 | /* Shift the error token. */ |
| 1819 | YY_SYMBOL_PRINT ("Shifting", yystos[yyn], yyvsp, yylsp); |
| 1820 | |
| 1821 | yystate = yyn; |
| 1822 | goto yynewstate; |
| 1823 | |
| 1824 | |
| 1825 | /*-------------------------------------. |
| 1826 | | yyacceptlab -- YYACCEPT comes here. | |
| 1827 | `-------------------------------------*/ |
| 1828 | yyacceptlab: |
| 1829 | yyresult = 0; |
| 1830 | goto yyreturn; |
| 1831 | |
| 1832 | /*-----------------------------------. |
| 1833 | | yyabortlab -- YYABORT comes here. | |
| 1834 | `-----------------------------------*/ |
| 1835 | yyabortlab: |
| 1836 | yyresult = 1; |
| 1837 | goto yyreturn; |
| 1838 | |
| 1839 | #if !defined yyoverflow || YYERROR_VERBOSE |
| 1840 | /*-------------------------------------------------. |
| 1841 | | yyexhaustedlab -- memory exhaustion comes here. | |
| 1842 | `-------------------------------------------------*/ |
| 1843 | yyexhaustedlab: |
| 1844 | yyerror (YY_("memory exhausted")); |
| 1845 | yyresult = 2; |
| 1846 | /* Fall through. */ |
| 1847 | #endif |
| 1848 | |
| 1849 | yyreturn: |
| 1850 | if (yychar != YYEMPTY) |
| 1851 | { |
| 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", |
| 1856 | yytoken, &yylval); |
| 1857 | } |
| 1858 | /* Do not reclaim the symbols of the rule whose action triggered |
| 1859 | this YYABORT or YYACCEPT. */ |
| 1860 | YYPOPSTACK (yylen); |
| 1861 | YY_STACK_PRINT (yyss, yyssp); |
| 1862 | while (yyssp != yyss) |
| 1863 | { |
| 1864 | yydestruct ("Cleanup: popping", |
| 1865 | yystos[*yyssp], yyvsp); |
| 1866 | YYPOPSTACK (1); |
| 1867 | } |
| 1868 | #ifndef yyoverflow |
| 1869 | if (yyss != yyssa) |
| 1870 | YYSTACK_FREE (yyss); |
| 1871 | #endif |
| 1872 | #if YYERROR_VERBOSE |
| 1873 | if (yymsg != yymsgbuf) |
| 1874 | YYSTACK_FREE (yymsg); |
| 1875 | #endif |
| 1876 | return yyresult; |
| 1877 | } |
| 1878 | |
| 1879 | |
| 1880 | |
| 1881 | /* Called by yyparse on error. */ |
| 1882 | void yyerror (char const *s) |
| 1883 | { |
| 1884 | fprintf (stderr, "yyerror: %s\n", s); |
| 1885 | } |
| 1886 | |
| 1887 | /* Declarations */ |
| 1888 | void set_input_string(char* in); |
| 1889 | |
| 1890 | /* This function parses a string */ |
Martin Roth | 6338189 | 2017-04-09 13:30:17 -0600 | [diff] [blame] | 1891 | static int parse_string(unsigned char* in) { |
Martin Roth | cfce793 | 2017-04-09 19:05:10 -0600 | [diff] [blame] | 1892 | set_input_string ((char *)in); |
| 1893 | return yyparse (); |
| 1894 | } |
| 1895 | |
Martin Roth | 6338189 | 2017-04-09 13:30:17 -0600 | [diff] [blame] | 1896 | static unsigned int loadfile (char *file, char *filetype, |
| 1897 | unsigned char **parsestring, unsigned int lenstr) |
| 1898 | { |
| 1899 | unsigned int lenfile; |
| 1900 | |
| 1901 | if ((fp = fopen(file, "r")) == NULL) { |
| 1902 | printf("Error: Could not open %s file: %s\n",filetype,file); |
| 1903 | exit(1); |
| 1904 | } |
| 1905 | fseek(fp, 0, SEEK_END); |
| 1906 | lenfile = ftell(fp); |
| 1907 | fseek(fp, 0, SEEK_SET); |
| 1908 | |
| 1909 | if (lenstr == 0) |
| 1910 | *parsestring = (unsigned char *) malloc (lenfile + 2); |
| 1911 | else |
| 1912 | *parsestring = (unsigned char *) realloc (*parsestring, |
| 1913 | lenfile + lenstr); |
| 1914 | |
| 1915 | check_pointer(*parsestring); |
| 1916 | fread(*parsestring + lenstr, 1, lenfile, fp); |
| 1917 | fclose(fp); |
| 1918 | return lenfile; |
| 1919 | } |
| 1920 | |
Martin Roth | cfce793 | 2017-04-09 19:05:10 -0600 | [diff] [blame] | 1921 | int main (int argc, char *argv[]) |
| 1922 | { |
Martin Roth | 6338189 | 2017-04-09 13:30:17 -0600 | [diff] [blame] | 1923 | unsigned int lenspec; |
Martin Roth | cfce793 | 2017-04-09 19:05:10 -0600 | [diff] [blame] | 1924 | unsigned char *parsestring; |
| 1925 | unsigned char c; |
| 1926 | unsigned int pos = 0; |
| 1927 | int ret = 0; |
| 1928 | |
| 1929 | #if YYDEBUG == 1 |
| 1930 | yydebug = 1; |
| 1931 | #endif |
| 1932 | create_binary_blob(); |
| 1933 | binary->lenactualblob = 0; |
| 1934 | |
| 1935 | if (argc == 4 && strcmp(argv[1], "-d") != 0) { |
| 1936 | /* Compile mode */ |
| 1937 | |
| 1938 | /* Load Spec */ |
Martin Roth | 6338189 | 2017-04-09 13:30:17 -0600 | [diff] [blame] | 1939 | lenspec = loadfile(argv[1], "spec", &parsestring, 0); |
| 1940 | loadfile(argv[2], "setter", &parsestring, lenspec); |
Martin Roth | cfce793 | 2017-04-09 19:05:10 -0600 | [diff] [blame] | 1941 | |
| 1942 | /* Open output and parse string - output to fp */ |
Martin Roth | 6338189 | 2017-04-09 13:30:17 -0600 | [diff] [blame] | 1943 | if ((fp = fopen(argv[3], "wb")) == NULL) { |
| 1944 | printf("Error: Could not open output file: %s\n",argv[3]); |
| 1945 | exit(1); |
| 1946 | } |
Martin Roth | cfce793 | 2017-04-09 19:05:10 -0600 | [diff] [blame] | 1947 | ret = parse_string(parsestring); |
| 1948 | free(parsestring); |
| 1949 | } else if (argc == 5 && strcmp (argv[1], "-d") == 0) { |
| 1950 | /* Decompile mode */ |
| 1951 | |
| 1952 | /* Load Spec */ |
Martin Roth | 6338189 | 2017-04-09 13:30:17 -0600 | [diff] [blame] | 1953 | lenspec = loadfile(argv[2], "spec", &parsestring, 0); |
Martin Roth | cfce793 | 2017-04-09 19:05:10 -0600 | [diff] [blame] | 1954 | |
Martin Roth | cfce793 | 2017-04-09 19:05:10 -0600 | [diff] [blame] | 1955 | parsestring[lenspec] = '%'; |
Martin Roth | 6338189 | 2017-04-09 13:30:17 -0600 | [diff] [blame] | 1956 | parsestring[lenspec + 1] = '\0'; |
Martin Roth | cfce793 | 2017-04-09 19:05:10 -0600 | [diff] [blame] | 1957 | |
| 1958 | /* Load Actual Binary */ |
Martin Roth | 6338189 | 2017-04-09 13:30:17 -0600 | [diff] [blame] | 1959 | if ((fp = fopen(argv[3], "rb")) == NULL) { |
| 1960 | printf("Error: Could not open binary file: %s\n",argv[3]); |
| 1961 | exit(1); |
| 1962 | } |
Martin Roth | cfce793 | 2017-04-09 19:05:10 -0600 | [diff] [blame] | 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); |
Martin Roth | 6338189 | 2017-04-09 13:30:17 -0600 | [diff] [blame] | 1967 | check_pointer(binary->actualblob); |
Martin Roth | cfce793 | 2017-04-09 19:05:10 -0600 | [diff] [blame] | 1968 | fread(binary->actualblob, 1, binary->lenactualblob, fp); |
| 1969 | fclose(fp); |
| 1970 | |
| 1971 | /* Open output and parse - output to fp */ |
Martin Roth | 6338189 | 2017-04-09 13:30:17 -0600 | [diff] [blame] | 1972 | if ((fp = fopen(argv[4], "w")) == NULL) { |
| 1973 | printf("Error: Could not open output file: %s\n",argv[4]); |
| 1974 | exit(1); |
| 1975 | } |
Martin Roth | cfce793 | 2017-04-09 19:05:10 -0600 | [diff] [blame] | 1976 | ret = parse_string(parsestring); |
| 1977 | free(parsestring); |
| 1978 | free(binary->actualblob); |
| 1979 | fclose(fp); |
| 1980 | } else { |
| 1981 | printf("Usage: Compile mode\n\n"); |
Denis 'GNUtoo' Carikli | 780e931 | 2018-01-10 14:35:55 +0100 | [diff] [blame] | 1982 | printf(" bincfg spec setter binaryoutput\n"); |
Martin Roth | cfce793 | 2017-04-09 19:05:10 -0600 | [diff] [blame] | 1983 | printf(" (file) (file) (file)\n"); |
| 1984 | printf(" OR : Decompile mode\n\n"); |
Denis 'GNUtoo' Carikli | 780e931 | 2018-01-10 14:35:55 +0100 | [diff] [blame] | 1985 | printf(" bincfg -d spec binary setteroutput\n"); |
Martin Roth | cfce793 | 2017-04-09 19:05:10 -0600 | [diff] [blame] | 1986 | } |
| 1987 | return ret; |
| 1988 | } |