1 /* A Bison parser, made by GNU Bison 2.1. */ 2 3 /* Skeleton parser for Yacc-like parsing with Bison, 4 Copyright (C) 1984, 1989, 1990, 2000, 2001, 2002, 2003, 2004, 2005 Free Software Foundation, Inc. 5 6 This program is free software; you can redistribute it and/or modify 7 it under the terms of the GNU General Public License as published by 8 the Free Software Foundation; either version 2, or (at your option) 9 any later version. 10 11 This program is distributed in the hope that it will be useful, 12 but WITHOUT ANY WARRANTY; without even the implied warranty of 13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 GNU General Public License for more details. 15 16 You should have received a copy of the GNU General Public License 17 along with this program; if not, write to the Free Software 18 Foundation, Inc., 51 Franklin Street, Fifth Floor, 19 Boston, MA 02110-1301, USA. */ 20 21 /* As a special exception, when this file is copied by Bison into a 22 Bison output file, you may use that output file without restriction. 23 This special exception was added by the Free Software Foundation 24 in version 1.24 of Bison. */ 25 26 /* Written by Richard Stallman by simplifying the original so called 27 ``semantic'' parser. */ 28 29 /* All symbols defined below should begin with yy or YY, to avoid 30 infringing on user name space. This should be done even for local 31 variables, as they might otherwise be expanded by user macros. 32 There are some unavoidable exceptions within include files to 33 define necessary library symbols; they are noted "INFRINGES ON 34 USER NAME SPACE" below. */ 35 36 /* Identify Bison output. */ 37 #define YYBISON 1 38 39 /* Bison version. */ 40 #define YYBISON_VERSION "2.1" 41 42 /* Skeleton name. */ 43 #define YYSKELETON_NAME "yacc.c" 44 45 /* Pure parsers. */ 46 #define YYPURE 1 47 48 /* Using locations. */ 49 #define YYLSP_NEEDED 1 50 51 52 53 /* Tokens. */ 54 #ifndef YYTOKENTYPE 55 # define YYTOKENTYPE 56 /* Put the tokens into the symbol table, so that GDB and other debuggers 57 know about them. */ 58 enum yytokentype { 59 TOK_IDENT = 258, 60 TOK_STRING_LITERAL = 259, 61 TOK_INT_LITERAL = 260, 62 TOK_SECTION_NAME = 261, 63 TOK_SOURCE_NAME = 262, 64 TOK_BLOB = 263, 65 TOK_DOT_DOT = 264, 66 TOK_AND = 265, 67 TOK_OR = 266, 68 TOK_GEQ = 267, 69 TOK_LEQ = 268, 70 TOK_EQ = 269, 71 TOK_NEQ = 270, 72 TOK_POWER = 271, 73 TOK_LSHIFT = 272, 74 TOK_RSHIFT = 273, 75 TOK_INT_SIZE = 274, 76 TOK_OPTIONS = 275, 77 TOK_CONSTANTS = 276, 78 TOK_SOURCES = 277, 79 TOK_FILTERS = 278, 80 TOK_SECTION = 279, 81 TOK_EXTERN = 280, 82 TOK_FROM = 281, 83 TOK_RAW = 282, 84 TOK_LOAD = 283, 85 TOK_JUMP = 284, 86 TOK_CALL = 285, 87 TOK_MODE = 286, 88 TOK_IF = 287, 89 TOK_ELSE = 288, 90 TOK_DEFINED = 289, 91 TOK_INFO = 290, 92 TOK_WARNING = 291, 93 TOK_ERROR = 292, 94 TOK_SIZEOF = 293, 95 TOK_DCD = 294, 96 TOK_HAB = 295, 97 TOK_IVT = 296, 98 UNARY_OP = 297 99 }; 100 #endif 101 /* Tokens. */ 102 #define TOK_IDENT 258 103 #define TOK_STRING_LITERAL 259 104 #define TOK_INT_LITERAL 260 105 #define TOK_SECTION_NAME 261 106 #define TOK_SOURCE_NAME 262 107 #define TOK_BLOB 263 108 #define TOK_DOT_DOT 264 109 #define TOK_AND 265 110 #define TOK_OR 266 111 #define TOK_GEQ 267 112 #define TOK_LEQ 268 113 #define TOK_EQ 269 114 #define TOK_NEQ 270 115 #define TOK_POWER 271 116 #define TOK_LSHIFT 272 117 #define TOK_RSHIFT 273 118 #define TOK_INT_SIZE 274 119 #define TOK_OPTIONS 275 120 #define TOK_CONSTANTS 276 121 #define TOK_SOURCES 277 122 #define TOK_FILTERS 278 123 #define TOK_SECTION 279 124 #define TOK_EXTERN 280 125 #define TOK_FROM 281 126 #define TOK_RAW 282 127 #define TOK_LOAD 283 128 #define TOK_JUMP 284 129 #define TOK_CALL 285 130 #define TOK_MODE 286 131 #define TOK_IF 287 132 #define TOK_ELSE 288 133 #define TOK_DEFINED 289 134 #define TOK_INFO 290 135 #define TOK_WARNING 291 136 #define TOK_ERROR 292 137 #define TOK_SIZEOF 293 138 #define TOK_DCD 294 139 #define TOK_HAB 295 140 #define TOK_IVT 296 141 #define UNARY_OP 297 142 143 144 145 146 /* Copy the first part of user declarations. */ 147 148 #include "ElftosbLexer.h" 149 #include "ElftosbAST.h" 150 #include "Logging.h" 151 #include "Blob.h" 152 #include "format_string.h" 153 #include "Value.h" 154 #include "ConversionController.h" 155 156 using namespace elftosb; 157 158 //! Our special location type. 159 #define YYLTYPE token_loc_t 160 161 // this indicates that we're using our own type. it should be unset automatically 162 // but that's not working for some reason with the .hpp file. 163 #if defined(YYLTYPE_IS_TRIVIAL) 164 #undef YYLTYPE_IS_TRIVIAL 165 #define YYLTYPE_IS_TRIVIAL 0 166 #endif 167 168 //! Default location action 169 #define YYLLOC_DEFAULT(Current, Rhs, N) \ 170 do { \ 171 if (N) \ 172 { \ 173 (Current).m_firstLine = YYRHSLOC(Rhs, 1).m_firstLine; \ 174 (Current).m_lastLine = YYRHSLOC(Rhs, N).m_lastLine; \ 175 } \ 176 else \ 177 { \ 178 (Current).m_firstLine = (Current).m_lastLine = YYRHSLOC(Rhs, 0).m_lastLine; \ 179 } \ 180 } while (0) 181 182 //! Forward declaration of yylex(). 183 static int yylex(YYSTYPE * lvalp, YYLTYPE * yylloc, ElftosbLexer * lexer); 184 185 // Forward declaration of error handling function. 186 static void yyerror(YYLTYPE * yylloc, ElftosbLexer * lexer, CommandFileASTNode ** resultAST, const char * error); 187 188 189 190 /* Enabling traces. */ 191 #ifndef YYDEBUG 192 # define YYDEBUG 0 193 #endif 194 195 /* Enabling verbose error messages. */ 196 #ifdef YYERROR_VERBOSE 197 # undef YYERROR_VERBOSE 198 # define YYERROR_VERBOSE 1 199 #else 200 # define YYERROR_VERBOSE 1 201 #endif 202 203 /* Enabling the token table. */ 204 #ifndef YYTOKEN_TABLE 205 # define YYTOKEN_TABLE 0 206 #endif 207 208 #if ! defined (YYSTYPE) && ! defined (YYSTYPE_IS_DECLARED) 209 typedef union YYSTYPE { 210 int m_num; 211 elftosb::SizedIntegerValue * m_int; 212 Blob * m_blob; 213 std::string * m_str; 214 elftosb::ASTNode * m_ast; // must use full name here because this is put into *.tab.hpp 215 } YYSTYPE; 216 /* Line 196 of yacc.c. */ 217 # define yystype YYSTYPE /* obsolescent; will be withdrawn */ 218 # define YYSTYPE_IS_DECLARED 1 219 # define YYSTYPE_IS_TRIVIAL 1 220 #endif 221 222 #if ! defined (YYLTYPE) && ! defined (YYLTYPE_IS_DECLARED) 223 typedef struct YYLTYPE 224 { 225 int first_line; 226 int first_column; 227 int last_line; 228 int last_column; 229 } YYLTYPE; 230 # define yyltype YYLTYPE /* obsolescent; will be withdrawn */ 231 # define YYLTYPE_IS_DECLARED 1 232 # define YYLTYPE_IS_TRIVIAL 1 233 #endif 234 235 236 /* Copy the second part of user declarations. */ 237 238 239 /* Line 219 of yacc.c. */ 240 241 #if ! defined (YYSIZE_T) && defined (__SIZE_TYPE__) 242 # define YYSIZE_T __SIZE_TYPE__ 243 #endif 244 #if ! defined (YYSIZE_T) && defined (size_t) 245 # define YYSIZE_T size_t 246 #endif 247 #if ! defined (YYSIZE_T) && (defined (__STDC__) || defined (__cplusplus)) 248 # include <stddef.h> /* INFRINGES ON USER NAME SPACE */ 249 # define YYSIZE_T size_t 250 #endif 251 #if ! defined (YYSIZE_T) 252 # define YYSIZE_T unsigned int 253 #endif 254 255 #ifndef YY_ 256 # if YYENABLE_NLS 257 # if ENABLE_NLS 258 # include <libintl.h> /* INFRINGES ON USER NAME SPACE */ 259 # define YY_(msgid) dgettext ("bison-runtime", msgid) 260 # endif 261 # endif 262 # ifndef YY_ 263 # define YY_(msgid) msgid 264 # endif 265 #endif 266 267 #if ! defined (yyoverflow) || YYERROR_VERBOSE 268 269 /* The parser invokes alloca or malloc; define the necessary symbols. */ 270 271 # ifdef YYSTACK_USE_ALLOCA 272 # if YYSTACK_USE_ALLOCA 273 # ifdef __GNUC__ 274 # define YYSTACK_ALLOC __builtin_alloca 275 # else 276 # define YYSTACK_ALLOC alloca 277 # if defined (__STDC__) || defined (__cplusplus) 278 # include <stdlib.h> /* INFRINGES ON USER NAME SPACE */ 279 # define YYINCLUDED_STDLIB_H 280 # endif 281 # endif 282 # endif 283 # endif 284 285 # ifdef YYSTACK_ALLOC 286 /* Pacify GCC's `empty if-body' warning. */ 287 # define YYSTACK_FREE(Ptr) do { /* empty */; } while (0) 288 # ifndef YYSTACK_ALLOC_MAXIMUM 289 /* The OS might guarantee only one guard page at the bottom of the stack, 290 and a page size can be as small as 4096 bytes. So we cannot safely 291 invoke alloca (N) if N exceeds 4096. Use a slightly smaller number 292 to allow for a few compiler-allocated temporary stack slots. */ 293 # define YYSTACK_ALLOC_MAXIMUM 4032 /* reasonable circa 2005 */ 294 # endif 295 # else 296 # define YYSTACK_ALLOC YYMALLOC 297 # define YYSTACK_FREE YYFREE 298 # ifndef YYSTACK_ALLOC_MAXIMUM 299 # define YYSTACK_ALLOC_MAXIMUM ((YYSIZE_T) -1) 300 # endif 301 # ifdef __cplusplus 302 extern "C" { 303 # endif 304 # ifndef YYMALLOC 305 # define YYMALLOC malloc 306 # if (! defined (malloc) && ! defined (YYINCLUDED_STDLIB_H) \ 307 && (defined (__STDC__) || defined (__cplusplus))) 308 void *malloc (YYSIZE_T); /* INFRINGES ON USER NAME SPACE */ 309 # endif 310 # endif 311 # ifndef YYFREE 312 # define YYFREE free 313 # if (! defined (free) && ! defined (YYINCLUDED_STDLIB_H) \ 314 && (defined (__STDC__) || defined (__cplusplus))) 315 void free (void *); /* INFRINGES ON USER NAME SPACE */ 316 # endif 317 # endif 318 # ifdef __cplusplus 319 } 320 # endif 321 # endif 322 #endif /* ! defined (yyoverflow) || YYERROR_VERBOSE */ 323 324 325 #if (! defined (yyoverflow) \ 326 && (! defined (__cplusplus) \ 327 || (defined (YYLTYPE_IS_TRIVIAL) && YYLTYPE_IS_TRIVIAL \ 328 && defined (YYSTYPE_IS_TRIVIAL) && YYSTYPE_IS_TRIVIAL))) 329 330 /* A type that is properly aligned for any stack member. */ 331 union yyalloc 332 { 333 short int yyss; 334 YYSTYPE yyvs; 335 YYLTYPE yyls; 336 }; 337 338 /* The size of the maximum gap between one aligned stack and the next. */ 339 # define YYSTACK_GAP_MAXIMUM (sizeof (union yyalloc) - 1) 340 341 /* The size of an array large to enough to hold all stacks, each with 342 N elements. */ 343 # define YYSTACK_BYTES(N) \ 344 ((N) * (sizeof (short int) + sizeof (YYSTYPE) + sizeof (YYLTYPE)) \ 345 + 2 * YYSTACK_GAP_MAXIMUM) 346 347 /* Copy COUNT objects from FROM to TO. The source and destination do 348 not overlap. */ 349 # ifndef YYCOPY 350 # if defined (__GNUC__) && 1 < __GNUC__ 351 # define YYCOPY(To, From, Count) \ 352 __builtin_memcpy (To, From, (Count) * sizeof (*(From))) 353 # else 354 # define YYCOPY(To, From, Count) \ 355 do \ 356 { \ 357 YYSIZE_T yyi; \ 358 for (yyi = 0; yyi < (Count); yyi++) \ 359 (To)[yyi] = (From)[yyi]; \ 360 } \ 361 while (0) 362 # endif 363 # endif 364 365 /* Relocate STACK from its old location to the new one. The 366 local variables YYSIZE and YYSTACKSIZE give the old and new number of 367 elements in the stack, and YYPTR gives the new location of the 368 stack. Advance YYPTR to a properly aligned location for the next 369 stack. */ 370 # define YYSTACK_RELOCATE(Stack) \ 371 do \ 372 { \ 373 YYSIZE_T yynewbytes; \ 374 YYCOPY (&yyptr->Stack, Stack, yysize); \ 375 Stack = &yyptr->Stack; \ 376 yynewbytes = yystacksize * sizeof (*Stack) + YYSTACK_GAP_MAXIMUM; \ 377 yyptr += yynewbytes / sizeof (*yyptr); \ 378 } \ 379 while (0) 380 381 #endif 382 383 #if defined (__STDC__) || defined (__cplusplus) 384 typedef signed char yysigned_char; 385 #else 386 typedef short int yysigned_char; 387 #endif 388 389 /* YYFINAL -- State number of the termination state. */ 390 #define YYFINAL 13 391 /* YYLAST -- Last index in YYTABLE. */ 392 #define YYLAST 418 393 394 /* YYNTOKENS -- Number of terminals. */ 395 #define YYNTOKENS 66 396 /* YYNNTS -- Number of nonterminals. */ 397 #define YYNNTS 52 398 /* YYNRULES -- Number of rules. */ 399 #define YYNRULES 133 400 /* YYNRULES -- Number of states. */ 401 #define YYNSTATES 238 402 403 /* YYTRANSLATE(YYLEX) -- Bison symbol number corresponding to YYLEX. */ 404 #define YYUNDEFTOK 2 405 #define YYMAXUTOK 297 406 407 #define YYTRANSLATE(YYX) \ 408 ((unsigned int) (YYX) <= YYMAXUTOK ? yytranslate[YYX] : YYUNDEFTOK) 409 410 /* YYTRANSLATE[YYLEX] -- Bison symbol number corresponding to YYLEX. */ 411 static const unsigned char yytranslate[] = 412 { 413 0, 2, 2, 2, 2, 2, 2, 2, 2, 2, 414 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 415 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 416 2, 2, 2, 26, 2, 2, 2, 64, 23, 2, 417 9, 10, 62, 60, 16, 61, 20, 63, 2, 2, 418 2, 2, 2, 2, 2, 2, 2, 2, 18, 17, 419 25, 15, 19, 2, 2, 2, 2, 2, 2, 2, 420 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 421 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 422 2, 13, 2, 14, 59, 2, 2, 2, 2, 2, 423 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 424 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 425 2, 2, 2, 11, 24, 12, 22, 2, 2, 2, 426 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 427 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 428 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 429 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 430 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 431 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 432 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 433 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 434 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 435 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 436 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 437 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 438 2, 2, 2, 2, 2, 2, 1, 2, 3, 4, 439 5, 6, 7, 8, 21, 27, 28, 29, 30, 31, 440 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 441 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 442 52, 53, 54, 55, 56, 57, 58, 65 443 }; 444 445 #if YYDEBUG 446 /* YYPRHS[YYN] -- Index of the first RHS symbol of rule number YYN in 447 YYRHS. */ 448 static const unsigned short int yyprhs[] = 449 { 450 0, 0, 3, 6, 8, 11, 13, 15, 17, 22, 451 27, 29, 32, 35, 36, 40, 45, 47, 50, 54, 452 55, 59, 66, 70, 71, 73, 77, 81, 83, 86, 453 93, 96, 97, 99, 100, 104, 108, 110, 113, 116, 454 118, 120, 121, 123, 126, 129, 131, 132, 134, 136, 455 138, 140, 145, 147, 148, 150, 152, 154, 156, 160, 456 165, 167, 169, 171, 175, 177, 180, 183, 184, 186, 457 188, 193, 195, 196, 200, 205, 207, 209, 211, 213, 458 217, 220, 221, 227, 230, 233, 236, 239, 246, 251, 459 254, 255, 257, 261, 263, 265, 267, 271, 275, 279, 460 283, 287, 291, 295, 299, 302, 307, 311, 316, 318, 461 322, 325, 327, 329, 331, 335, 339, 343, 347, 351, 462 355, 359, 363, 367, 371, 375, 377, 381, 385, 390, 463 395, 400, 403, 406 464 }; 465 466 /* YYRHS -- A `-1'-separated list of the rules' RHS. */ 467 static const yysigned_char yyrhs[] = 468 { 469 67, 0, -1, 68, 82, -1, 69, -1, 68, 69, 470 -1, 70, -1, 71, -1, 75, -1, 37, 11, 72, 471 12, -1, 38, 11, 72, 12, -1, 73, -1, 72, 472 73, -1, 74, 17, -1, -1, 3, 15, 111, -1, 473 39, 11, 76, 12, -1, 77, -1, 76, 77, -1, 474 78, 79, 17, -1, -1, 3, 15, 4, -1, 3, 475 15, 42, 9, 113, 10, -1, 9, 80, 10, -1, 476 -1, 81, -1, 80, 16, 81, -1, 3, 15, 111, 477 -1, 83, -1, 82, 83, -1, 41, 9, 113, 84, 478 10, 86, -1, 17, 85, -1, -1, 80, -1, -1, 479 30, 94, 17, -1, 11, 87, 12, -1, 88, -1, 480 87, 88, -1, 91, 17, -1, 105, -1, 108, -1, 481 -1, 90, -1, 89, 90, -1, 91, 17, -1, 108, 482 -1, -1, 92, -1, 101, -1, 106, -1, 107, -1, 483 45, 93, 94, 97, -1, 56, -1, -1, 113, -1, 484 4, -1, 7, -1, 95, -1, 95, 43, 7, -1, 485 7, 13, 95, 14, -1, 8, -1, 99, -1, 96, 486 -1, 95, 16, 96, -1, 6, -1, 22, 6, -1, 487 19, 98, -1, -1, 20, -1, 110, -1, 58, 9, 488 100, 10, -1, 80, -1, -1, 102, 103, 104, -1, 489 57, 102, 110, 104, -1, 47, -1, 46, -1, 7, 490 -1, 113, -1, 9, 113, 10, -1, 9, 10, -1, 491 -1, 43, 7, 11, 89, 12, -1, 48, 113, -1, 492 52, 4, -1, 53, 4, -1, 54, 4, -1, 49, 493 112, 11, 87, 12, 109, -1, 50, 11, 87, 12, 494 -1, 50, 108, -1, -1, 113, -1, 113, 21, 113, 495 -1, 112, -1, 4, -1, 113, -1, 112, 25, 112, 496 -1, 112, 19, 112, -1, 112, 29, 112, -1, 112, 497 30, 112, -1, 112, 31, 112, -1, 112, 32, 112, 498 -1, 112, 27, 112, -1, 112, 28, 112, -1, 26, 499 112, -1, 3, 9, 7, 10, -1, 9, 112, 10, 500 -1, 51, 9, 3, 10, -1, 115, -1, 7, 18, 501 3, -1, 18, 3, -1, 117, -1, 3, -1, 114, 502 -1, 115, 60, 115, -1, 115, 61, 115, -1, 115, 503 62, 115, -1, 115, 63, 115, -1, 115, 64, 115, 504 -1, 115, 33, 115, -1, 115, 23, 115, -1, 115, 505 24, 115, -1, 115, 59, 115, -1, 115, 34, 115, 506 -1, 115, 35, 115, -1, 116, -1, 115, 20, 36, 507 -1, 9, 115, 10, -1, 55, 9, 114, 10, -1, 508 55, 9, 3, 10, -1, 55, 9, 7, 10, -1, 509 60, 115, -1, 61, 115, -1, 5, -1 510 }; 511 512 /* YYRLINE[YYN] -- source line where rule number YYN was defined. */ 513 static const unsigned short int yyrline[] = 514 { 515 0, 162, 162, 172, 178, 186, 187, 188, 191, 197, 516 203, 209, 216, 217, 220, 227, 233, 239, 247, 259, 517 262, 267, 275, 276, 280, 286, 294, 301, 307, 314, 518 329, 334, 340, 345, 351, 357, 365, 371, 379, 380, 519 381, 382, 385, 391, 399, 400, 401, 404, 405, 406, 520 407, 410, 433, 443, 445, 449, 454, 459, 464, 469, 521 474, 479, 484, 490, 498, 503, 510, 515, 521, 526, 522 532, 544, 545, 548, 577, 614, 615, 618, 623, 630, 523 631, 632, 635, 642, 649, 654, 659, 666, 677, 681, 524 688, 691, 696, 703, 707, 714, 718, 725, 732, 739, 525 746, 753, 760, 767, 774, 779, 784, 789, 796, 799, 526 804, 812, 816, 821, 832, 839, 846, 853, 860, 867, 527 874, 881, 888, 895, 902, 909, 913, 918, 923, 928, 528 933, 940, 944, 951 529 }; 530 #endif 531 532 #if YYDEBUG || YYERROR_VERBOSE || YYTOKEN_TABLE 533 /* YYTNAME[SYMBOL-NUM] -- String name of the symbol SYMBOL-NUM. 534 First, the terminals, then, starting at YYNTOKENS, nonterminals. */ 535 static const char *const yytname[] = 536 { 537 "$end", "error", "$undefined", "\"identifier\"", "\"string\"", 538 "\"integer\"", "\"section name\"", "\"source name\"", 539 "\"binary object\"", "'('", "')'", "'{'", "'}'", "'['", "']'", "'='", 540 "','", "';'", "':'", "'>'", "'.'", "\"..\"", "'~'", "'&'", "'|'", "'<'", 541 "'!'", "\"&&\"", "\"||\"", "\">=\"", "\"<=\"", "\"==\"", "\"!=\"", 542 "\"**\"", "\"<<\"", "\">>\"", "\"integer size\"", "\"options\"", 543 "\"constants\"", "\"sources\"", "\"filters\"", "\"section\"", 544 "\"extern\"", "\"from\"", "\"raw\"", "\"load\"", "\"jump\"", "\"call\"", 545 "\"mode\"", "\"if\"", "\"else\"", "\"defined\"", "\"info\"", 546 "\"warning\"", "\"error\"", "\"sizeof\"", "\"dcd\"", "\"hab\"", 547 "\"ivt\"", "'^'", "'+'", "'-'", "'*'", "'/'", "'%'", "UNARY_OP", 548 "$accept", "command_file", "blocks_list", "pre_section_block", 549 "options_block", "constants_block", "const_def_list", 550 "const_def_list_elem", "const_def", "sources_block", "source_def_list", 551 "source_def_list_elem", "source_def", "source_attrs_opt", 552 "source_attr_list", "source_attr_list_elem", "section_defs", 553 "section_def", "section_options_opt", "source_attr_list_opt", 554 "section_contents", "full_stmt_list", "full_stmt_list_elem", 555 "basic_stmt_list", "basic_stmt_list_elem", "basic_stmt", "load_stmt", 556 "dcd_opt", "load_data", "section_list", "section_list_elem", 557 "load_target_opt", "load_target", "ivt_def", "assignment_list_opt", 558 "call_stmt", "call_or_jump", "call_target", "call_arg_opt", "from_stmt", 559 "mode_stmt", "message_stmt", "if_stmt", "else_opt", "address_or_range", 560 "const_expr", "bool_expr", "int_const_expr", "symbol_ref", "expr", 561 "unary_expr", "int_value", 0 562 }; 563 #endif 564 565 # ifdef YYPRINT 566 /* YYTOKNUM[YYLEX-NUM] -- Internal token number corresponding to 567 token YYLEX-NUM. */ 568 static const unsigned short int yytoknum[] = 569 { 570 0, 256, 257, 258, 259, 260, 261, 262, 263, 40, 571 41, 123, 125, 91, 93, 61, 44, 59, 58, 62, 572 46, 264, 126, 38, 124, 60, 33, 265, 266, 267, 573 268, 269, 270, 271, 272, 273, 274, 275, 276, 277, 574 278, 279, 280, 281, 282, 283, 284, 285, 286, 287, 575 288, 289, 290, 291, 292, 293, 294, 295, 296, 94, 576 43, 45, 42, 47, 37, 297 577 }; 578 # endif 579 580 /* YYR1[YYN] -- Symbol number of symbol that rule YYN derives. */ 581 static const unsigned char yyr1[] = 582 { 583 0, 66, 67, 68, 68, 69, 69, 69, 70, 71, 584 72, 72, 73, 73, 74, 75, 76, 76, 77, 77, 585 78, 78, 79, 79, 80, 80, 81, 82, 82, 83, 586 84, 84, 85, 85, 86, 86, 87, 87, 88, 88, 587 88, 88, 89, 89, 90, 90, 90, 91, 91, 91, 588 91, 92, 93, 93, 94, 94, 94, 94, 94, 94, 589 94, 94, 95, 95, 96, 96, 97, 97, 98, 98, 590 99, 100, 100, 101, 101, 102, 102, 103, 103, 104, 591 104, 104, 105, 106, 107, 107, 107, 108, 109, 109, 592 109, 110, 110, 111, 111, 112, 112, 112, 112, 112, 593 112, 112, 112, 112, 112, 112, 112, 112, 113, 114, 594 114, 115, 115, 115, 115, 115, 115, 115, 115, 115, 595 115, 115, 115, 115, 115, 115, 115, 115, 115, 115, 596 115, 116, 116, 117 597 }; 598 599 /* YYR2[YYN] -- Number of symbols composing right hand side of rule YYN. */ 600 static const unsigned char yyr2[] = 601 { 602 0, 2, 2, 1, 2, 1, 1, 1, 4, 4, 603 1, 2, 2, 0, 3, 4, 1, 2, 3, 0, 604 3, 6, 3, 0, 1, 3, 3, 1, 2, 6, 605 2, 0, 1, 0, 3, 3, 1, 2, 2, 1, 606 1, 0, 1, 2, 2, 1, 0, 1, 1, 1, 607 1, 4, 1, 0, 1, 1, 1, 1, 3, 4, 608 1, 1, 1, 3, 1, 2, 2, 0, 1, 1, 609 4, 1, 0, 3, 4, 1, 1, 1, 1, 3, 610 2, 0, 5, 2, 2, 2, 2, 6, 4, 2, 611 0, 1, 3, 1, 1, 1, 3, 3, 3, 3, 612 3, 3, 3, 3, 2, 4, 3, 4, 1, 3, 613 2, 1, 1, 1, 3, 3, 3, 3, 3, 3, 614 3, 3, 3, 3, 3, 1, 3, 3, 4, 4, 615 4, 2, 2, 1 616 }; 617 618 /* YYDEFACT[STATE-NAME] -- Default rule to reduce with in state 619 STATE-NUM when YYTABLE doesn't specify something else to do. Zero 620 means the default is an error. */ 621 static const unsigned char yydefact[] = 622 { 623 0, 0, 0, 0, 0, 0, 3, 5, 6, 7, 624 13, 13, 19, 1, 0, 4, 2, 27, 0, 0, 625 10, 0, 0, 0, 0, 16, 23, 0, 28, 0, 626 8, 11, 12, 9, 0, 15, 17, 0, 0, 112, 627 133, 0, 0, 0, 0, 0, 0, 31, 113, 108, 628 125, 111, 112, 94, 0, 0, 0, 14, 93, 95, 629 20, 0, 0, 0, 24, 18, 0, 0, 110, 0, 630 131, 132, 33, 0, 0, 0, 0, 0, 0, 0, 631 0, 0, 0, 0, 0, 0, 0, 0, 108, 104, 632 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 633 0, 22, 0, 109, 127, 0, 0, 0, 32, 30, 634 0, 126, 120, 121, 119, 123, 124, 122, 114, 115, 635 116, 117, 118, 0, 106, 0, 97, 96, 102, 103, 636 98, 99, 100, 101, 0, 26, 25, 129, 130, 128, 637 41, 0, 29, 105, 107, 21, 0, 53, 76, 75, 638 0, 0, 0, 0, 0, 0, 0, 36, 0, 47, 639 48, 0, 39, 49, 50, 40, 55, 64, 56, 60, 640 0, 0, 0, 57, 62, 61, 54, 0, 52, 0, 641 83, 0, 84, 85, 86, 0, 35, 37, 38, 77, 642 81, 78, 0, 65, 72, 34, 0, 0, 46, 67, 643 41, 81, 91, 0, 73, 0, 71, 0, 63, 58, 644 0, 42, 0, 45, 0, 51, 0, 74, 0, 80, 645 0, 59, 70, 82, 43, 44, 68, 66, 69, 90, 646 92, 79, 0, 87, 41, 89, 0, 88 647 }; 648 649 /* YYDEFGOTO[NTERM-NUM]. */ 650 static const short int yydefgoto[] = 651 { 652 -1, 4, 5, 6, 7, 8, 19, 20, 21, 9, 653 24, 25, 26, 38, 63, 64, 16, 17, 73, 109, 654 142, 156, 157, 210, 211, 158, 159, 179, 172, 173, 655 174, 215, 227, 175, 207, 160, 161, 190, 204, 162, 656 163, 164, 165, 233, 201, 57, 58, 59, 48, 49, 657 50, 51 658 }; 659 660 /* YYPACT[STATE-NUM] -- Index in YYTABLE of the portion describing 661 STATE-NUM. */ 662 #define YYPACT_NINF -181 663 static const short int yypact[] = 664 { 665 128, 17, 25, 48, 69, 123, -181, -181, -181, -181, 666 96, 96, 101, -181, 80, -181, 68, -181, 112, 85, 667 -181, 115, 89, 114, 91, -181, 124, 30, -181, 47, 668 -181, -181, -181, -181, 11, -181, -181, 134, 125, -181, 669 -181, 133, 30, 140, 144, 30, 30, 153, -181, 225, 670 -181, -181, 148, -181, 61, 61, 162, -181, 359, -181, 671 -181, 164, 159, 22, -181, -181, 172, 121, -181, 9, 672 -181, -181, 134, 168, 143, 30, 30, 30, 30, 30, 673 30, 30, 30, 30, 30, 30, 179, 303, 121, -181, 674 194, 61, 61, 61, 61, 61, 61, 61, 61, 30, 675 47, -181, 134, -181, -181, 188, 4, 200, 199, -181, 676 56, -181, 241, 231, 236, 86, 86, 247, 76, 76, 677 196, 196, 196, 208, -181, 210, -181, -181, 373, 373, 678 -181, -181, -181, -181, 216, -181, -181, -181, -181, -181, 679 314, 2, -181, -181, -181, -181, 220, 175, -181, -181, 680 30, 61, 228, 230, 237, 28, 147, -181, 223, -181, 681 -181, 108, -181, -181, -181, -181, -181, -181, 92, -181, 682 240, 243, 233, 15, -181, -181, -181, 242, -181, 2, 683 -181, 345, -181, -181, -181, 30, -181, -181, -181, 133, 684 246, -181, 7, -181, 134, -181, 7, 250, 361, 244, 685 314, 246, 248, 16, -181, 104, 199, 252, -181, -181, 686 190, -181, 251, -181, 75, -181, 160, -181, 30, -181, 687 261, -181, -181, -181, -181, -181, -181, -181, -181, 222, 688 -181, -181, 6, -181, 314, -181, 176, -181 689 }; 690 691 /* YYPGOTO[NTERM-NUM]. */ 692 static const short int yypgoto[] = 693 { 694 -181, -181, -181, 268, -181, -181, 266, 106, -181, -181, 695 -181, 254, -181, -181, -70, 177, -181, 267, -181, -181, 696 -181, -151, -155, -181, 107, -180, -181, -181, 127, 122, 697 129, -181, -181, -181, -181, -181, 163, -181, 118, -181, 698 -181, -181, -21, -181, 109, 221, -51, -27, 257, 270, 699 -181, -181 700 }; 701 702 /* YYTABLE[YYPACT[STATE-NUM]]. What to do in state STATE-NUM. If 703 positive, shift that token. If negative, reduce the rule which 704 number is the opposite. If zero, do what YYDEFACT says. 705 If YYTABLE_NINF, syntax error. */ 706 #define YYTABLE_NINF -1 707 static const unsigned char yytable[] = 708 { 709 47, 187, 108, 87, 89, 39, 166, 40, 167, 168, 710 169, 42, 105, 167, 138, 60, 106, 234, 212, 39, 711 43, 40, 66, 41, 170, 42, 219, 43, 10, 170, 712 212, 196, 101, 39, 43, 40, 11, 41, 102, 42, 713 126, 127, 128, 129, 130, 131, 132, 133, 43, 216, 714 52, 53, 40, 61, 41, 151, 54, 44, 197, 12, 715 171, 187, 45, 46, 52, 43, 40, 140, 41, 13, 716 54, 44, 134, 55, 148, 149, 45, 46, 39, 43, 717 40, 187, 41, 236, 42, 44, 141, 55, 18, 27, 718 45, 46, 18, 43, 23, 226, 74, 30, 56, 18, 719 181, 33, 44, 35, 23, 192, 74, 45, 46, 14, 720 66, 39, 56, 40, 176, 189, 44, 42, 221, 77, 721 196, 45, 46, 180, 206, 31, 43, 29, 31, 34, 722 44, 104, 32, 37, 191, 45, 46, 62, 83, 84, 723 85, 74, 65, 68, 75, 76, 81, 82, 83, 84, 724 85, 66, 176, 69, 77, 78, 79, 86, 202, 186, 725 1, 2, 3, 44, 14, 1, 2, 3, 45, 46, 726 72, 90, 229, 99, 100, 103, 220, 213, 110, 111, 727 80, 81, 82, 83, 84, 85, 123, 202, 237, 213, 728 146, 230, 147, 148, 149, 150, 151, 125, 137, 152, 729 153, 154, 223, 146, 155, 147, 148, 149, 150, 151, 730 139, 235, 152, 153, 154, 102, 74, 155, 143, 146, 731 144, 147, 148, 149, 150, 151, 145, 177, 152, 153, 732 154, 178, 182, 155, 183, 147, 148, 149, 150, 151, 733 188, 184, 152, 153, 154, 74, 193, 155, 75, 76, 734 195, 74, 194, 198, 75, 203, 74, 209, 77, 78, 735 79, 74, 222, 214, 77, 78, 79, 74, 225, 218, 736 75, 231, 232, 15, 77, 78, 79, 22, 36, 136, 737 77, 78, 79, 28, 80, 81, 82, 83, 84, 85, 738 80, 81, 82, 83, 84, 85, 81, 82, 83, 84, 739 85, 81, 82, 83, 84, 85, 199, 81, 82, 83, 740 84, 85, 67, 124, 205, 70, 71, 224, 185, 217, 741 0, 135, 91, 228, 88, 208, 107, 0, 92, 0, 742 93, 94, 95, 96, 97, 98, 0, 0, 0, 0, 743 0, 0, 0, 0, 0, 112, 113, 114, 115, 116, 744 117, 118, 119, 120, 121, 122, 200, 146, 0, 147, 745 148, 149, 150, 151, 91, 0, 152, 153, 154, 0, 746 92, 155, 93, 94, 95, 96, 97, 98, 91, 0, 747 0, 0, 0, 0, 92, 0, 93, 94, 95, 96, 748 97, 98, 91, 0, 0, 0, 0, 0, 92, 0, 749 0, 0, 95, 96, 97, 98, 147, 148, 149, 150, 750 151, 0, 0, 152, 153, 154, 0, 0, 155 751 }; 752 753 static const short int yycheck[] = 754 { 755 27, 156, 72, 54, 55, 3, 4, 5, 6, 7, 756 8, 9, 3, 6, 10, 4, 7, 11, 198, 3, 757 18, 5, 18, 7, 22, 9, 10, 18, 11, 22, 758 210, 16, 10, 3, 18, 5, 11, 7, 16, 9, 759 91, 92, 93, 94, 95, 96, 97, 98, 18, 200, 760 3, 4, 5, 42, 7, 49, 9, 55, 43, 11, 761 58, 216, 60, 61, 3, 18, 5, 11, 7, 0, 762 9, 55, 99, 26, 46, 47, 60, 61, 3, 18, 763 5, 236, 7, 234, 9, 55, 30, 26, 3, 9, 764 60, 61, 3, 18, 3, 20, 20, 12, 51, 3, 765 151, 12, 55, 12, 3, 13, 20, 60, 61, 41, 766 18, 3, 51, 5, 141, 7, 55, 9, 14, 33, 767 16, 60, 61, 150, 194, 19, 18, 15, 22, 15, 768 55, 10, 17, 9, 161, 60, 61, 3, 62, 63, 769 64, 20, 17, 3, 23, 24, 60, 61, 62, 63, 770 64, 18, 179, 9, 33, 34, 35, 9, 185, 12, 771 37, 38, 39, 55, 41, 37, 38, 39, 60, 61, 772 17, 9, 12, 9, 15, 3, 203, 198, 10, 36, 773 59, 60, 61, 62, 63, 64, 7, 214, 12, 210, 774 43, 218, 45, 46, 47, 48, 49, 3, 10, 52, 775 53, 54, 12, 43, 57, 45, 46, 47, 48, 49, 776 10, 232, 52, 53, 54, 16, 20, 57, 10, 43, 777 10, 45, 46, 47, 48, 49, 10, 7, 52, 53, 778 54, 56, 4, 57, 4, 45, 46, 47, 48, 49, 779 17, 4, 52, 53, 54, 20, 6, 57, 23, 24, 780 17, 20, 9, 11, 23, 9, 20, 7, 33, 34, 781 35, 20, 10, 19, 33, 34, 35, 20, 17, 21, 782 23, 10, 50, 5, 33, 34, 35, 11, 24, 102, 783 33, 34, 35, 16, 59, 60, 61, 62, 63, 64, 784 59, 60, 61, 62, 63, 64, 60, 61, 62, 63, 785 64, 60, 61, 62, 63, 64, 179, 60, 61, 62, 786 63, 64, 42, 10, 192, 45, 46, 210, 155, 201, 787 -1, 100, 19, 214, 54, 196, 69, -1, 25, -1, 788 27, 28, 29, 30, 31, 32, -1, -1, -1, -1, 789 -1, -1, -1, -1, -1, 75, 76, 77, 78, 79, 790 80, 81, 82, 83, 84, 85, 11, 43, -1, 45, 791 46, 47, 48, 49, 19, -1, 52, 53, 54, -1, 792 25, 57, 27, 28, 29, 30, 31, 32, 19, -1, 793 -1, -1, -1, -1, 25, -1, 27, 28, 29, 30, 794 31, 32, 19, -1, -1, -1, -1, -1, 25, -1, 795 -1, -1, 29, 30, 31, 32, 45, 46, 47, 48, 796 49, -1, -1, 52, 53, 54, -1, -1, 57 797 }; 798 799 /* YYSTOS[STATE-NUM] -- The (internal number of the) accessing 800 symbol of state STATE-NUM. */ 801 static const unsigned char yystos[] = 802 { 803 0, 37, 38, 39, 67, 68, 69, 70, 71, 75, 804 11, 11, 11, 0, 41, 69, 82, 83, 3, 72, 805 73, 74, 72, 3, 76, 77, 78, 9, 83, 15, 806 12, 73, 17, 12, 15, 12, 77, 9, 79, 3, 807 5, 7, 9, 18, 55, 60, 61, 113, 114, 115, 808 116, 117, 3, 4, 9, 26, 51, 111, 112, 113, 809 4, 42, 3, 80, 81, 17, 18, 115, 3, 9, 810 115, 115, 17, 84, 20, 23, 24, 33, 34, 35, 811 59, 60, 61, 62, 63, 64, 9, 112, 115, 112, 812 9, 19, 25, 27, 28, 29, 30, 31, 32, 9, 813 15, 10, 16, 3, 10, 3, 7, 114, 80, 85, 814 10, 36, 115, 115, 115, 115, 115, 115, 115, 115, 815 115, 115, 115, 7, 10, 3, 112, 112, 112, 112, 816 112, 112, 112, 112, 113, 111, 81, 10, 10, 10, 817 11, 30, 86, 10, 10, 10, 43, 45, 46, 47, 818 48, 49, 52, 53, 54, 57, 87, 88, 91, 92, 819 101, 102, 105, 106, 107, 108, 4, 6, 7, 8, 820 22, 58, 94, 95, 96, 99, 113, 7, 56, 93, 821 113, 112, 4, 4, 4, 102, 12, 88, 17, 7, 822 103, 113, 13, 6, 9, 17, 16, 43, 11, 94, 823 11, 110, 113, 9, 104, 95, 80, 100, 96, 7, 824 89, 90, 91, 108, 19, 97, 87, 104, 21, 10, 825 113, 14, 10, 12, 90, 17, 20, 98, 110, 12, 826 113, 10, 50, 109, 11, 108, 87, 12 827 }; 828 829 #define yyerrok (yyerrstatus = 0) 830 #define yyclearin (yychar = YYEMPTY) 831 #define YYEMPTY (-2) 832 #define YYEOF 0 833 834 #define YYACCEPT goto yyacceptlab 835 #define YYABORT goto yyabortlab 836 #define YYERROR goto yyerrorlab 837 838 839 /* Like YYERROR except do call yyerror. This remains here temporarily 840 to ease the transition to the new meaning of YYERROR, for GCC. 841 Once GCC version 2 has supplanted version 1, this can go. */ 842 843 #define YYFAIL goto yyerrlab 844 845 #define YYRECOVERING() (!!yyerrstatus) 846 847 #define YYBACKUP(Token, Value) \ 848 do \ 849 if (yychar == YYEMPTY && yylen == 1) \ 850 { \ 851 yychar = (Token); \ 852 yylval = (Value); \ 853 yytoken = YYTRANSLATE (yychar); \ 854 YYPOPSTACK; \ 855 goto yybackup; \ 856 } \ 857 else \ 858 { \ 859 yyerror (&yylloc, lexer, resultAST, YY_("syntax error: cannot back up")); \ 860 YYERROR; \ 861 } \ 862 while (0) 863 864 865 #define YYTERROR 1 866 #define YYERRCODE 256 867 868 869 /* YYLLOC_DEFAULT -- Set CURRENT to span from RHS[1] to RHS[N]. 870 If N is 0, then set CURRENT to the empty location which ends 871 the previous symbol: RHS[0] (always defined). */ 872 873 #define YYRHSLOC(Rhs, K) ((Rhs)[K]) 874 #ifndef YYLLOC_DEFAULT 875 # define YYLLOC_DEFAULT(Current, Rhs, N) \ 876 do \ 877 if (N) \ 878 { \ 879 (Current).first_line = YYRHSLOC (Rhs, 1).first_line; \ 880 (Current).first_column = YYRHSLOC (Rhs, 1).first_column; \ 881 (Current).last_line = YYRHSLOC (Rhs, N).last_line; \ 882 (Current).last_column = YYRHSLOC (Rhs, N).last_column; \ 883 } \ 884 else \ 885 { \ 886 (Current).first_line = (Current).last_line = \ 887 YYRHSLOC (Rhs, 0).last_line; \ 888 (Current).first_column = (Current).last_column = \ 889 YYRHSLOC (Rhs, 0).last_column; \ 890 } \ 891 while (0) 892 #endif 893 894 895 /* YY_LOCATION_PRINT -- Print the location on the stream. 896 This macro was not mandated originally: define only if we know 897 we won't break user code: when these are the locations we know. */ 898 899 #ifndef YY_LOCATION_PRINT 900 # if YYLTYPE_IS_TRIVIAL 901 # define YY_LOCATION_PRINT(File, Loc) \ 902 fprintf (File, "%d.%d-%d.%d", \ 903 (Loc).first_line, (Loc).first_column, \ 904 (Loc).last_line, (Loc).last_column) 905 # else 906 # define YY_LOCATION_PRINT(File, Loc) ((void) 0) 907 # endif 908 #endif 909 910 911 /* YYLEX -- calling `yylex' with the right arguments. */ 912 913 #ifdef YYLEX_PARAM 914 # define YYLEX yylex (&yylval, &yylloc, YYLEX_PARAM) 915 #else 916 # define YYLEX yylex (&yylval, &yylloc, lexer) 917 #endif 918 919 /* Enable debugging if requested. */ 920 #if YYDEBUG 921 922 # ifndef YYFPRINTF 923 # include <stdio.h> /* INFRINGES ON USER NAME SPACE */ 924 # define YYFPRINTF fprintf 925 # endif 926 927 # define YYDPRINTF(Args) \ 928 do { \ 929 if (yydebug) \ 930 YYFPRINTF Args; \ 931 } while (0) 932 933 # define YY_SYMBOL_PRINT(Title, Type, Value, Location) \ 934 do { \ 935 if (yydebug) \ 936 { \ 937 YYFPRINTF (stderr, "%s ", Title); \ 938 yysymprint (stderr, \ 939 Type, Value, Location); \ 940 YYFPRINTF (stderr, "\n"); \ 941 } \ 942 } while (0) 943 944 /*------------------------------------------------------------------. 945 | yy_stack_print -- Print the state stack from its BOTTOM up to its | 946 | TOP (included). | 947 `------------------------------------------------------------------*/ 948 949 #if defined (__STDC__) || defined (__cplusplus) 950 static void 951 yy_stack_print (short int *bottom, short int *top) 952 #else 953 static void 954 yy_stack_print (bottom, top) 955 short int *bottom; 956 short int *top; 957 #endif 958 { 959 YYFPRINTF (stderr, "Stack now"); 960 for (/* Nothing. */; bottom <= top; ++bottom) 961 YYFPRINTF (stderr, " %d", *bottom); 962 YYFPRINTF (stderr, "\n"); 963 } 964 965 # define YY_STACK_PRINT(Bottom, Top) \ 966 do { \ 967 if (yydebug) \ 968 yy_stack_print ((Bottom), (Top)); \ 969 } while (0) 970 971 972 /*------------------------------------------------. 973 | Report that the YYRULE is going to be reduced. | 974 `------------------------------------------------*/ 975 976 #if defined (__STDC__) || defined (__cplusplus) 977 static void 978 yy_reduce_print (int yyrule) 979 #else 980 static void 981 yy_reduce_print (yyrule) 982 int yyrule; 983 #endif 984 { 985 int yyi; 986 unsigned long int yylno = yyrline[yyrule]; 987 YYFPRINTF (stderr, "Reducing stack by rule %d (line %lu), ", 988 yyrule - 1, yylno); 989 /* Print the symbols being reduced, and their result. */ 990 for (yyi = yyprhs[yyrule]; 0 <= yyrhs[yyi]; yyi++) 991 YYFPRINTF (stderr, "%s ", yytname[yyrhs[yyi]]); 992 YYFPRINTF (stderr, "-> %s\n", yytname[yyr1[yyrule]]); 993 } 994 995 # define YY_REDUCE_PRINT(Rule) \ 996 do { \ 997 if (yydebug) \ 998 yy_reduce_print (Rule); \ 999 } while (0) 1000 1001 /* Nonzero means print parse trace. It is left uninitialized so that 1002 multiple parsers can coexist. */ 1003 int yydebug; 1004 #else /* !YYDEBUG */ 1005 # define YYDPRINTF(Args) 1006 # define YY_SYMBOL_PRINT(Title, Type, Value, Location) 1007 # define YY_STACK_PRINT(Bottom, Top) 1008 # define YY_REDUCE_PRINT(Rule) 1009 #endif /* !YYDEBUG */ 1010 1011 1012 /* YYINITDEPTH -- initial size of the parser's stacks. */ 1013 #ifndef YYINITDEPTH 1014 # define YYINITDEPTH 200 1015 #endif 1016 1017 /* YYMAXDEPTH -- maximum size the stacks can grow to (effective only 1018 if the built-in stack extension method is used). 1019 1020 Do not make this value too large; the results are undefined if 1021 YYSTACK_ALLOC_MAXIMUM < YYSTACK_BYTES (YYMAXDEPTH) 1022 evaluated with infinite-precision integer arithmetic. */ 1023 1024 #ifndef YYMAXDEPTH 1025 # define YYMAXDEPTH 10000 1026 #endif 1027 1028 1029 1031 #if YYERROR_VERBOSE 1032 1033 # ifndef yystrlen 1034 # if defined (__GLIBC__) && defined (_STRING_H) 1035 # define yystrlen strlen 1036 # else 1037 /* Return the length of YYSTR. */ 1038 static YYSIZE_T 1039 # if defined (__STDC__) || defined (__cplusplus) 1040 yystrlen (const char *yystr) 1041 # else 1042 yystrlen (yystr) 1043 const char *yystr; 1044 # endif 1045 { 1046 const char *yys = yystr; 1047 1048 while (*yys++ != '\0') 1049 continue; 1050 1051 return yys - yystr - 1; 1052 } 1053 # endif 1054 # endif 1055 1056 # ifndef yystpcpy 1057 # if defined (__GLIBC__) && defined (_STRING_H) && defined (_GNU_SOURCE) 1058 # define yystpcpy stpcpy 1059 # else 1060 /* Copy YYSRC to YYDEST, returning the address of the terminating '\0' in 1061 YYDEST. */ 1062 static char * 1063 # if defined (__STDC__) || defined (__cplusplus) 1064 yystpcpy (char *yydest, const char *yysrc) 1065 # else 1066 yystpcpy (yydest, yysrc) 1067 char *yydest; 1068 const char *yysrc; 1069 # endif 1070 { 1071 char *yyd = yydest; 1072 const char *yys = yysrc; 1073 1074 while ((*yyd++ = *yys++) != '\0') 1075 continue; 1076 1077 return yyd - 1; 1078 } 1079 # endif 1080 # endif 1081 1082 # ifndef yytnamerr 1083 /* Copy to YYRES the contents of YYSTR after stripping away unnecessary 1084 quotes and backslashes, so that it's suitable for yyerror. The 1085 heuristic is that double-quoting is unnecessary unless the string 1086 contains an apostrophe, a comma, or backslash (other than 1087 backslash-backslash). YYSTR is taken from yytname. If YYRES is 1088 null, do not copy; instead, return the length of what the result 1089 would have been. */ 1090 static YYSIZE_T 1091 yytnamerr (char *yyres, const char *yystr) 1092 { 1093 if (*yystr == '"') 1094 { 1095 size_t yyn = 0; 1096 char const *yyp = yystr; 1097 1098 for (;;) 1099 switch (*++yyp) 1100 { 1101 case '\'': 1102 case ',': 1103 goto do_not_strip_quotes; 1104 1105 case '\\': 1106 if (*++yyp != '\\') 1107 goto do_not_strip_quotes; 1108 /* Fall through. */ 1109 default: 1110 if (yyres) 1111 yyres[yyn] = *yyp; 1112 yyn++; 1113 break; 1114 1115 case '"': 1116 if (yyres) 1117 yyres[yyn] = '\0'; 1118 return yyn; 1119 } 1120 do_not_strip_quotes: ; 1121 } 1122 1123 if (! yyres) 1124 return yystrlen (yystr); 1125 1126 return yystpcpy (yyres, yystr) - yyres; 1127 } 1128 # endif 1129 1130 #endif /* YYERROR_VERBOSE */ 1131 1132 1133 1135 #if YYDEBUG 1136 /*--------------------------------. 1137 | Print this symbol on YYOUTPUT. | 1138 `--------------------------------*/ 1139 1140 #if defined (__STDC__) || defined (__cplusplus) 1141 static void 1142 yysymprint (FILE *yyoutput, int yytype, YYSTYPE *yyvaluep, YYLTYPE *yylocationp) 1143 #else 1144 static void 1145 yysymprint (yyoutput, yytype, yyvaluep, yylocationp) 1146 FILE *yyoutput; 1147 int yytype; 1148 YYSTYPE *yyvaluep; 1149 YYLTYPE *yylocationp; 1150 #endif 1151 { 1152 /* Pacify ``unused variable'' warnings. */ 1153 (void) yyvaluep; 1154 (void) yylocationp; 1155 1156 if (yytype < YYNTOKENS) 1157 YYFPRINTF (yyoutput, "token %s (", yytname[yytype]); 1158 else 1159 YYFPRINTF (yyoutput, "nterm %s (", yytname[yytype]); 1160 1161 YY_LOCATION_PRINT (yyoutput, *yylocationp); 1162 YYFPRINTF (yyoutput, ": "); 1163 1164 # ifdef YYPRINT 1165 if (yytype < YYNTOKENS) 1166 YYPRINT (yyoutput, yytoknum[yytype], *yyvaluep); 1167 # endif 1168 switch (yytype) 1169 { 1170 default: 1171 break; 1172 } 1173 YYFPRINTF (yyoutput, ")"); 1174 } 1175 1176 #endif /* ! YYDEBUG */ 1177 /*-----------------------------------------------. 1178 | Release the memory associated to this symbol. | 1179 `-----------------------------------------------*/ 1180 1181 #if defined (__STDC__) || defined (__cplusplus) 1182 static void 1183 yydestruct (const char *yymsg, int yytype, YYSTYPE *yyvaluep, YYLTYPE *yylocationp) 1184 #else 1185 static void 1186 yydestruct (yymsg, yytype, yyvaluep, yylocationp) 1187 const char *yymsg; 1188 int yytype; 1189 YYSTYPE *yyvaluep; 1190 YYLTYPE *yylocationp; 1191 #endif 1192 { 1193 /* Pacify ``unused variable'' warnings. */ 1194 (void) yyvaluep; 1195 (void) yylocationp; 1196 1197 if (!yymsg) 1198 yymsg = "Deleting"; 1199 YY_SYMBOL_PRINT (yymsg, yytype, yyvaluep, yylocationp); 1200 1201 switch (yytype) 1202 { 1203 case 3: /* "\"identifier\"" */ 1204 { delete (yyvaluep->m_str); }; 1205 break; 1206 case 4: /* "\"string\"" */ 1207 { delete (yyvaluep->m_str); }; 1208 break; 1209 case 5: /* "\"integer\"" */ 1210 { delete (yyvaluep->m_int); }; 1211 break; 1212 case 6: /* "\"section name\"" */ 1213 { delete (yyvaluep->m_str); }; 1214 break; 1215 case 7: /* "\"source name\"" */ 1216 { delete (yyvaluep->m_str); }; 1217 break; 1218 case 8: /* "\"binary object\"" */ 1219 { delete (yyvaluep->m_blob); }; 1220 break; 1221 case 36: /* "\"integer size\"" */ 1222 { delete (yyvaluep->m_int); }; 1223 break; 1224 1225 default: 1226 break; 1227 } 1228 } 1229 1230 1232 /* Prevent warnings from -Wmissing-prototypes. */ 1233 1234 #ifdef YYPARSE_PARAM 1235 # if defined (__STDC__) || defined (__cplusplus) 1236 int yyparse (void *YYPARSE_PARAM); 1237 # else 1238 int yyparse (); 1239 # endif 1240 #else /* ! YYPARSE_PARAM */ 1241 #if defined (__STDC__) || defined (__cplusplus) 1242 int yyparse (ElftosbLexer * lexer, CommandFileASTNode ** resultAST); 1243 #else 1244 int yyparse (); 1245 #endif 1246 #endif /* ! YYPARSE_PARAM */ 1247 1248 1249 1250 1251 1252 1253 /*----------. 1254 | yyparse. | 1255 `----------*/ 1256 1257 #ifdef YYPARSE_PARAM 1258 # if defined (__STDC__) || defined (__cplusplus) 1259 int yyparse (void *YYPARSE_PARAM) 1260 # else 1261 int yyparse (YYPARSE_PARAM) 1262 void *YYPARSE_PARAM; 1263 # endif 1264 #else /* ! YYPARSE_PARAM */ 1265 #if defined (__STDC__) || defined (__cplusplus) 1266 int 1267 yyparse (ElftosbLexer * lexer, CommandFileASTNode ** resultAST) 1268 #else 1269 int 1270 yyparse (lexer, resultAST) 1271 ElftosbLexer * lexer; 1272 CommandFileASTNode ** resultAST; 1273 #endif 1274 #endif 1275 { 1276 /* The look-ahead symbol. */ 1277 int yychar; 1278 1279 /* The semantic value of the look-ahead symbol. */ 1280 YYSTYPE yylval; 1281 1282 /* Number of syntax errors so far. */ 1283 int yynerrs; 1284 /* Location data for the look-ahead symbol. */ 1285 YYLTYPE yylloc; 1286 1287 int yystate; 1288 int yyn; 1289 int yyresult; 1290 /* Number of tokens to shift before error messages enabled. */ 1291 int yyerrstatus; 1292 /* Look-ahead token as an internal (translated) token number. */ 1293 int yytoken = 0; 1294 1295 /* Three stacks and their tools: 1296 `yyss': related to states, 1297 `yyvs': related to semantic values, 1298 `yyls': related to locations. 1299 1300 Refer to the stacks thru separate pointers, to allow yyoverflow 1301 to reallocate them elsewhere. */ 1302 1303 /* The state stack. */ 1304 short int yyssa[YYINITDEPTH]; 1305 short int *yyss = yyssa; 1306 short int *yyssp; 1307 1308 /* The semantic value stack. */ 1309 YYSTYPE yyvsa[YYINITDEPTH]; 1310 YYSTYPE *yyvs = yyvsa; 1311 YYSTYPE *yyvsp; 1312 1313 /* The location stack. */ 1314 YYLTYPE yylsa[YYINITDEPTH]; 1315 YYLTYPE *yyls = yylsa; 1316 YYLTYPE *yylsp; 1317 /* The locations where the error started and ended. */ 1318 YYLTYPE yyerror_range[2]; 1319 1320 #define YYPOPSTACK (yyvsp--, yyssp--, yylsp--) 1321 1322 YYSIZE_T yystacksize = YYINITDEPTH; 1323 1324 /* The variables used to return semantic value and location from the 1325 action routines. */ 1326 YYSTYPE yyval; 1327 YYLTYPE yyloc; 1328 1329 /* When reducing, the number of symbols on the RHS of the reduced 1330 rule. */ 1331 int yylen; 1332 1333 YYDPRINTF ((stderr, "Starting parse\n")); 1334 1335 yystate = 0; 1336 yyerrstatus = 0; 1337 yynerrs = 0; 1338 yychar = YYEMPTY; /* Cause a token to be read. */ 1339 1340 /* Initialize stack pointers. 1341 Waste one element of value and location stack 1342 so that they stay on the same level as the state stack. 1343 The wasted elements are never initialized. */ 1344 1345 yyssp = yyss; 1346 yyvsp = yyvs; 1347 yylsp = yyls; 1348 #if YYLTYPE_IS_TRIVIAL 1349 /* Initialize the default location before parsing starts. */ 1350 yylloc.first_line = yylloc.last_line = 1; 1351 yylloc.first_column = yylloc.last_column = 0; 1352 #endif 1353 1354 goto yysetstate; 1355 1356 /*------------------------------------------------------------. 1357 | yynewstate -- Push a new state, which is found in yystate. | 1358 `------------------------------------------------------------*/ 1359 yynewstate: 1360 /* In all cases, when you get here, the value and location stacks 1361 have just been pushed. so pushing a state here evens the stacks. 1362 */ 1363 yyssp++; 1364 1365 yysetstate: 1366 *yyssp = yystate; 1367 1368 if (yyss + yystacksize - 1 <= yyssp) 1369 { 1370 /* Get the current used size of the three stacks, in elements. */ 1371 YYSIZE_T yysize = yyssp - yyss + 1; 1372 1373 #ifdef yyoverflow 1374 { 1375 /* Give user a chance to reallocate the stack. Use copies of 1376 these so that the &'s don't force the real ones into 1377 memory. */ 1378 YYSTYPE *yyvs1 = yyvs; 1379 short int *yyss1 = yyss; 1380 YYLTYPE *yyls1 = yyls; 1381 1382 /* Each stack pointer address is followed by the size of the 1383 data in use in that stack, in bytes. This used to be a 1384 conditional around just the two extra args, but that might 1385 be undefined if yyoverflow is a macro. */ 1386 yyoverflow (YY_("memory exhausted"), 1387 &yyss1, yysize * sizeof (*yyssp), 1388 &yyvs1, yysize * sizeof (*yyvsp), 1389 &yyls1, yysize * sizeof (*yylsp), 1390 &yystacksize); 1391 yyls = yyls1; 1392 yyss = yyss1; 1393 yyvs = yyvs1; 1394 } 1395 #else /* no yyoverflow */ 1396 # ifndef YYSTACK_RELOCATE 1397 goto yyexhaustedlab; 1398 # else 1399 /* Extend the stack our own way. */ 1400 if (YYMAXDEPTH <= yystacksize) 1401 goto yyexhaustedlab; 1402 yystacksize *= 2; 1403 if (YYMAXDEPTH < yystacksize) 1404 yystacksize = YYMAXDEPTH; 1405 1406 { 1407 short int *yyss1 = yyss; 1408 union yyalloc *yyptr = 1409 (union yyalloc *) YYSTACK_ALLOC (YYSTACK_BYTES (yystacksize)); 1410 if (! yyptr) 1411 goto yyexhaustedlab; 1412 YYSTACK_RELOCATE (yyss); 1413 YYSTACK_RELOCATE (yyvs); 1414 YYSTACK_RELOCATE (yyls); 1415 # undef YYSTACK_RELOCATE 1416 if (yyss1 != yyssa) 1417 YYSTACK_FREE (yyss1); 1418 } 1419 # endif 1420 #endif /* no yyoverflow */ 1421 1422 yyssp = yyss + yysize - 1; 1423 yyvsp = yyvs + yysize - 1; 1424 yylsp = yyls + yysize - 1; 1425 1426 YYDPRINTF ((stderr, "Stack size increased to %lu\n", 1427 (unsigned long int) yystacksize)); 1428 1429 if (yyss + yystacksize - 1 <= yyssp) 1430 YYABORT; 1431 } 1432 1433 YYDPRINTF ((stderr, "Entering state %d\n", yystate)); 1434 1435 goto yybackup; 1436 1437 /*-----------. 1438 | yybackup. | 1439 `-----------*/ 1440 yybackup: 1441 1442 /* Do appropriate processing given the current state. */ 1443 /* Read a look-ahead token if we need one and don't already have one. */ 1444 /* yyresume: */ 1445 1446 /* First try to decide what to do without reference to look-ahead token. */ 1447 1448 yyn = yypact[yystate]; 1449 if (yyn == YYPACT_NINF) 1450 goto yydefault; 1451 1452 /* Not known => get a look-ahead token if don't already have one. */ 1453 1454 /* YYCHAR is either YYEMPTY or YYEOF or a valid look-ahead symbol. */ 1455 if (yychar == YYEMPTY) 1456 { 1457 YYDPRINTF ((stderr, "Reading a token: ")); 1458 yychar = YYLEX; 1459 } 1460 1461 if (yychar <= YYEOF) 1462 { 1463 yychar = yytoken = YYEOF; 1464 YYDPRINTF ((stderr, "Now at end of input.\n")); 1465 } 1466 else 1467 { 1468 yytoken = YYTRANSLATE (yychar); 1469 YY_SYMBOL_PRINT ("Next token is", yytoken, &yylval, &yylloc); 1470 } 1471 1472 /* If the proper action on seeing token YYTOKEN is to reduce or to 1473 detect an error, take that action. */ 1474 yyn += yytoken; 1475 if (yyn < 0 || YYLAST < yyn || yycheck[yyn] != yytoken) 1476 goto yydefault; 1477 yyn = yytable[yyn]; 1478 if (yyn <= 0) 1479 { 1480 if (yyn == 0 || yyn == YYTABLE_NINF) 1481 goto yyerrlab; 1482 yyn = -yyn; 1483 goto yyreduce; 1484 } 1485 1486 if (yyn == YYFINAL) 1487 YYACCEPT; 1488 1489 /* Shift the look-ahead token. */ 1490 YY_SYMBOL_PRINT ("Shifting", yytoken, &yylval, &yylloc); 1491 1492 /* Discard the token being shifted unless it is eof. */ 1493 if (yychar != YYEOF) 1494 yychar = YYEMPTY; 1495 1496 *++yyvsp = yylval; 1497 *++yylsp = yylloc; 1498 1499 /* Count tokens shifted since error; after three, turn off error 1500 status. */ 1501 if (yyerrstatus) 1502 yyerrstatus--; 1503 1504 yystate = yyn; 1505 goto yynewstate; 1506 1507 1508 /*-----------------------------------------------------------. 1509 | yydefault -- do the default action for the current state. | 1510 `-----------------------------------------------------------*/ 1511 yydefault: 1512 yyn = yydefact[yystate]; 1513 if (yyn == 0) 1514 goto yyerrlab; 1515 goto yyreduce; 1516 1517 1518 /*-----------------------------. 1519 | yyreduce -- Do a reduction. | 1520 `-----------------------------*/ 1521 yyreduce: 1522 /* yyn is the number of a rule to reduce with. */ 1523 yylen = yyr2[yyn]; 1524 1525 /* If YYLEN is nonzero, implement the default value of the action: 1526 `$$ = $1'. 1527 1528 Otherwise, the following line sets YYVAL to garbage. 1529 This behavior is undocumented and Bison 1530 users should not rely upon it. Assigning to YYVAL 1531 unconditionally makes the parser a bit smaller, and it avoids a 1532 GCC warning that YYVAL may be used uninitialized. */ 1533 yyval = yyvsp[1-yylen]; 1534 1535 /* Default location. */ 1536 YYLLOC_DEFAULT (yyloc, yylsp - yylen, yylen); 1537 YY_REDUCE_PRINT (yyn); 1538 switch (yyn) 1539 { 1540 case 2: 1541 { 1542 CommandFileASTNode * commandFile = new CommandFileASTNode(); 1543 commandFile->setBlocks(dynamic_cast<ListASTNode*>((yyvsp[-1].m_ast))); 1544 commandFile->setSections(dynamic_cast<ListASTNode*>((yyvsp[0].m_ast))); 1545 commandFile->setLocation((yylsp[-1]), (yylsp[0])); 1546 *resultAST = commandFile; 1547 ;} 1548 break; 1549 1550 case 3: 1551 { 1552 ListASTNode * list = new ListASTNode(); 1553 list->appendNode((yyvsp[0].m_ast)); 1554 (yyval.m_ast) = list; 1555 ;} 1556 break; 1557 1558 case 4: 1559 { 1560 dynamic_cast<ListASTNode*>((yyvsp[-1].m_ast))->appendNode((yyvsp[0].m_ast)); 1561 (yyval.m_ast) = (yyvsp[-1].m_ast); 1562 ;} 1563 break; 1564 1565 case 5: 1566 { (yyval.m_ast) = (yyvsp[0].m_ast); ;} 1567 break; 1568 1569 case 6: 1570 { (yyval.m_ast) = (yyvsp[0].m_ast); ;} 1571 break; 1572 1573 case 7: 1574 { (yyval.m_ast) = (yyvsp[0].m_ast); ;} 1575 break; 1576 1577 case 8: 1578 { 1579 (yyval.m_ast) = new OptionsBlockASTNode(dynamic_cast<ListASTNode *>((yyvsp[-1].m_ast))); 1580 ;} 1581 break; 1582 1583 case 9: 1584 { 1585 (yyval.m_ast) = new ConstantsBlockASTNode(dynamic_cast<ListASTNode *>((yyvsp[-1].m_ast))); 1586 ;} 1587 break; 1588 1589 case 10: 1590 { 1591 ListASTNode * list = new ListASTNode(); 1592 list->appendNode((yyvsp[0].m_ast)); 1593 (yyval.m_ast) = list; 1594 ;} 1595 break; 1596 1597 case 11: 1598 { 1599 dynamic_cast<ListASTNode*>((yyvsp[-1].m_ast))->appendNode((yyvsp[0].m_ast)); 1600 (yyval.m_ast) = (yyvsp[-1].m_ast); 1601 ;} 1602 break; 1603 1604 case 12: 1605 { (yyval.m_ast) = (yyvsp[-1].m_ast); ;} 1606 break; 1607 1608 case 13: 1609 { (yyval.m_ast) = NULL; ;} 1610 break; 1611 1612 case 14: 1613 { 1614 (yyval.m_ast) = new AssignmentASTNode((yyvsp[-2].m_str), (yyvsp[0].m_ast)); 1615 (yyval.m_ast)->setLocation((yylsp[-2]), (yylsp[0])); 1616 ;} 1617 break; 1618 1619 case 15: 1620 { 1621 (yyval.m_ast) = new SourcesBlockASTNode(dynamic_cast<ListASTNode *>((yyvsp[-1].m_ast))); 1622 ;} 1623 break; 1624 1625 case 16: 1626 { 1627 ListASTNode * list = new ListASTNode(); 1628 list->appendNode((yyvsp[0].m_ast)); 1629 (yyval.m_ast) = list; 1630 ;} 1631 break; 1632 1633 case 17: 1634 { 1635 dynamic_cast<ListASTNode*>((yyvsp[-1].m_ast))->appendNode((yyvsp[0].m_ast)); 1636 (yyval.m_ast) = (yyvsp[-1].m_ast); 1637 ;} 1638 break; 1639 1640 case 18: 1641 { 1642 // tell the lexer that this is the name of a source file 1643 SourceDefASTNode * node = dynamic_cast<SourceDefASTNode*>((yyvsp[-2].m_ast)); 1644 if ((yyvsp[-1].m_ast)) 1645 { 1646 node->setAttributes(dynamic_cast<ListASTNode*>((yyvsp[-1].m_ast))); 1647 } 1648 node->setLocation(node->getLocation(), (yylsp[0])); 1649 lexer->addSourceName(node->getName()); 1650 (yyval.m_ast) = (yyvsp[-2].m_ast); 1651 ;} 1652 break; 1653 1654 case 19: 1655 { (yyval.m_ast) = NULL; ;} 1656 break; 1657 1658 case 20: 1659 { 1660 (yyval.m_ast) = new PathSourceDefASTNode((yyvsp[-2].m_str), (yyvsp[0].m_str)); 1661 (yyval.m_ast)->setLocation((yylsp[-2]), (yylsp[0])); 1662 ;} 1663 break; 1664 1665 case 21: 1666 { 1667 (yyval.m_ast) = new ExternSourceDefASTNode((yyvsp[-5].m_str), dynamic_cast<ExprASTNode*>((yyvsp[-1].m_ast))); 1668 (yyval.m_ast)->setLocation((yylsp[-5]), (yylsp[0])); 1669 ;} 1670 break; 1671 1672 case 22: 1673 { (yyval.m_ast) = (yyvsp[-1].m_ast); ;} 1674 break; 1675 1676 case 23: 1677 { (yyval.m_ast) = NULL; ;} 1678 break; 1679 1680 case 24: 1681 { 1682 ListASTNode * list = new ListASTNode(); 1683 list->appendNode((yyvsp[0].m_ast)); 1684 (yyval.m_ast) = list; 1685 ;} 1686 break; 1687 1688 case 25: 1689 { 1690 dynamic_cast<ListASTNode*>((yyvsp[-2].m_ast))->appendNode((yyvsp[0].m_ast)); 1691 (yyval.m_ast) = (yyvsp[-2].m_ast); 1692 ;} 1693 break; 1694 1695 case 26: 1696 { 1697 (yyval.m_ast) = new AssignmentASTNode((yyvsp[-2].m_str), (yyvsp[0].m_ast)); 1698 (yyval.m_ast)->setLocation((yylsp[-2]), (yylsp[0])); 1699 ;} 1700 break; 1701 1702 case 27: 1703 { 1704 ListASTNode * list = new ListASTNode(); 1705 list->appendNode((yyvsp[0].m_ast)); 1706 (yyval.m_ast) = list; 1707 ;} 1708 break; 1709 1710 case 28: 1711 { 1712 dynamic_cast<ListASTNode*>((yyvsp[-1].m_ast))->appendNode((yyvsp[0].m_ast)); 1713 (yyval.m_ast) = (yyvsp[-1].m_ast); 1714 ;} 1715 break; 1716 1717 case 29: 1718 { 1719 SectionContentsASTNode * sectionNode = dynamic_cast<SectionContentsASTNode*>((yyvsp[0].m_ast)); 1720 if (sectionNode) 1721 { 1722 ExprASTNode * exprNode = dynamic_cast<ExprASTNode*>((yyvsp[-3].m_ast)); 1723 sectionNode->setSectionNumberExpr(exprNode); 1724 sectionNode->setOptions(dynamic_cast<ListASTNode*>((yyvsp[-2].m_ast))); 1725 sectionNode->setLocation((yylsp[-5]), sectionNode->getLocation()); 1726 } 1727 (yyval.m_ast) = (yyvsp[0].m_ast); 1728 ;} 1729 break; 1730 1731 case 30: 1732 { 1733 (yyval.m_ast) = (yyvsp[0].m_ast); 1734 ;} 1735 break; 1736 1737 case 31: 1738 { 1739 (yyval.m_ast) = NULL; 1740 ;} 1741 break; 1742 1743 case 32: 1744 { 1745 (yyval.m_ast) = (yyvsp[0].m_ast); 1746 ;} 1747 break; 1748 1749 case 33: 1750 { 1751 (yyval.m_ast) = NULL; 1752 ;} 1753 break; 1754 1755 case 34: 1756 { 1757 DataSectionContentsASTNode * dataSection = new DataSectionContentsASTNode((yyvsp[-1].m_ast)); 1758 dataSection->setLocation((yylsp[-2]), (yylsp[0])); 1759 (yyval.m_ast) = dataSection; 1760 ;} 1761 break; 1762 1763 case 35: 1764 { 1765 ListASTNode * listNode = dynamic_cast<ListASTNode*>((yyvsp[-1].m_ast)); 1766 (yyval.m_ast) = new BootableSectionContentsASTNode(listNode); 1767 (yyval.m_ast)->setLocation((yylsp[-2]), (yylsp[0])); 1768 ;} 1769 break; 1770 1771 case 36: 1772 { 1773 ListASTNode * list = new ListASTNode(); 1774 list->appendNode((yyvsp[0].m_ast)); 1775 (yyval.m_ast) = list; 1776 ;} 1777 break; 1778 1779 case 37: 1780 { 1781 dynamic_cast<ListASTNode*>((yyvsp[-1].m_ast))->appendNode((yyvsp[0].m_ast)); 1782 (yyval.m_ast) = (yyvsp[-1].m_ast); 1783 ;} 1784 break; 1785 1786 case 38: 1787 { (yyval.m_ast) = (yyvsp[-1].m_ast); ;} 1788 break; 1789 1790 case 39: 1791 { (yyval.m_ast) = (yyvsp[0].m_ast); ;} 1792 break; 1793 1794 case 40: 1795 { (yyval.m_ast) = (yyvsp[0].m_ast); ;} 1796 break; 1797 1798 case 41: 1799 { (yyval.m_ast) = NULL; ;} 1800 break; 1801 1802 case 42: 1803 { 1804 ListASTNode * list = new ListASTNode(); 1805 list->appendNode((yyvsp[0].m_ast)); 1806 (yyval.m_ast) = list; 1807 ;} 1808 break; 1809 1810 case 43: 1811 { 1812 dynamic_cast<ListASTNode*>((yyvsp[-1].m_ast))->appendNode((yyvsp[0].m_ast)); 1813 (yyval.m_ast) = (yyvsp[-1].m_ast); 1814 ;} 1815 break; 1816 1817 case 44: 1818 { (yyval.m_ast) = (yyvsp[-1].m_ast); ;} 1819 break; 1820 1821 case 45: 1822 { (yyval.m_ast) = (yyvsp[0].m_ast); ;} 1823 break; 1824 1825 case 46: 1826 { (yyval.m_ast) = NULL; ;} 1827 break; 1828 1829 case 47: 1830 { (yyval.m_ast) = (yyvsp[0].m_ast); ;} 1831 break; 1832 1833 case 48: 1834 { (yyval.m_ast) = (yyvsp[0].m_ast); ;} 1835 break; 1836 1837 case 49: 1838 { (yyval.m_ast) = (yyvsp[0].m_ast); ;} 1839 break; 1840 1841 case 50: 1842 { (yyval.m_ast) = (yyvsp[0].m_ast); ;} 1843 break; 1844 1845 case 51: 1846 { 1847 LoadStatementASTNode * stmt = new LoadStatementASTNode(); 1848 stmt->setData((yyvsp[-1].m_ast)); 1849 stmt->setTarget((yyvsp[0].m_ast)); 1850 // set dcd load flag if the "dcd" keyword was present. 1851 if ((yyvsp[-2].m_num)) 1852 { 1853 stmt->setDCDLoad(true); 1854 } 1855 // set char locations for the statement 1856 if ((yyvsp[0].m_ast)) 1857 { 1858 stmt->setLocation((yylsp[-3]), (yylsp[0])); 1859 } 1860 else 1861 { 1862 stmt->setLocation((yylsp[-3]), (yylsp[-1])); 1863 } 1864 (yyval.m_ast) = stmt; 1865 ;} 1866 break; 1867 1868 case 52: 1869 { 1870 if (!elftosb::g_enableHABSupport) 1871 { 1872 yyerror(&yylloc, lexer, resultAST, "HAB features not supported with the selected family"); 1873 YYABORT; 1874 } 1875 1876 (yyval.m_num) = 1; 1877 ;} 1878 break; 1879 1880 case 53: 1881 { (yyval.m_num) = 0; ;} 1882 break; 1883 1884 case 54: 1885 { 1886 (yyval.m_ast) = (yyvsp[0].m_ast); 1887 ;} 1888 break; 1889 1890 case 55: 1891 { 1892 (yyval.m_ast) = new StringConstASTNode((yyvsp[0].m_str)); 1893 (yyval.m_ast)->setLocation((yylsp[0])); 1894 ;} 1895 break; 1896 1897 case 56: 1898 { 1899 (yyval.m_ast) = new SourceASTNode((yyvsp[0].m_str)); 1900 (yyval.m_ast)->setLocation((yylsp[0])); 1901 ;} 1902 break; 1903 1904 case 57: 1905 { 1906 (yyval.m_ast) = new SectionMatchListASTNode(dynamic_cast<ListASTNode*>((yyvsp[0].m_ast))); 1907 (yyval.m_ast)->setLocation((yylsp[0])); 1908 ;} 1909 break; 1910 1911 case 58: 1912 { 1913 (yyval.m_ast) = new SectionMatchListASTNode(dynamic_cast<ListASTNode*>((yyvsp[-2].m_ast)), (yyvsp[0].m_str)); 1914 (yyval.m_ast)->setLocation((yylsp[-2]), (yylsp[0])); 1915 ;} 1916 break; 1917 1918 case 59: 1919 { 1920 (yyval.m_ast) = new SectionMatchListASTNode(dynamic_cast<ListASTNode*>((yyvsp[-1].m_ast)), (yyvsp[-3].m_str)); 1921 (yyval.m_ast)->setLocation((yylsp[-3]), (yylsp[0])); 1922 ;} 1923 break; 1924 1925 case 60: 1926 { 1927 (yyval.m_ast) = new BlobConstASTNode((yyvsp[0].m_blob)); 1928 (yyval.m_ast)->setLocation((yylsp[0])); 1929 ;} 1930 break; 1931 1932 case 61: 1933 { 1934 ;} 1935 break; 1936 1937 case 62: 1938 { 1939 ListASTNode * list = new ListASTNode(); 1940 list->appendNode((yyvsp[0].m_ast)); 1941 (yyval.m_ast) = list; 1942 ;} 1943 break; 1944 1945 case 63: 1946 { 1947 dynamic_cast<ListASTNode*>((yyvsp[-2].m_ast))->appendNode((yyvsp[0].m_ast)); 1948 (yyval.m_ast) = (yyvsp[-2].m_ast); 1949 ;} 1950 break; 1951 1952 case 64: 1953 { 1954 (yyval.m_ast) = new SectionASTNode((yyvsp[0].m_str), SectionASTNode::kInclude); 1955 (yyval.m_ast)->setLocation((yylsp[0])); 1956 ;} 1957 break; 1958 1959 case 65: 1960 { 1961 (yyval.m_ast) = new SectionASTNode((yyvsp[0].m_str), SectionASTNode::kExclude); 1962 (yyval.m_ast)->setLocation((yylsp[-1]), (yylsp[0])); 1963 ;} 1964 break; 1965 1966 case 66: 1967 { 1968 (yyval.m_ast) = (yyvsp[0].m_ast); 1969 ;} 1970 break; 1971 1972 case 67: 1973 { 1974 (yyval.m_ast) = new NaturalLocationASTNode(); 1975 // $$->setLocation(); 1976 ;} 1977 break; 1978 1979 case 68: 1980 { 1981 (yyval.m_ast) = new NaturalLocationASTNode(); 1982 (yyval.m_ast)->setLocation((yylsp[0])); 1983 ;} 1984 break; 1985 1986 case 69: 1987 { 1988 (yyval.m_ast) = (yyvsp[0].m_ast); 1989 ;} 1990 break; 1991 1992 case 70: 1993 { 1994 IVTConstASTNode * ivt = new IVTConstASTNode(); 1995 if ((yyvsp[-1].m_ast)) 1996 { 1997 ivt->setFieldAssignments(dynamic_cast<ListASTNode*>((yyvsp[-1].m_ast))); 1998 } 1999 ivt->setLocation((yylsp[-3]), (yylsp[0])); 2000 (yyval.m_ast) = ivt; 2001 ;} 2002 break; 2003 2004 case 71: 2005 { (yyval.m_ast) = (yyvsp[0].m_ast); ;} 2006 break; 2007 2008 case 72: 2009 { (yyval.m_ast) = NULL; ;} 2010 break; 2011 2012 case 73: 2013 { 2014 CallStatementASTNode * stmt = new CallStatementASTNode(); 2015 switch ((yyvsp[-2].m_num)) 2016 { 2017 case 1: 2018 stmt->setCallType(CallStatementASTNode::kCallType); 2019 break; 2020 case 2: 2021 stmt->setCallType(CallStatementASTNode::kJumpType); 2022 break; 2023 default: 2024 yyerror(&yylloc, lexer, resultAST, "invalid call_or_jump value"); 2025 YYABORT; 2026 break; 2027 } 2028 stmt->setTarget((yyvsp[-1].m_ast)); 2029 stmt->setArgument((yyvsp[0].m_ast)); 2030 stmt->setIsHAB(false); 2031 if ((yyvsp[0].m_ast)) 2032 { 2033 stmt->setLocation((yylsp[-2]), (yylsp[0])); 2034 } 2035 else 2036 { 2037 stmt->setLocation((yylsp[-2]), (yylsp[-1])); 2038 } 2039 (yyval.m_ast) = stmt; 2040 ;} 2041 break; 2042 2043 case 74: 2044 { 2045 if (!elftosb::g_enableHABSupport) 2046 { 2047 yyerror(&yylloc, lexer, resultAST, "HAB features not supported with the selected family"); 2048 YYABORT; 2049 } 2050 2051 CallStatementASTNode * stmt = new CallStatementASTNode(); 2052 switch ((yyvsp[-2].m_num)) 2053 { 2054 case 1: 2055 stmt->setCallType(CallStatementASTNode::kCallType); 2056 break; 2057 case 2: 2058 stmt->setCallType(CallStatementASTNode::kJumpType); 2059 break; 2060 default: 2061 yyerror(&yylloc, lexer, resultAST, "invalid call_or_jump value"); 2062 YYABORT; 2063 break; 2064 } 2065 stmt->setTarget((yyvsp[-1].m_ast)); 2066 stmt->setArgument((yyvsp[0].m_ast)); 2067 stmt->setIsHAB(true); 2068 if ((yyvsp[0].m_ast)) 2069 { 2070 stmt->setLocation((yylsp[-3]), (yylsp[0])); 2071 } 2072 else 2073 { 2074 stmt->setLocation((yylsp[-3]), (yylsp[-1])); 2075 } 2076 (yyval.m_ast) = stmt; 2077 ;} 2078 break; 2079 2080 case 75: 2081 { (yyval.m_num) = 1; ;} 2082 break; 2083 2084 case 76: 2085 { (yyval.m_num) = 2; ;} 2086 break; 2087 2088 case 77: 2089 { 2090 (yyval.m_ast) = new SymbolASTNode(NULL, (yyvsp[0].m_str)); 2091 (yyval.m_ast)->setLocation((yylsp[0])); 2092 ;} 2093 break; 2094 2095 case 78: 2096 { 2097 (yyval.m_ast) = new AddressRangeASTNode((yyvsp[0].m_ast), NULL); 2098 (yyval.m_ast)->setLocation((yyvsp[0].m_ast)); 2099 ;} 2100 break; 2101 2102 case 79: 2103 { (yyval.m_ast) = (yyvsp[-1].m_ast); ;} 2104 break; 2105 2106 case 80: 2107 { (yyval.m_ast) = NULL; ;} 2108 break; 2109 2110 case 81: 2111 { (yyval.m_ast) = NULL; ;} 2112 break; 2113 2114 case 82: 2115 { 2116 (yyval.m_ast) = new FromStatementASTNode((yyvsp[-3].m_str), dynamic_cast<ListASTNode*>((yyvsp[-1].m_ast))); 2117 (yyval.m_ast)->setLocation((yylsp[-4]), (yylsp[0])); 2118 ;} 2119 break; 2120 2121 case 83: 2122 { 2123 (yyval.m_ast) = new ModeStatementASTNode(dynamic_cast<ExprASTNode*>((yyvsp[0].m_ast))); 2124 (yyval.m_ast)->setLocation((yylsp[-1]), (yylsp[0])); 2125 ;} 2126 break; 2127 2128 case 84: 2129 { 2130 (yyval.m_ast) = new MessageStatementASTNode(MessageStatementASTNode::kInfo, (yyvsp[0].m_str)); 2131 (yyval.m_ast)->setLocation((yylsp[-1]), (yylsp[0])); 2132 ;} 2133 break; 2134 2135 case 85: 2136 { 2137 (yyval.m_ast) = new MessageStatementASTNode(MessageStatementASTNode::kWarning, (yyvsp[0].m_str)); 2138 (yyval.m_ast)->setLocation((yylsp[-1]), (yylsp[0])); 2139 ;} 2140 break; 2141 2142 case 86: 2143 { 2144 (yyval.m_ast) = new MessageStatementASTNode(MessageStatementASTNode::kError, (yyvsp[0].m_str)); 2145 (yyval.m_ast)->setLocation((yylsp[-1]), (yylsp[0])); 2146 ;} 2147 break; 2148 2149 case 87: 2150 { 2151 IfStatementASTNode * ifStmt = new IfStatementASTNode(); 2152 ifStmt->setConditionExpr(dynamic_cast<ExprASTNode*>((yyvsp[-4].m_ast))); 2153 ifStmt->setIfStatements(dynamic_cast<ListASTNode*>((yyvsp[-2].m_ast))); 2154 ifStmt->setElseStatements(dynamic_cast<ListASTNode*>((yyvsp[0].m_ast))); 2155 ifStmt->setLocation((yylsp[-5]), (yylsp[0])); 2156 (yyval.m_ast) = ifStmt; 2157 ;} 2158 break; 2159 2160 case 88: 2161 { 2162 (yyval.m_ast) = (yyvsp[-1].m_ast); 2163 ;} 2164 break; 2165 2166 case 89: 2167 { 2168 ListASTNode * list = new ListASTNode(); 2169 list->appendNode((yyvsp[0].m_ast)); 2170 (yyval.m_ast) = list; 2171 (yyval.m_ast)->setLocation((yylsp[-1]), (yylsp[0])); 2172 ;} 2173 break; 2174 2175 case 90: 2176 { (yyval.m_ast) = NULL; ;} 2177 break; 2178 2179 case 91: 2180 { 2181 (yyval.m_ast) = new AddressRangeASTNode((yyvsp[0].m_ast), NULL); 2182 (yyval.m_ast)->setLocation((yyvsp[0].m_ast)); 2183 ;} 2184 break; 2185 2186 case 92: 2187 { 2188 (yyval.m_ast) = new AddressRangeASTNode((yyvsp[-2].m_ast), (yyvsp[0].m_ast)); 2189 (yyval.m_ast)->setLocation((yylsp[-2]), (yylsp[0])); 2190 ;} 2191 break; 2192 2193 case 93: 2194 { 2195 (yyval.m_ast) = (yyvsp[0].m_ast); 2196 ;} 2197 break; 2198 2199 case 94: 2200 { 2201 (yyval.m_ast) = new StringConstASTNode((yyvsp[0].m_str)); 2202 (yyval.m_ast)->setLocation((yylsp[0])); 2203 ;} 2204 break; 2205 2206 case 95: 2207 { 2208 (yyval.m_ast) = (yyvsp[0].m_ast); 2209 ;} 2210 break; 2211 2212 case 96: 2213 { 2214 ExprASTNode * left = dynamic_cast<ExprASTNode*>((yyvsp[-2].m_ast)); 2215 ExprASTNode * right = dynamic_cast<ExprASTNode*>((yyvsp[0].m_ast)); 2216 (yyval.m_ast) = new BinaryOpExprASTNode(left, BinaryOpExprASTNode::kLessThan, right); 2217 (yyval.m_ast)->setLocation((yylsp[-2]), (yylsp[0])); 2218 ;} 2219 break; 2220 2221 case 97: 2222 { 2223 ExprASTNode * left = dynamic_cast<ExprASTNode*>((yyvsp[-2].m_ast)); 2224 ExprASTNode * right = dynamic_cast<ExprASTNode*>((yyvsp[0].m_ast)); 2225 (yyval.m_ast) = new BinaryOpExprASTNode(left, BinaryOpExprASTNode::kGreaterThan, right); 2226 (yyval.m_ast)->setLocation((yylsp[-2]), (yylsp[0])); 2227 ;} 2228 break; 2229 2230 case 98: 2231 { 2232 ExprASTNode * left = dynamic_cast<ExprASTNode*>((yyvsp[-2].m_ast)); 2233 ExprASTNode * right = dynamic_cast<ExprASTNode*>((yyvsp[0].m_ast)); 2234 (yyval.m_ast) = new BinaryOpExprASTNode(left, BinaryOpExprASTNode::kGreaterThanEqual, right); 2235 (yyval.m_ast)->setLocation((yylsp[-2]), (yylsp[0])); 2236 ;} 2237 break; 2238 2239 case 99: 2240 { 2241 ExprASTNode * left = dynamic_cast<ExprASTNode*>((yyvsp[-2].m_ast)); 2242 ExprASTNode * right = dynamic_cast<ExprASTNode*>((yyvsp[0].m_ast)); 2243 (yyval.m_ast) = new BinaryOpExprASTNode(left, BinaryOpExprASTNode::kLessThanEqual, right); 2244 (yyval.m_ast)->setLocation((yylsp[-2]), (yylsp[0])); 2245 ;} 2246 break; 2247 2248 case 100: 2249 { 2250 ExprASTNode * left = dynamic_cast<ExprASTNode*>((yyvsp[-2].m_ast)); 2251 ExprASTNode * right = dynamic_cast<ExprASTNode*>((yyvsp[0].m_ast)); 2252 (yyval.m_ast) = new BinaryOpExprASTNode(left, BinaryOpExprASTNode::kEqual, right); 2253 (yyval.m_ast)->setLocation((yylsp[-2]), (yylsp[0])); 2254 ;} 2255 break; 2256 2257 case 101: 2258 { 2259 ExprASTNode * left = dynamic_cast<ExprASTNode*>((yyvsp[-2].m_ast)); 2260 ExprASTNode * right = dynamic_cast<ExprASTNode*>((yyvsp[0].m_ast)); 2261 (yyval.m_ast) = new BinaryOpExprASTNode(left, BinaryOpExprASTNode::kNotEqual, right); 2262 (yyval.m_ast)->setLocation((yylsp[-2]), (yylsp[0])); 2263 ;} 2264 break; 2265 2266 case 102: 2267 { 2268 ExprASTNode * left = dynamic_cast<ExprASTNode*>((yyvsp[-2].m_ast)); 2269 ExprASTNode * right = dynamic_cast<ExprASTNode*>((yyvsp[0].m_ast)); 2270 (yyval.m_ast) = new BinaryOpExprASTNode(left, BinaryOpExprASTNode::kBooleanAnd, right); 2271 (yyval.m_ast)->setLocation((yylsp[-2]), (yylsp[0])); 2272 ;} 2273 break; 2274 2275 case 103: 2276 { 2277 ExprASTNode * left = dynamic_cast<ExprASTNode*>((yyvsp[-2].m_ast)); 2278 ExprASTNode * right = dynamic_cast<ExprASTNode*>((yyvsp[0].m_ast)); 2279 (yyval.m_ast) = new BinaryOpExprASTNode(left, BinaryOpExprASTNode::kBooleanOr, right); 2280 (yyval.m_ast)->setLocation((yylsp[-2]), (yylsp[0])); 2281 ;} 2282 break; 2283 2284 case 104: 2285 { 2286 (yyval.m_ast) = new BooleanNotExprASTNode(dynamic_cast<ExprASTNode*>((yyvsp[0].m_ast))); 2287 (yyval.m_ast)->setLocation((yylsp[-1]), (yylsp[0])); 2288 ;} 2289 break; 2290 2291 case 105: 2292 { 2293 (yyval.m_ast) = new SourceFileFunctionASTNode((yyvsp[-3].m_str), (yyvsp[-1].m_str)); 2294 (yyval.m_ast)->setLocation((yylsp[-3]), (yylsp[0])); 2295 ;} 2296 break; 2297 2298 case 106: 2299 { 2300 (yyval.m_ast) = (yyvsp[-1].m_ast); 2301 (yyval.m_ast)->setLocation((yylsp[-2]), (yylsp[0])); 2302 ;} 2303 break; 2304 2305 case 107: 2306 { 2307 (yyval.m_ast) = new DefinedOperatorASTNode((yyvsp[-1].m_str)); 2308 (yyval.m_ast)->setLocation((yylsp[-3]), (yylsp[0])); 2309 ;} 2310 break; 2311 2312 case 108: 2313 { (yyval.m_ast) = (yyvsp[0].m_ast); ;} 2314 break; 2315 2316 case 109: 2317 { 2318 (yyval.m_ast) = new SymbolASTNode((yyvsp[0].m_str), (yyvsp[-2].m_str)); 2319 (yyval.m_ast)->setLocation((yylsp[-2]), (yylsp[0])); 2320 ;} 2321 break; 2322 2323 case 110: 2324 { 2325 (yyval.m_ast) = new SymbolASTNode((yyvsp[0].m_str)); 2326 (yyval.m_ast)->setLocation((yylsp[-1]), (yylsp[0])); 2327 ;} 2328 break; 2329 2330 case 111: 2331 { 2332 (yyval.m_ast) = (yyvsp[0].m_ast); 2333 ;} 2334 break; 2335 2336 case 112: 2337 { 2338 (yyval.m_ast) = new VariableExprASTNode((yyvsp[0].m_str)); 2339 (yyval.m_ast)->setLocation((yylsp[0])); 2340 ;} 2341 break; 2342 2343 case 113: 2344 { 2345 (yyval.m_ast) = new SymbolRefExprASTNode(dynamic_cast<SymbolASTNode*>((yyvsp[0].m_ast))); 2346 (yyval.m_ast)->setLocation((yylsp[0])); 2347 ;} 2348 break; 2349 2350 case 114: 2351 { 2352 ExprASTNode * left = dynamic_cast<ExprASTNode*>((yyvsp[-2].m_ast)); 2353 ExprASTNode * right = dynamic_cast<ExprASTNode*>((yyvsp[0].m_ast)); 2354 (yyval.m_ast) = new BinaryOpExprASTNode(left, BinaryOpExprASTNode::kAdd, right); 2355 (yyval.m_ast)->setLocation((yylsp[-2]), (yylsp[0])); 2356 ;} 2357 break; 2358 2359 case 115: 2360 { 2361 ExprASTNode * left = dynamic_cast<ExprASTNode*>((yyvsp[-2].m_ast)); 2362 ExprASTNode * right = dynamic_cast<ExprASTNode*>((yyvsp[0].m_ast)); 2363 (yyval.m_ast) = new BinaryOpExprASTNode(left, BinaryOpExprASTNode::kSubtract, right); 2364 (yyval.m_ast)->setLocation((yylsp[-2]), (yylsp[0])); 2365 ;} 2366 break; 2367 2368 case 116: 2369 { 2370 ExprASTNode * left = dynamic_cast<ExprASTNode*>((yyvsp[-2].m_ast)); 2371 ExprASTNode * right = dynamic_cast<ExprASTNode*>((yyvsp[0].m_ast)); 2372 (yyval.m_ast) = new BinaryOpExprASTNode(left, BinaryOpExprASTNode::kMultiply, right); 2373 (yyval.m_ast)->setLocation((yylsp[-2]), (yylsp[0])); 2374 ;} 2375 break; 2376 2377 case 117: 2378 { 2379 ExprASTNode * left = dynamic_cast<ExprASTNode*>((yyvsp[-2].m_ast)); 2380 ExprASTNode * right = dynamic_cast<ExprASTNode*>((yyvsp[0].m_ast)); 2381 (yyval.m_ast) = new BinaryOpExprASTNode(left, BinaryOpExprASTNode::kDivide, right); 2382 (yyval.m_ast)->setLocation((yylsp[-2]), (yylsp[0])); 2383 ;} 2384 break; 2385 2386 case 118: 2387 { 2388 ExprASTNode * left = dynamic_cast<ExprASTNode*>((yyvsp[-2].m_ast)); 2389 ExprASTNode * right = dynamic_cast<ExprASTNode*>((yyvsp[0].m_ast)); 2390 (yyval.m_ast) = new BinaryOpExprASTNode(left, BinaryOpExprASTNode::kModulus, right); 2391 (yyval.m_ast)->setLocation((yylsp[-2]), (yylsp[0])); 2392 ;} 2393 break; 2394 2395 case 119: 2396 { 2397 ExprASTNode * left = dynamic_cast<ExprASTNode*>((yyvsp[-2].m_ast)); 2398 ExprASTNode * right = dynamic_cast<ExprASTNode*>((yyvsp[0].m_ast)); 2399 (yyval.m_ast) = new BinaryOpExprASTNode(left, BinaryOpExprASTNode::kPower, right); 2400 (yyval.m_ast)->setLocation((yylsp[-2]), (yylsp[0])); 2401 ;} 2402 break; 2403 2404 case 120: 2405 { 2406 ExprASTNode * left = dynamic_cast<ExprASTNode*>((yyvsp[-2].m_ast)); 2407 ExprASTNode * right = dynamic_cast<ExprASTNode*>((yyvsp[0].m_ast)); 2408 (yyval.m_ast) = new BinaryOpExprASTNode(left, BinaryOpExprASTNode::kBitwiseAnd, right); 2409 (yyval.m_ast)->setLocation((yylsp[-2]), (yylsp[0])); 2410 ;} 2411 break; 2412 2413 case 121: 2414 { 2415 ExprASTNode * left = dynamic_cast<ExprASTNode*>((yyvsp[-2].m_ast)); 2416 ExprASTNode * right = dynamic_cast<ExprASTNode*>((yyvsp[0].m_ast)); 2417 (yyval.m_ast) = new BinaryOpExprASTNode(left, BinaryOpExprASTNode::kBitwiseOr, right); 2418 (yyval.m_ast)->setLocation((yylsp[-2]), (yylsp[0])); 2419 ;} 2420 break; 2421 2422 case 122: 2423 { 2424 ExprASTNode * left = dynamic_cast<ExprASTNode*>((yyvsp[-2].m_ast)); 2425 ExprASTNode * right = dynamic_cast<ExprASTNode*>((yyvsp[0].m_ast)); 2426 (yyval.m_ast) = new BinaryOpExprASTNode(left, BinaryOpExprASTNode::kBitwiseXor, right); 2427 (yyval.m_ast)->setLocation((yylsp[-2]), (yylsp[0])); 2428 ;} 2429 break; 2430 2431 case 123: 2432 { 2433 ExprASTNode * left = dynamic_cast<ExprASTNode*>((yyvsp[-2].m_ast)); 2434 ExprASTNode * right = dynamic_cast<ExprASTNode*>((yyvsp[0].m_ast)); 2435 (yyval.m_ast) = new BinaryOpExprASTNode(left, BinaryOpExprASTNode::kShiftLeft, right); 2436 (yyval.m_ast)->setLocation((yylsp[-2]), (yylsp[0])); 2437 ;} 2438 break; 2439 2440 case 124: 2441 { 2442 ExprASTNode * left = dynamic_cast<ExprASTNode*>((yyvsp[-2].m_ast)); 2443 ExprASTNode * right = dynamic_cast<ExprASTNode*>((yyvsp[0].m_ast)); 2444 (yyval.m_ast) = new BinaryOpExprASTNode(left, BinaryOpExprASTNode::kShiftRight, right); 2445 (yyval.m_ast)->setLocation((yylsp[-2]), (yylsp[0])); 2446 ;} 2447 break; 2448 2449 case 125: 2450 { 2451 (yyval.m_ast) = (yyvsp[0].m_ast); 2452 ;} 2453 break; 2454 2455 case 126: 2456 { 2457 (yyval.m_ast) = new IntSizeExprASTNode(dynamic_cast<ExprASTNode*>((yyvsp[-2].m_ast)), (yyvsp[0].m_int)->getWordSize()); 2458 (yyval.m_ast)->setLocation((yylsp[-2]), (yylsp[0])); 2459 ;} 2460 break; 2461 2462 case 127: 2463 { 2464 (yyval.m_ast) = (yyvsp[-1].m_ast); 2465 (yyval.m_ast)->setLocation((yylsp[-2]), (yylsp[0])); 2466 ;} 2467 break; 2468 2469 case 128: 2470 { 2471 (yyval.m_ast) = new SizeofOperatorASTNode(dynamic_cast<SymbolASTNode*>((yyvsp[-1].m_ast))); 2472 (yyval.m_ast)->setLocation((yylsp[-3]), (yylsp[0])); 2473 ;} 2474 break; 2475 2476 case 129: 2477 { 2478 (yyval.m_ast) = new SizeofOperatorASTNode((yyvsp[-1].m_str)); 2479 (yyval.m_ast)->setLocation((yylsp[-3]), (yylsp[0])); 2480 ;} 2481 break; 2482 2483 case 130: 2484 { 2485 (yyval.m_ast) = new SizeofOperatorASTNode((yyvsp[-1].m_str)); 2486 (yyval.m_ast)->setLocation((yylsp[-3]), (yylsp[0])); 2487 ;} 2488 break; 2489 2490 case 131: 2491 { 2492 (yyval.m_ast) = (yyvsp[0].m_ast); 2493 ;} 2494 break; 2495 2496 case 132: 2497 { 2498 (yyval.m_ast) = new NegativeExprASTNode(dynamic_cast<ExprASTNode*>((yyvsp[0].m_ast))); 2499 (yyval.m_ast)->setLocation((yylsp[-1]), (yylsp[0])); 2500 ;} 2501 break; 2502 2503 case 133: 2504 { 2505 (yyval.m_ast) = new IntConstExprASTNode((yyvsp[0].m_int)->getValue(), (yyvsp[0].m_int)->getWordSize()); 2506 (yyval.m_ast)->setLocation((yylsp[0])); 2507 ;} 2508 break; 2509 2510 2511 default: break; 2512 } 2513 2514 /* Line 1126 of yacc.c. */ 2515 2516 yyvsp -= yylen; 2518 yyssp -= yylen; 2519 yylsp -= yylen; 2520 2521 YY_STACK_PRINT (yyss, yyssp); 2522 2523 *++yyvsp = yyval; 2524 *++yylsp = yyloc; 2525 2526 /* Now `shift' the result of the reduction. Determine what state 2527 that goes to, based on the state we popped back to and the rule 2528 number reduced by. */ 2529 2530 yyn = yyr1[yyn]; 2531 2532 yystate = yypgoto[yyn - YYNTOKENS] + *yyssp; 2533 if (0 <= yystate && yystate <= YYLAST && yycheck[yystate] == *yyssp) 2534 yystate = yytable[yystate]; 2535 else 2536 yystate = yydefgoto[yyn - YYNTOKENS]; 2537 2538 goto yynewstate; 2539 2540 2541 /*------------------------------------. 2542 | yyerrlab -- here on detecting error | 2543 `------------------------------------*/ 2544 yyerrlab: 2545 /* If not already recovering from an error, report this error. */ 2546 if (!yyerrstatus) 2547 { 2548 ++yynerrs; 2549 #if YYERROR_VERBOSE 2550 yyn = yypact[yystate]; 2551 2552 if (YYPACT_NINF < yyn && yyn < YYLAST) 2553 { 2554 int yytype = YYTRANSLATE (yychar); 2555 YYSIZE_T yysize0 = yytnamerr (0, yytname[yytype]); 2556 YYSIZE_T yysize = yysize0; 2557 YYSIZE_T yysize1; 2558 int yysize_overflow = 0; 2559 char *yymsg = 0; 2560 # define YYERROR_VERBOSE_ARGS_MAXIMUM 5 2561 char const *yyarg[YYERROR_VERBOSE_ARGS_MAXIMUM]; 2562 int yyx; 2563 2564 #if 0 2565 /* This is so xgettext sees the translatable formats that are 2566 constructed on the fly. */ 2567 YY_("syntax error, unexpected %s"); 2568 YY_("syntax error, unexpected %s, expecting %s"); 2569 YY_("syntax error, unexpected %s, expecting %s or %s"); 2570 YY_("syntax error, unexpected %s, expecting %s or %s or %s"); 2571 YY_("syntax error, unexpected %s, expecting %s or %s or %s or %s"); 2572 #endif 2573 char *yyfmt; 2574 char const *yyf; 2575 static char const yyunexpected[] = "syntax error, unexpected %s"; 2576 static char const yyexpecting[] = ", expecting %s"; 2577 static char const yyor[] = " or %s"; 2578 char yyformat[sizeof yyunexpected 2579 + sizeof yyexpecting - 1 2580 + ((YYERROR_VERBOSE_ARGS_MAXIMUM - 2) 2581 * (sizeof yyor - 1))]; 2582 char const *yyprefix = yyexpecting; 2583 2584 /* Start YYX at -YYN if negative to avoid negative indexes in 2585 YYCHECK. */ 2586 int yyxbegin = yyn < 0 ? -yyn : 0; 2587 2588 /* Stay within bounds of both yycheck and yytname. */ 2589 int yychecklim = YYLAST - yyn; 2590 int yyxend = yychecklim < YYNTOKENS ? yychecklim : YYNTOKENS; 2591 int yycount = 1; 2592 2593 yyarg[0] = yytname[yytype]; 2594 yyfmt = yystpcpy (yyformat, yyunexpected); 2595 2596 for (yyx = yyxbegin; yyx < yyxend; ++yyx) 2597 if (yycheck[yyx + yyn] == yyx && yyx != YYTERROR) 2598 { 2599 if (yycount == YYERROR_VERBOSE_ARGS_MAXIMUM) 2600 { 2601 yycount = 1; 2602 yysize = yysize0; 2603 yyformat[sizeof yyunexpected - 1] = '\0'; 2604 break; 2605 } 2606 yyarg[yycount++] = yytname[yyx]; 2607 yysize1 = yysize + yytnamerr (0, yytname[yyx]); 2608 yysize_overflow |= yysize1 < yysize; 2609 yysize = yysize1; 2610 yyfmt = yystpcpy (yyfmt, yyprefix); 2611 yyprefix = yyor; 2612 } 2613 2614 yyf = YY_(yyformat); 2615 yysize1 = yysize + yystrlen (yyf); 2616 yysize_overflow |= yysize1 < yysize; 2617 yysize = yysize1; 2618 2619 if (!yysize_overflow && yysize <= YYSTACK_ALLOC_MAXIMUM) 2620 yymsg = (char *) YYSTACK_ALLOC (yysize); 2621 if (yymsg) 2622 { 2623 /* Avoid sprintf, as that infringes on the user's name space. 2624 Don't have undefined behavior even if the translation 2625 produced a string with the wrong number of "%s"s. */ 2626 char *yyp = yymsg; 2627 int yyi = 0; 2628 while ((*yyp = *yyf)) 2629 { 2630 if (*yyp == '%' && yyf[1] == 's' && yyi < yycount) 2631 { 2632 yyp += yytnamerr (yyp, yyarg[yyi++]); 2633 yyf += 2; 2634 } 2635 else 2636 { 2637 yyp++; 2638 yyf++; 2639 } 2640 } 2641 yyerror (&yylloc, lexer, resultAST, yymsg); 2642 YYSTACK_FREE (yymsg); 2643 } 2644 else 2645 { 2646 yyerror (&yylloc, lexer, resultAST, YY_("syntax error")); 2647 goto yyexhaustedlab; 2648 } 2649 } 2650 else 2651 #endif /* YYERROR_VERBOSE */ 2652 yyerror (&yylloc, lexer, resultAST, YY_("syntax error")); 2653 } 2654 2655 yyerror_range[0] = yylloc; 2656 2657 if (yyerrstatus == 3) 2658 { 2659 /* If just tried and failed to reuse look-ahead token after an 2660 error, discard it. */ 2661 2662 if (yychar <= YYEOF) 2663 { 2664 /* Return failure if at end of input. */ 2665 if (yychar == YYEOF) 2666 YYABORT; 2667 } 2668 else 2669 { 2670 yydestruct ("Error: discarding", yytoken, &yylval, &yylloc); 2671 yychar = YYEMPTY; 2672 } 2673 } 2674 2675 /* Else will try to reuse look-ahead token after shifting the error 2676 token. */ 2677 goto yyerrlab1; 2678 2679 2680 /*---------------------------------------------------. 2681 | yyerrorlab -- error raised explicitly by YYERROR. | 2682 `---------------------------------------------------*/ 2683 yyerrorlab: 2684 2685 /* Pacify compilers like GCC when the user code never invokes 2686 YYERROR and the label yyerrorlab therefore never appears in user 2687 code. */ 2688 if (0) 2689 goto yyerrorlab; 2690 2691 yyerror_range[0] = yylsp[1-yylen]; 2692 yylsp -= yylen; 2693 yyvsp -= yylen; 2694 yyssp -= yylen; 2695 yystate = *yyssp; 2696 goto yyerrlab1; 2697 2698 2699 /*-------------------------------------------------------------. 2700 | yyerrlab1 -- common code for both syntax error and YYERROR. | 2701 `-------------------------------------------------------------*/ 2702 yyerrlab1: 2703 yyerrstatus = 3; /* Each real token shifted decrements this. */ 2704 2705 for (;;) 2706 { 2707 yyn = yypact[yystate]; 2708 if (yyn != YYPACT_NINF) 2709 { 2710 yyn += YYTERROR; 2711 if (0 <= yyn && yyn <= YYLAST && yycheck[yyn] == YYTERROR) 2712 { 2713 yyn = yytable[yyn]; 2714 if (0 < yyn) 2715 break; 2716 } 2717 } 2718 2719 /* Pop the current state because it cannot handle the error token. */ 2720 if (yyssp == yyss) 2721 YYABORT; 2722 2723 yyerror_range[0] = *yylsp; 2724 yydestruct ("Error: popping", yystos[yystate], yyvsp, yylsp); 2725 YYPOPSTACK; 2726 yystate = *yyssp; 2727 YY_STACK_PRINT (yyss, yyssp); 2728 } 2729 2730 if (yyn == YYFINAL) 2731 YYACCEPT; 2732 2733 *++yyvsp = yylval; 2734 2735 yyerror_range[1] = yylloc; 2736 /* Using YYLLOC is tempting, but would change the location of 2737 the look-ahead. YYLOC is available though. */ 2738 YYLLOC_DEFAULT (yyloc, yyerror_range - 1, 2); 2739 *++yylsp = yyloc; 2740 2741 /* Shift the error token. */ 2742 YY_SYMBOL_PRINT ("Shifting", yystos[yyn], yyvsp, yylsp); 2743 2744 yystate = yyn; 2745 goto yynewstate; 2746 2747 2748 /*-------------------------------------. 2749 | yyacceptlab -- YYACCEPT comes here. | 2750 `-------------------------------------*/ 2751 yyacceptlab: 2752 yyresult = 0; 2753 goto yyreturn; 2754 2755 /*-----------------------------------. 2756 | yyabortlab -- YYABORT comes here. | 2757 `-----------------------------------*/ 2758 yyabortlab: 2759 yyresult = 1; 2760 goto yyreturn; 2761 2762 #ifndef yyoverflow 2763 /*-------------------------------------------------. 2764 | yyexhaustedlab -- memory exhaustion comes here. | 2765 `-------------------------------------------------*/ 2766 yyexhaustedlab: 2767 yyerror (&yylloc, lexer, resultAST, YY_("memory exhausted")); 2768 yyresult = 2; 2769 /* Fall through. */ 2770 #endif 2771 2772 yyreturn: 2773 if (yychar != YYEOF && yychar != YYEMPTY) 2774 yydestruct ("Cleanup: discarding lookahead", 2775 yytoken, &yylval, &yylloc); 2776 while (yyssp != yyss) 2777 { 2778 yydestruct ("Cleanup: popping", 2779 yystos[*yyssp], yyvsp, yylsp); 2780 YYPOPSTACK; 2781 } 2782 #ifndef yyoverflow 2783 if (yyss != yyssa) 2784 YYSTACK_FREE (yyss); 2785 #endif 2786 return yyresult; 2787 } 2788 2789 2790 2791 2792 /* code goes here */ 2793 2794 static int yylex(YYSTYPE * lvalp, YYLTYPE * yylloc, ElftosbLexer * lexer) 2795 { 2796 int token = lexer->yylex(); 2797 *yylloc = lexer->getLocation(); 2798 lexer->getSymbolValue(lvalp); 2799 return token; 2800 } 2801 2802 static void yyerror(YYLTYPE * yylloc, ElftosbLexer * lexer, CommandFileASTNode ** resultAST, const char * error) 2803 { 2804 throw syntax_error(format_string("line %d: %s\n", yylloc->m_firstLine, error)); 2805 } 2806 2807 2808