1 1.8 christos /* A Bison parser, made by GNU Bison 3.8.2. */ 2 1.1 christos 3 1.6 christos /* Bison implementation for Yacc-like parsers in C 4 1.1 christos 5 1.8 christos Copyright (C) 1984, 1989-1990, 2000-2015, 2018-2021 Free Software Foundation, 6 1.8 christos Inc. 7 1.1 christos 8 1.6 christos This program is free software: you can redistribute it and/or modify 9 1.1 christos it under the terms of the GNU General Public License as published by 10 1.6 christos the Free Software Foundation, either version 3 of the License, or 11 1.6 christos (at your option) any later version. 12 1.1 christos 13 1.1 christos This program is distributed in the hope that it will be useful, 14 1.1 christos but WITHOUT ANY WARRANTY; without even the implied warranty of 15 1.1 christos MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 16 1.1 christos GNU General Public License for more details. 17 1.1 christos 18 1.1 christos You should have received a copy of the GNU General Public License 19 1.8 christos along with this program. If not, see <https://www.gnu.org/licenses/>. */ 20 1.1 christos 21 1.1 christos /* As a special exception, you may create a larger work that contains 22 1.1 christos part or all of the Bison parser skeleton and distribute that work 23 1.1 christos under terms of your choice, so long as that work isn't itself a 24 1.1 christos parser generator using the skeleton or a modified version thereof 25 1.1 christos as a parser skeleton. Alternatively, if you modify or redistribute 26 1.1 christos the parser skeleton itself, you may (at your option) remove this 27 1.1 christos special exception, which will cause the skeleton and the resulting 28 1.1 christos Bison output files to be licensed under the GNU General Public 29 1.1 christos License without this special exception. 30 1.1 christos 31 1.1 christos This special exception was added by the Free Software Foundation in 32 1.1 christos version 2.2 of Bison. */ 33 1.1 christos 34 1.1 christos /* C LALR(1) parser skeleton written by Richard Stallman, by 35 1.1 christos simplifying the original so-called "semantic" parser. */ 36 1.1 christos 37 1.8 christos /* DO NOT RELY ON FEATURES THAT ARE NOT DOCUMENTED in the manual, 38 1.8 christos especially those whose name start with YY_ or yy_. They are 39 1.8 christos private implementation details that can be changed or removed. */ 40 1.8 christos 41 1.1 christos /* All symbols defined below should begin with yy or YY, to avoid 42 1.1 christos infringing on user name space. This should be done even for local 43 1.1 christos variables, as they might otherwise be expanded by user macros. 44 1.1 christos There are some unavoidable exceptions within include files to 45 1.1 christos define necessary library symbols; they are noted "INFRINGES ON 46 1.1 christos USER NAME SPACE" below. */ 47 1.1 christos 48 1.8 christos /* Identify Bison output, and Bison version. */ 49 1.8 christos #define YYBISON 30802 50 1.1 christos 51 1.8 christos /* Bison version string. */ 52 1.8 christos #define YYBISON_VERSION "3.8.2" 53 1.1 christos 54 1.1 christos /* Skeleton name. */ 55 1.1 christos #define YYSKELETON_NAME "yacc.c" 56 1.1 christos 57 1.1 christos /* Pure parsers. */ 58 1.1 christos #define YYPURE 0 59 1.1 christos 60 1.6 christos /* Push parsers. */ 61 1.6 christos #define YYPUSH 0 62 1.1 christos 63 1.6 christos /* Pull parsers. */ 64 1.6 christos #define YYPULL 1 65 1.1 christos 66 1.1 christos 67 1.1 christos 68 1.1 christos 69 1.8 christos /* First part of user prologue. */ 70 1.8 christos #line 1 "deffilep.y" 71 1.1 christos /* deffilep.y - parser for .def files */ 72 1.1 christos 73 1.10 christos /* Copyright (C) 1995-2025 Free Software Foundation, Inc. 74 1.1 christos 75 1.1 christos This file is part of GNU Binutils. 76 1.1 christos 77 1.1 christos This program is free software; you can redistribute it and/or modify 78 1.1 christos it under the terms of the GNU General Public License as published by 79 1.1 christos the Free Software Foundation; either version 3 of the License, or 80 1.1 christos (at your option) any later version. 81 1.1 christos 82 1.1 christos This program is distributed in the hope that it will be useful, 83 1.1 christos but WITHOUT ANY WARRANTY; without even the implied warranty of 84 1.1 christos MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 85 1.1 christos GNU General Public License for more details. 86 1.1 christos 87 1.1 christos You should have received a copy of the GNU General Public License 88 1.1 christos along with this program; if not, write to the Free Software 89 1.1 christos Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, 90 1.1 christos MA 02110-1301, USA. */ 91 1.1 christos 92 1.1 christos #include "sysdep.h" 93 1.1 christos #include "libiberty.h" 94 1.1 christos #include "safe-ctype.h" 95 1.1 christos #include "bfd.h" 96 1.7 christos #include "bfdlink.h" 97 1.1 christos #include "ld.h" 98 1.1 christos #include "ldmisc.h" 99 1.1 christos #include "deffile.h" 100 1.1 christos 101 1.1 christos #define TRACE 0 102 1.1 christos 103 1.1 christos #define ROUND_UP(a, b) (((a)+((b)-1))&~((b)-1)) 104 1.1 christos 105 1.9 christos #define SYMBOL_LIST_ARRAY_GROW 64 106 1.9 christos 107 1.1 christos /* Remap normal yacc parser interface names (yyparse, yylex, yyerror, etc), 108 1.1 christos as well as gratuitiously global symbol names, so we can have multiple 109 1.1 christos yacc generated parsers in ld. Note that these are only the variables 110 1.1 christos produced by yacc. If other parser generators (bison, byacc, etc) produce 111 1.1 christos additional global names that conflict at link time, then those parser 112 1.1 christos generators need to be fixed instead of adding those names to this list. */ 113 1.1 christos 114 1.1 christos #define yymaxdepth def_maxdepth 115 1.1 christos #define yyparse def_parse 116 1.1 christos #define yylex def_lex 117 1.1 christos #define yyerror def_error 118 1.1 christos #define yylval def_lval 119 1.1 christos #define yychar def_char 120 1.1 christos #define yydebug def_debug 121 1.3 christos #define yypact def_pact 122 1.3 christos #define yyr1 def_r1 123 1.3 christos #define yyr2 def_r2 124 1.3 christos #define yydef def_def 125 1.3 christos #define yychk def_chk 126 1.3 christos #define yypgo def_pgo 127 1.3 christos #define yyact def_act 128 1.1 christos #define yyexca def_exca 129 1.1 christos #define yyerrflag def_errflag 130 1.1 christos #define yynerrs def_nerrs 131 1.1 christos #define yyps def_ps 132 1.1 christos #define yypv def_pv 133 1.1 christos #define yys def_s 134 1.1 christos #define yy_yys def_yys 135 1.1 christos #define yystate def_state 136 1.1 christos #define yytmp def_tmp 137 1.1 christos #define yyv def_v 138 1.1 christos #define yy_yyv def_yyv 139 1.1 christos #define yyval def_val 140 1.1 christos #define yylloc def_lloc 141 1.1 christos #define yyreds def_reds /* With YYDEBUG defined. */ 142 1.1 christos #define yytoks def_toks /* With YYDEBUG defined. */ 143 1.1 christos #define yylhs def_yylhs 144 1.1 christos #define yylen def_yylen 145 1.1 christos #define yydefred def_yydefred 146 1.1 christos #define yydgoto def_yydgoto 147 1.1 christos #define yysindex def_yysindex 148 1.1 christos #define yyrindex def_yyrindex 149 1.1 christos #define yygindex def_yygindex 150 1.1 christos #define yytable def_yytable 151 1.1 christos #define yycheck def_yycheck 152 1.1 christos 153 1.1 christos typedef struct def_pool_str { 154 1.1 christos struct def_pool_str *next; 155 1.1 christos char data[1]; 156 1.1 christos } def_pool_str; 157 1.1 christos 158 1.1 christos static def_pool_str *pool_strs = NULL; 159 1.1 christos 160 1.1 christos static char *def_pool_alloc (size_t sz); 161 1.1 christos static char *def_pool_strdup (const char *str); 162 1.1 christos static void def_pool_free (void); 163 1.1 christos 164 1.1 christos static void def_description (const char *); 165 1.1 christos static void def_exports (const char *, const char *, int, int, const char *); 166 1.1 christos static void def_heapsize (int, int); 167 1.1 christos static void def_import (const char *, const char *, const char *, const char *, 168 1.1 christos int, const char *); 169 1.3 christos static void def_image_name (const char *, bfd_vma, int); 170 1.1 christos static void def_section (const char *, int); 171 1.1 christos static void def_section_alt (const char *, const char *); 172 1.1 christos static void def_stacksize (int, int); 173 1.1 christos static void def_version (int, int); 174 1.1 christos static void def_directive (char *); 175 1.1 christos static void def_aligncomm (char *str, int align); 176 1.9 christos static void def_exclude_symbols (char *str); 177 1.1 christos static int def_parse (void); 178 1.8 christos static void def_error (const char *); 179 1.1 christos static int def_lex (void); 180 1.1 christos 181 1.1 christos static int lex_forced_token = 0; 182 1.1 christos static const char *lex_parse_string = 0; 183 1.1 christos static const char *lex_parse_string_end = 0; 184 1.1 christos 185 1.1 christos 186 1.9 christos #line 187 "deffilep.c" 187 1.1 christos 188 1.8 christos # ifndef YY_CAST 189 1.8 christos # ifdef __cplusplus 190 1.8 christos # define YY_CAST(Type, Val) static_cast<Type> (Val) 191 1.8 christos # define YY_REINTERPRET_CAST(Type, Val) reinterpret_cast<Type> (Val) 192 1.8 christos # else 193 1.8 christos # define YY_CAST(Type, Val) ((Type) (Val)) 194 1.8 christos # define YY_REINTERPRET_CAST(Type, Val) ((Type) (Val)) 195 1.8 christos # endif 196 1.8 christos # endif 197 1.6 christos # ifndef YY_NULLPTR 198 1.8 christos # if defined __cplusplus 199 1.8 christos # if 201103L <= __cplusplus 200 1.8 christos # define YY_NULLPTR nullptr 201 1.8 christos # else 202 1.8 christos # define YY_NULLPTR 0 203 1.8 christos # endif 204 1.6 christos # else 205 1.8 christos # define YY_NULLPTR ((void*)0) 206 1.6 christos # endif 207 1.6 christos # endif 208 1.1 christos 209 1.8 christos /* Use api.header.include to #include this header 210 1.8 christos instead of duplicating it here. */ 211 1.6 christos #ifndef YY_YY_DEFFILEP_H_INCLUDED 212 1.6 christos # define YY_YY_DEFFILEP_H_INCLUDED 213 1.6 christos /* Debug traces. */ 214 1.6 christos #ifndef YYDEBUG 215 1.6 christos # define YYDEBUG 0 216 1.6 christos #endif 217 1.6 christos #if YYDEBUG 218 1.6 christos extern int yydebug; 219 1.3 christos #endif 220 1.3 christos 221 1.8 christos /* Token kinds. */ 222 1.6 christos #ifndef YYTOKENTYPE 223 1.6 christos # define YYTOKENTYPE 224 1.6 christos enum yytokentype 225 1.6 christos { 226 1.8 christos YYEMPTY = -2, 227 1.8 christos YYEOF = 0, /* "end of file" */ 228 1.8 christos YYerror = 256, /* error */ 229 1.8 christos YYUNDEF = 257, /* "invalid token" */ 230 1.8 christos NAME = 258, /* NAME */ 231 1.8 christos LIBRARY = 259, /* LIBRARY */ 232 1.8 christos DESCRIPTION = 260, /* DESCRIPTION */ 233 1.8 christos STACKSIZE_K = 261, /* STACKSIZE_K */ 234 1.8 christos HEAPSIZE = 262, /* HEAPSIZE */ 235 1.8 christos CODE = 263, /* CODE */ 236 1.8 christos DATAU = 264, /* DATAU */ 237 1.8 christos DATAL = 265, /* DATAL */ 238 1.8 christos SECTIONS = 266, /* SECTIONS */ 239 1.8 christos EXPORTS = 267, /* EXPORTS */ 240 1.8 christos IMPORTS = 268, /* IMPORTS */ 241 1.8 christos VERSIONK = 269, /* VERSIONK */ 242 1.8 christos BASE = 270, /* BASE */ 243 1.8 christos CONSTANTU = 271, /* CONSTANTU */ 244 1.8 christos CONSTANTL = 272, /* CONSTANTL */ 245 1.8 christos PRIVATEU = 273, /* PRIVATEU */ 246 1.8 christos PRIVATEL = 274, /* PRIVATEL */ 247 1.8 christos ALIGNCOMM = 275, /* ALIGNCOMM */ 248 1.9 christos EXCLUDE_SYMBOLS = 276, /* EXCLUDE_SYMBOLS */ 249 1.9 christos READ = 277, /* READ */ 250 1.9 christos WRITE = 278, /* WRITE */ 251 1.9 christos EXECUTE = 279, /* EXECUTE */ 252 1.9 christos SHARED_K = 280, /* SHARED_K */ 253 1.9 christos NONAMEU = 281, /* NONAMEU */ 254 1.9 christos NONAMEL = 282, /* NONAMEL */ 255 1.9 christos DIRECTIVE = 283, /* DIRECTIVE */ 256 1.9 christos EQUAL = 284, /* EQUAL */ 257 1.9 christos ID = 285, /* ID */ 258 1.9 christos DIGITS = 286 /* DIGITS */ 259 1.6 christos }; 260 1.8 christos typedef enum yytokentype yytoken_kind_t; 261 1.6 christos #endif 262 1.8 christos /* Token kinds. */ 263 1.8 christos #define YYEMPTY -2 264 1.8 christos #define YYEOF 0 265 1.8 christos #define YYerror 256 266 1.8 christos #define YYUNDEF 257 267 1.6 christos #define NAME 258 268 1.6 christos #define LIBRARY 259 269 1.6 christos #define DESCRIPTION 260 270 1.6 christos #define STACKSIZE_K 261 271 1.6 christos #define HEAPSIZE 262 272 1.6 christos #define CODE 263 273 1.6 christos #define DATAU 264 274 1.6 christos #define DATAL 265 275 1.6 christos #define SECTIONS 266 276 1.6 christos #define EXPORTS 267 277 1.6 christos #define IMPORTS 268 278 1.6 christos #define VERSIONK 269 279 1.6 christos #define BASE 270 280 1.6 christos #define CONSTANTU 271 281 1.6 christos #define CONSTANTL 272 282 1.6 christos #define PRIVATEU 273 283 1.6 christos #define PRIVATEL 274 284 1.6 christos #define ALIGNCOMM 275 285 1.9 christos #define EXCLUDE_SYMBOLS 276 286 1.9 christos #define READ 277 287 1.9 christos #define WRITE 278 288 1.9 christos #define EXECUTE 279 289 1.9 christos #define SHARED_K 280 290 1.9 christos #define NONAMEU 281 291 1.9 christos #define NONAMEL 282 292 1.9 christos #define DIRECTIVE 283 293 1.9 christos #define EQUAL 284 294 1.9 christos #define ID 285 295 1.9 christos #define DIGITS 286 296 1.6 christos 297 1.6 christos /* Value type. */ 298 1.1 christos #if ! defined YYSTYPE && ! defined YYSTYPE_IS_DECLARED 299 1.6 christos union YYSTYPE 300 1.1 christos { 301 1.9 christos #line 117 "deffilep.y" 302 1.6 christos 303 1.1 christos char *id; 304 1.1 christos const char *id_const; 305 1.1 christos int number; 306 1.3 christos bfd_vma vma; 307 1.1 christos char *digits; 308 1.6 christos 309 1.9 christos #line 310 "deffilep.c" 310 1.8 christos 311 1.6 christos }; 312 1.6 christos typedef union YYSTYPE YYSTYPE; 313 1.6 christos # define YYSTYPE_IS_TRIVIAL 1 314 1.5 christos # define YYSTYPE_IS_DECLARED 1 315 1.1 christos #endif 316 1.1 christos 317 1.1 christos 318 1.6 christos extern YYSTYPE yylval; 319 1.6 christos 320 1.8 christos 321 1.6 christos int yyparse (void); 322 1.6 christos 323 1.8 christos 324 1.6 christos #endif /* !YY_YY_DEFFILEP_H_INCLUDED */ 325 1.8 christos /* Symbol kind. */ 326 1.8 christos enum yysymbol_kind_t 327 1.8 christos { 328 1.8 christos YYSYMBOL_YYEMPTY = -2, 329 1.8 christos YYSYMBOL_YYEOF = 0, /* "end of file" */ 330 1.8 christos YYSYMBOL_YYerror = 1, /* error */ 331 1.8 christos YYSYMBOL_YYUNDEF = 2, /* "invalid token" */ 332 1.8 christos YYSYMBOL_NAME = 3, /* NAME */ 333 1.8 christos YYSYMBOL_LIBRARY = 4, /* LIBRARY */ 334 1.8 christos YYSYMBOL_DESCRIPTION = 5, /* DESCRIPTION */ 335 1.8 christos YYSYMBOL_STACKSIZE_K = 6, /* STACKSIZE_K */ 336 1.8 christos YYSYMBOL_HEAPSIZE = 7, /* HEAPSIZE */ 337 1.8 christos YYSYMBOL_CODE = 8, /* CODE */ 338 1.8 christos YYSYMBOL_DATAU = 9, /* DATAU */ 339 1.8 christos YYSYMBOL_DATAL = 10, /* DATAL */ 340 1.8 christos YYSYMBOL_SECTIONS = 11, /* SECTIONS */ 341 1.8 christos YYSYMBOL_EXPORTS = 12, /* EXPORTS */ 342 1.8 christos YYSYMBOL_IMPORTS = 13, /* IMPORTS */ 343 1.8 christos YYSYMBOL_VERSIONK = 14, /* VERSIONK */ 344 1.8 christos YYSYMBOL_BASE = 15, /* BASE */ 345 1.8 christos YYSYMBOL_CONSTANTU = 16, /* CONSTANTU */ 346 1.8 christos YYSYMBOL_CONSTANTL = 17, /* CONSTANTL */ 347 1.8 christos YYSYMBOL_PRIVATEU = 18, /* PRIVATEU */ 348 1.8 christos YYSYMBOL_PRIVATEL = 19, /* PRIVATEL */ 349 1.8 christos YYSYMBOL_ALIGNCOMM = 20, /* ALIGNCOMM */ 350 1.9 christos YYSYMBOL_EXCLUDE_SYMBOLS = 21, /* EXCLUDE_SYMBOLS */ 351 1.9 christos YYSYMBOL_READ = 22, /* READ */ 352 1.9 christos YYSYMBOL_WRITE = 23, /* WRITE */ 353 1.9 christos YYSYMBOL_EXECUTE = 24, /* EXECUTE */ 354 1.9 christos YYSYMBOL_SHARED_K = 25, /* SHARED_K */ 355 1.9 christos YYSYMBOL_NONAMEU = 26, /* NONAMEU */ 356 1.9 christos YYSYMBOL_NONAMEL = 27, /* NONAMEL */ 357 1.9 christos YYSYMBOL_DIRECTIVE = 28, /* DIRECTIVE */ 358 1.9 christos YYSYMBOL_EQUAL = 29, /* EQUAL */ 359 1.9 christos YYSYMBOL_ID = 30, /* ID */ 360 1.9 christos YYSYMBOL_DIGITS = 31, /* DIGITS */ 361 1.9 christos YYSYMBOL_32_ = 32, /* '.' */ 362 1.9 christos YYSYMBOL_33_ = 33, /* ',' */ 363 1.9 christos YYSYMBOL_34_ = 34, /* '=' */ 364 1.9 christos YYSYMBOL_35_ = 35, /* '@' */ 365 1.9 christos YYSYMBOL_YYACCEPT = 36, /* $accept */ 366 1.9 christos YYSYMBOL_start = 37, /* start */ 367 1.9 christos YYSYMBOL_command = 38, /* command */ 368 1.9 christos YYSYMBOL_explist = 39, /* explist */ 369 1.9 christos YYSYMBOL_expline = 40, /* expline */ 370 1.9 christos YYSYMBOL_exp_opt_list = 41, /* exp_opt_list */ 371 1.9 christos YYSYMBOL_exp_opt = 42, /* exp_opt */ 372 1.9 christos YYSYMBOL_implist = 43, /* implist */ 373 1.9 christos YYSYMBOL_impline = 44, /* impline */ 374 1.9 christos YYSYMBOL_seclist = 45, /* seclist */ 375 1.9 christos YYSYMBOL_secline = 46, /* secline */ 376 1.9 christos YYSYMBOL_attr_list = 47, /* attr_list */ 377 1.9 christos YYSYMBOL_opt_comma = 48, /* opt_comma */ 378 1.9 christos YYSYMBOL_opt_number = 49, /* opt_number */ 379 1.9 christos YYSYMBOL_attr = 50, /* attr */ 380 1.9 christos YYSYMBOL_keyword_as_name = 51, /* keyword_as_name */ 381 1.9 christos YYSYMBOL_opt_name2 = 52, /* opt_name2 */ 382 1.9 christos YYSYMBOL_opt_name = 53, /* opt_name */ 383 1.9 christos YYSYMBOL_opt_equalequal_name = 54, /* opt_equalequal_name */ 384 1.9 christos YYSYMBOL_opt_ordinal = 55, /* opt_ordinal */ 385 1.9 christos YYSYMBOL_opt_equal_name = 56, /* opt_equal_name */ 386 1.9 christos YYSYMBOL_opt_base = 57, /* opt_base */ 387 1.9 christos YYSYMBOL_anylang_id = 58, /* anylang_id */ 388 1.9 christos YYSYMBOL_symbol_list = 59, /* symbol_list */ 389 1.9 christos YYSYMBOL_opt_digits = 60, /* opt_digits */ 390 1.9 christos YYSYMBOL_opt_id = 61, /* opt_id */ 391 1.9 christos YYSYMBOL_NUMBER = 62, /* NUMBER */ 392 1.9 christos YYSYMBOL_VMA = 63 /* VMA */ 393 1.8 christos }; 394 1.8 christos typedef enum yysymbol_kind_t yysymbol_kind_t; 395 1.8 christos 396 1.3 christos 397 1.1 christos 398 1.1 christos 399 1.1 christos #ifdef short 400 1.1 christos # undef short 401 1.1 christos #endif 402 1.1 christos 403 1.8 christos /* On compilers that do not define __PTRDIFF_MAX__ etc., make sure 404 1.8 christos <limits.h> and (if available) <stdint.h> are included 405 1.8 christos so that the code can choose integer types of a good width. */ 406 1.8 christos 407 1.8 christos #ifndef __PTRDIFF_MAX__ 408 1.8 christos # include <limits.h> /* INFRINGES ON USER NAME SPACE */ 409 1.8 christos # if defined __STDC_VERSION__ && 199901 <= __STDC_VERSION__ 410 1.8 christos # include <stdint.h> /* INFRINGES ON USER NAME SPACE */ 411 1.8 christos # define YY_STDINT_H 412 1.8 christos # endif 413 1.8 christos #endif 414 1.8 christos 415 1.8 christos /* Narrow types that promote to a signed type and that can represent a 416 1.8 christos signed or unsigned integer of at least N bits. In tables they can 417 1.8 christos save space and decrease cache pressure. Promoting to a signed type 418 1.8 christos helps avoid bugs in integer arithmetic. */ 419 1.8 christos 420 1.8 christos #ifdef __INT_LEAST8_MAX__ 421 1.8 christos typedef __INT_LEAST8_TYPE__ yytype_int8; 422 1.8 christos #elif defined YY_STDINT_H 423 1.8 christos typedef int_least8_t yytype_int8; 424 1.1 christos #else 425 1.8 christos typedef signed char yytype_int8; 426 1.1 christos #endif 427 1.1 christos 428 1.8 christos #ifdef __INT_LEAST16_MAX__ 429 1.8 christos typedef __INT_LEAST16_TYPE__ yytype_int16; 430 1.8 christos #elif defined YY_STDINT_H 431 1.8 christos typedef int_least16_t yytype_int16; 432 1.6 christos #else 433 1.8 christos typedef short yytype_int16; 434 1.1 christos #endif 435 1.1 christos 436 1.8 christos /* Work around bug in HP-UX 11.23, which defines these macros 437 1.8 christos incorrectly for preprocessor constants. This workaround can likely 438 1.8 christos be removed in 2023, as HPE has promised support for HP-UX 11.23 439 1.8 christos (aka HP-UX 11i v2) only through the end of 2022; see Table 2 of 440 1.8 christos <https://h20195.www2.hpe.com/V2/getpdf.aspx/4AA4-7673ENW.pdf>. */ 441 1.8 christos #ifdef __hpux 442 1.8 christos # undef UINT_LEAST8_MAX 443 1.8 christos # undef UINT_LEAST16_MAX 444 1.8 christos # define UINT_LEAST8_MAX 255 445 1.8 christos # define UINT_LEAST16_MAX 65535 446 1.8 christos #endif 447 1.8 christos 448 1.8 christos #if defined __UINT_LEAST8_MAX__ && __UINT_LEAST8_MAX__ <= __INT_MAX__ 449 1.8 christos typedef __UINT_LEAST8_TYPE__ yytype_uint8; 450 1.8 christos #elif (!defined __UINT_LEAST8_MAX__ && defined YY_STDINT_H \ 451 1.8 christos && UINT_LEAST8_MAX <= INT_MAX) 452 1.8 christos typedef uint_least8_t yytype_uint8; 453 1.8 christos #elif !defined __UINT_LEAST8_MAX__ && UCHAR_MAX <= INT_MAX 454 1.8 christos typedef unsigned char yytype_uint8; 455 1.1 christos #else 456 1.8 christos typedef short yytype_uint8; 457 1.1 christos #endif 458 1.1 christos 459 1.8 christos #if defined __UINT_LEAST16_MAX__ && __UINT_LEAST16_MAX__ <= __INT_MAX__ 460 1.8 christos typedef __UINT_LEAST16_TYPE__ yytype_uint16; 461 1.8 christos #elif (!defined __UINT_LEAST16_MAX__ && defined YY_STDINT_H \ 462 1.8 christos && UINT_LEAST16_MAX <= INT_MAX) 463 1.8 christos typedef uint_least16_t yytype_uint16; 464 1.8 christos #elif !defined __UINT_LEAST16_MAX__ && USHRT_MAX <= INT_MAX 465 1.8 christos typedef unsigned short yytype_uint16; 466 1.1 christos #else 467 1.8 christos typedef int yytype_uint16; 468 1.8 christos #endif 469 1.8 christos 470 1.8 christos #ifndef YYPTRDIFF_T 471 1.8 christos # if defined __PTRDIFF_TYPE__ && defined __PTRDIFF_MAX__ 472 1.8 christos # define YYPTRDIFF_T __PTRDIFF_TYPE__ 473 1.8 christos # define YYPTRDIFF_MAXIMUM __PTRDIFF_MAX__ 474 1.8 christos # elif defined PTRDIFF_MAX 475 1.8 christos # ifndef ptrdiff_t 476 1.8 christos # include <stddef.h> /* INFRINGES ON USER NAME SPACE */ 477 1.8 christos # endif 478 1.8 christos # define YYPTRDIFF_T ptrdiff_t 479 1.8 christos # define YYPTRDIFF_MAXIMUM PTRDIFF_MAX 480 1.8 christos # else 481 1.8 christos # define YYPTRDIFF_T long 482 1.8 christos # define YYPTRDIFF_MAXIMUM LONG_MAX 483 1.8 christos # endif 484 1.1 christos #endif 485 1.1 christos 486 1.1 christos #ifndef YYSIZE_T 487 1.1 christos # ifdef __SIZE_TYPE__ 488 1.1 christos # define YYSIZE_T __SIZE_TYPE__ 489 1.1 christos # elif defined size_t 490 1.1 christos # define YYSIZE_T size_t 491 1.8 christos # elif defined __STDC_VERSION__ && 199901 <= __STDC_VERSION__ 492 1.1 christos # include <stddef.h> /* INFRINGES ON USER NAME SPACE */ 493 1.1 christos # define YYSIZE_T size_t 494 1.1 christos # else 495 1.8 christos # define YYSIZE_T unsigned 496 1.1 christos # endif 497 1.1 christos #endif 498 1.1 christos 499 1.8 christos #define YYSIZE_MAXIMUM \ 500 1.8 christos YY_CAST (YYPTRDIFF_T, \ 501 1.8 christos (YYPTRDIFF_MAXIMUM < YY_CAST (YYSIZE_T, -1) \ 502 1.8 christos ? YYPTRDIFF_MAXIMUM \ 503 1.8 christos : YY_CAST (YYSIZE_T, -1))) 504 1.8 christos 505 1.8 christos #define YYSIZEOF(X) YY_CAST (YYPTRDIFF_T, sizeof (X)) 506 1.8 christos 507 1.8 christos 508 1.8 christos /* Stored state numbers (used for stacks). */ 509 1.8 christos typedef yytype_uint8 yy_state_t; 510 1.8 christos 511 1.8 christos /* State numbers in computations. */ 512 1.8 christos typedef int yy_state_fast_t; 513 1.1 christos 514 1.1 christos #ifndef YY_ 515 1.1 christos # if defined YYENABLE_NLS && YYENABLE_NLS 516 1.1 christos # if ENABLE_NLS 517 1.1 christos # include <libintl.h> /* INFRINGES ON USER NAME SPACE */ 518 1.6 christos # define YY_(Msgid) dgettext ("bison-runtime", Msgid) 519 1.1 christos # endif 520 1.1 christos # endif 521 1.1 christos # ifndef YY_ 522 1.6 christos # define YY_(Msgid) Msgid 523 1.6 christos # endif 524 1.6 christos #endif 525 1.6 christos 526 1.8 christos 527 1.8 christos #ifndef YY_ATTRIBUTE_PURE 528 1.8 christos # if defined __GNUC__ && 2 < __GNUC__ + (96 <= __GNUC_MINOR__) 529 1.8 christos # define YY_ATTRIBUTE_PURE __attribute__ ((__pure__)) 530 1.6 christos # else 531 1.8 christos # define YY_ATTRIBUTE_PURE 532 1.6 christos # endif 533 1.6 christos #endif 534 1.6 christos 535 1.6 christos #ifndef YY_ATTRIBUTE_UNUSED 536 1.8 christos # if defined __GNUC__ && 2 < __GNUC__ + (7 <= __GNUC_MINOR__) 537 1.8 christos # define YY_ATTRIBUTE_UNUSED __attribute__ ((__unused__)) 538 1.6 christos # else 539 1.8 christos # define YY_ATTRIBUTE_UNUSED 540 1.1 christos # endif 541 1.1 christos #endif 542 1.1 christos 543 1.1 christos /* Suppress unused-variable warnings by "using" E. */ 544 1.1 christos #if ! defined lint || defined __GNUC__ 545 1.8 christos # define YY_USE(E) ((void) (E)) 546 1.1 christos #else 547 1.8 christos # define YY_USE(E) /* empty */ 548 1.1 christos #endif 549 1.1 christos 550 1.6 christos /* Suppress an incorrect diagnostic about yylval being uninitialized. */ 551 1.8 christos #if defined __GNUC__ && ! defined __ICC && 406 <= __GNUC__ * 100 + __GNUC_MINOR__ 552 1.8 christos # if __GNUC__ * 100 + __GNUC_MINOR__ < 407 553 1.8 christos # define YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN \ 554 1.8 christos _Pragma ("GCC diagnostic push") \ 555 1.8 christos _Pragma ("GCC diagnostic ignored \"-Wuninitialized\"") 556 1.8 christos # else 557 1.8 christos # define YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN \ 558 1.8 christos _Pragma ("GCC diagnostic push") \ 559 1.8 christos _Pragma ("GCC diagnostic ignored \"-Wuninitialized\"") \ 560 1.6 christos _Pragma ("GCC diagnostic ignored \"-Wmaybe-uninitialized\"") 561 1.8 christos # endif 562 1.8 christos # define YY_IGNORE_MAYBE_UNINITIALIZED_END \ 563 1.6 christos _Pragma ("GCC diagnostic pop") 564 1.1 christos #else 565 1.6 christos # define YY_INITIAL_VALUE(Value) Value 566 1.6 christos #endif 567 1.6 christos #ifndef YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN 568 1.6 christos # define YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN 569 1.6 christos # define YY_IGNORE_MAYBE_UNINITIALIZED_END 570 1.3 christos #endif 571 1.6 christos #ifndef YY_INITIAL_VALUE 572 1.6 christos # define YY_INITIAL_VALUE(Value) /* Nothing. */ 573 1.1 christos #endif 574 1.1 christos 575 1.8 christos #if defined __cplusplus && defined __GNUC__ && ! defined __ICC && 6 <= __GNUC__ 576 1.8 christos # define YY_IGNORE_USELESS_CAST_BEGIN \ 577 1.8 christos _Pragma ("GCC diagnostic push") \ 578 1.8 christos _Pragma ("GCC diagnostic ignored \"-Wuseless-cast\"") 579 1.8 christos # define YY_IGNORE_USELESS_CAST_END \ 580 1.8 christos _Pragma ("GCC diagnostic pop") 581 1.8 christos #endif 582 1.8 christos #ifndef YY_IGNORE_USELESS_CAST_BEGIN 583 1.8 christos # define YY_IGNORE_USELESS_CAST_BEGIN 584 1.8 christos # define YY_IGNORE_USELESS_CAST_END 585 1.8 christos #endif 586 1.8 christos 587 1.8 christos 588 1.8 christos #define YY_ASSERT(E) ((void) (0 && (E))) 589 1.6 christos 590 1.8 christos #if !defined yyoverflow 591 1.1 christos 592 1.1 christos /* The parser invokes alloca or malloc; define the necessary symbols. */ 593 1.1 christos 594 1.1 christos # ifdef YYSTACK_USE_ALLOCA 595 1.1 christos # if YYSTACK_USE_ALLOCA 596 1.1 christos # ifdef __GNUC__ 597 1.1 christos # define YYSTACK_ALLOC __builtin_alloca 598 1.1 christos # elif defined __BUILTIN_VA_ARG_INCR 599 1.1 christos # include <alloca.h> /* INFRINGES ON USER NAME SPACE */ 600 1.1 christos # elif defined _AIX 601 1.1 christos # define YYSTACK_ALLOC __alloca 602 1.1 christos # elif defined _MSC_VER 603 1.1 christos # include <malloc.h> /* INFRINGES ON USER NAME SPACE */ 604 1.1 christos # define alloca _alloca 605 1.1 christos # else 606 1.1 christos # define YYSTACK_ALLOC alloca 607 1.6 christos # if ! defined _ALLOCA_H && ! defined EXIT_SUCCESS 608 1.1 christos # include <stdlib.h> /* INFRINGES ON USER NAME SPACE */ 609 1.6 christos /* Use EXIT_SUCCESS as a witness for stdlib.h. */ 610 1.6 christos # ifndef EXIT_SUCCESS 611 1.6 christos # define EXIT_SUCCESS 0 612 1.1 christos # endif 613 1.1 christos # endif 614 1.1 christos # endif 615 1.1 christos # endif 616 1.1 christos # endif 617 1.1 christos 618 1.1 christos # ifdef YYSTACK_ALLOC 619 1.6 christos /* Pacify GCC's 'empty if-body' warning. */ 620 1.6 christos # define YYSTACK_FREE(Ptr) do { /* empty */; } while (0) 621 1.1 christos # ifndef YYSTACK_ALLOC_MAXIMUM 622 1.1 christos /* The OS might guarantee only one guard page at the bottom of the stack, 623 1.1 christos and a page size can be as small as 4096 bytes. So we cannot safely 624 1.1 christos invoke alloca (N) if N exceeds 4096. Use a slightly smaller number 625 1.1 christos to allow for a few compiler-allocated temporary stack slots. */ 626 1.1 christos # define YYSTACK_ALLOC_MAXIMUM 4032 /* reasonable circa 2006 */ 627 1.1 christos # endif 628 1.1 christos # else 629 1.1 christos # define YYSTACK_ALLOC YYMALLOC 630 1.1 christos # define YYSTACK_FREE YYFREE 631 1.1 christos # ifndef YYSTACK_ALLOC_MAXIMUM 632 1.1 christos # define YYSTACK_ALLOC_MAXIMUM YYSIZE_MAXIMUM 633 1.1 christos # endif 634 1.6 christos # if (defined __cplusplus && ! defined EXIT_SUCCESS \ 635 1.1 christos && ! ((defined YYMALLOC || defined malloc) \ 636 1.6 christos && (defined YYFREE || defined free))) 637 1.1 christos # include <stdlib.h> /* INFRINGES ON USER NAME SPACE */ 638 1.6 christos # ifndef EXIT_SUCCESS 639 1.6 christos # define EXIT_SUCCESS 0 640 1.1 christos # endif 641 1.1 christos # endif 642 1.1 christos # ifndef YYMALLOC 643 1.1 christos # define YYMALLOC malloc 644 1.6 christos # if ! defined malloc && ! defined EXIT_SUCCESS 645 1.1 christos void *malloc (YYSIZE_T); /* INFRINGES ON USER NAME SPACE */ 646 1.1 christos # endif 647 1.1 christos # endif 648 1.1 christos # ifndef YYFREE 649 1.1 christos # define YYFREE free 650 1.6 christos # if ! defined free && ! defined EXIT_SUCCESS 651 1.1 christos void free (void *); /* INFRINGES ON USER NAME SPACE */ 652 1.1 christos # endif 653 1.1 christos # endif 654 1.1 christos # endif 655 1.8 christos #endif /* !defined yyoverflow */ 656 1.1 christos 657 1.1 christos #if (! defined yyoverflow \ 658 1.1 christos && (! defined __cplusplus \ 659 1.6 christos || (defined YYSTYPE_IS_TRIVIAL && YYSTYPE_IS_TRIVIAL))) 660 1.1 christos 661 1.1 christos /* A type that is properly aligned for any stack member. */ 662 1.1 christos union yyalloc 663 1.1 christos { 664 1.8 christos yy_state_t yyss_alloc; 665 1.6 christos YYSTYPE yyvs_alloc; 666 1.6 christos }; 667 1.1 christos 668 1.1 christos /* The size of the maximum gap between one aligned stack and the next. */ 669 1.8 christos # define YYSTACK_GAP_MAXIMUM (YYSIZEOF (union yyalloc) - 1) 670 1.1 christos 671 1.1 christos /* The size of an array large to enough to hold all stacks, each with 672 1.1 christos N elements. */ 673 1.1 christos # define YYSTACK_BYTES(N) \ 674 1.8 christos ((N) * (YYSIZEOF (yy_state_t) + YYSIZEOF (YYSTYPE)) \ 675 1.1 christos + YYSTACK_GAP_MAXIMUM) 676 1.1 christos 677 1.6 christos # define YYCOPY_NEEDED 1 678 1.1 christos 679 1.1 christos /* Relocate STACK from its old location to the new one. The 680 1.1 christos local variables YYSIZE and YYSTACKSIZE give the old and new number of 681 1.1 christos elements in the stack, and YYPTR gives the new location of the 682 1.1 christos stack. Advance YYPTR to a properly aligned location for the next 683 1.1 christos stack. */ 684 1.6 christos # define YYSTACK_RELOCATE(Stack_alloc, Stack) \ 685 1.6 christos do \ 686 1.6 christos { \ 687 1.8 christos YYPTRDIFF_T yynewbytes; \ 688 1.6 christos YYCOPY (&yyptr->Stack_alloc, Stack, yysize); \ 689 1.6 christos Stack = &yyptr->Stack_alloc; \ 690 1.8 christos yynewbytes = yystacksize * YYSIZEOF (*Stack) + YYSTACK_GAP_MAXIMUM; \ 691 1.8 christos yyptr += yynewbytes / YYSIZEOF (*yyptr); \ 692 1.6 christos } \ 693 1.6 christos while (0) 694 1.1 christos 695 1.1 christos #endif 696 1.1 christos 697 1.6 christos #if defined YYCOPY_NEEDED && YYCOPY_NEEDED 698 1.6 christos /* Copy COUNT objects from SRC to DST. The source and destination do 699 1.6 christos not overlap. */ 700 1.6 christos # ifndef YYCOPY 701 1.6 christos # if defined __GNUC__ && 1 < __GNUC__ 702 1.6 christos # define YYCOPY(Dst, Src, Count) \ 703 1.8 christos __builtin_memcpy (Dst, Src, YY_CAST (YYSIZE_T, (Count)) * sizeof (*(Src))) 704 1.6 christos # else 705 1.6 christos # define YYCOPY(Dst, Src, Count) \ 706 1.6 christos do \ 707 1.6 christos { \ 708 1.8 christos YYPTRDIFF_T yyi; \ 709 1.6 christos for (yyi = 0; yyi < (Count); yyi++) \ 710 1.6 christos (Dst)[yyi] = (Src)[yyi]; \ 711 1.6 christos } \ 712 1.6 christos while (0) 713 1.6 christos # endif 714 1.6 christos # endif 715 1.6 christos #endif /* !YYCOPY_NEEDED */ 716 1.6 christos 717 1.1 christos /* YYFINAL -- State number of the termination state. */ 718 1.9 christos #define YYFINAL 73 719 1.1 christos /* YYLAST -- Last index in YYTABLE. */ 720 1.9 christos #define YYLAST 161 721 1.1 christos 722 1.1 christos /* YYNTOKENS -- Number of terminals. */ 723 1.9 christos #define YYNTOKENS 36 724 1.1 christos /* YYNNTS -- Number of nonterminals. */ 725 1.9 christos #define YYNNTS 28 726 1.1 christos /* YYNRULES -- Number of rules. */ 727 1.9 christos #define YYNRULES 104 728 1.6 christos /* YYNSTATES -- Number of states. */ 729 1.9 christos #define YYNSTATES 153 730 1.1 christos 731 1.8 christos /* YYMAXUTOK -- Last valid token kind. */ 732 1.9 christos #define YYMAXUTOK 286 733 1.1 christos 734 1.8 christos 735 1.8 christos /* YYTRANSLATE(TOKEN-NUM) -- Symbol number corresponding to TOKEN-NUM 736 1.8 christos as returned by yylex, with out-of-bounds checking. */ 737 1.8 christos #define YYTRANSLATE(YYX) \ 738 1.8 christos (0 <= (YYX) && (YYX) <= YYMAXUTOK \ 739 1.8 christos ? YY_CAST (yysymbol_kind_t, yytranslate[YYX]) \ 740 1.8 christos : YYSYMBOL_YYUNDEF) 741 1.1 christos 742 1.6 christos /* YYTRANSLATE[TOKEN-NUM] -- Symbol number corresponding to TOKEN-NUM 743 1.8 christos as returned by yylex. */ 744 1.8 christos static const yytype_int8 yytranslate[] = 745 1.1 christos { 746 1.1 christos 0, 2, 2, 2, 2, 2, 2, 2, 2, 2, 747 1.1 christos 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 748 1.1 christos 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 749 1.1 christos 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 750 1.9 christos 2, 2, 2, 2, 33, 2, 32, 2, 2, 2, 751 1.1 christos 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 752 1.9 christos 2, 34, 2, 2, 35, 2, 2, 2, 2, 2, 753 1.1 christos 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 754 1.1 christos 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 755 1.1 christos 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 756 1.1 christos 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 757 1.1 christos 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 758 1.1 christos 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 759 1.1 christos 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 760 1.1 christos 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 761 1.1 christos 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 762 1.1 christos 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 763 1.1 christos 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 764 1.1 christos 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 765 1.1 christos 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 766 1.1 christos 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 767 1.1 christos 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 768 1.1 christos 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 769 1.1 christos 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 770 1.1 christos 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 771 1.1 christos 2, 2, 2, 2, 2, 2, 1, 2, 3, 4, 772 1.1 christos 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 773 1.1 christos 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 774 1.9 christos 25, 26, 27, 28, 29, 30, 31 775 1.1 christos }; 776 1.1 christos 777 1.1 christos #if YYDEBUG 778 1.8 christos /* YYRLINE[YYN] -- Source line where rule number YYN was defined. */ 779 1.8 christos static const yytype_int16 yyrline[] = 780 1.1 christos { 781 1.9 christos 0, 142, 142, 143, 147, 148, 149, 150, 151, 152, 782 1.9 christos 153, 154, 155, 156, 157, 158, 159, 160, 161, 165, 783 1.9 christos 167, 168, 175, 182, 183, 186, 187, 188, 189, 190, 784 1.9 christos 191, 192, 193, 196, 197, 201, 203, 205, 207, 209, 785 1.9 christos 211, 216, 217, 221, 222, 226, 227, 231, 232, 234, 786 1.9 christos 235, 239, 240, 241, 242, 246, 247, 248, 249, 250, 787 1.9 christos 251, 252, 253, 254, 255, 256, 257, 258, 265, 266, 788 1.9 christos 267, 268, 269, 270, 271, 272, 273, 274, 277, 278, 789 1.9 christos 284, 290, 296, 304, 305, 308, 309, 313, 314, 318, 790 1.9 christos 319, 322, 323, 326, 327, 333, 342, 343, 344, 347, 791 1.9 christos 348, 351, 352, 355, 357 792 1.1 christos }; 793 1.1 christos #endif 794 1.1 christos 795 1.8 christos /** Accessing symbol of state STATE. */ 796 1.8 christos #define YY_ACCESSING_SYMBOL(State) YY_CAST (yysymbol_kind_t, yystos[State]) 797 1.8 christos 798 1.8 christos #if YYDEBUG || 0 799 1.8 christos /* The user-facing name of the symbol whose (internal) number is 800 1.8 christos YYSYMBOL. No bounds checking. */ 801 1.8 christos static const char *yysymbol_name (yysymbol_kind_t yysymbol) YY_ATTRIBUTE_UNUSED; 802 1.8 christos 803 1.1 christos /* YYTNAME[SYMBOL-NUM] -- String name of the symbol SYMBOL-NUM. 804 1.1 christos First, the terminals, then, starting at YYNTOKENS, nonterminals. */ 805 1.1 christos static const char *const yytname[] = 806 1.1 christos { 807 1.8 christos "\"end of file\"", "error", "\"invalid token\"", "NAME", "LIBRARY", 808 1.8 christos "DESCRIPTION", "STACKSIZE_K", "HEAPSIZE", "CODE", "DATAU", "DATAL", 809 1.8 christos "SECTIONS", "EXPORTS", "IMPORTS", "VERSIONK", "BASE", "CONSTANTU", 810 1.9 christos "CONSTANTL", "PRIVATEU", "PRIVATEL", "ALIGNCOMM", "EXCLUDE_SYMBOLS", 811 1.9 christos "READ", "WRITE", "EXECUTE", "SHARED_K", "NONAMEU", "NONAMEL", 812 1.9 christos "DIRECTIVE", "EQUAL", "ID", "DIGITS", "'.'", "','", "'='", "'@'", 813 1.9 christos "$accept", "start", "command", "explist", "expline", "exp_opt_list", 814 1.9 christos "exp_opt", "implist", "impline", "seclist", "secline", "attr_list", 815 1.9 christos "opt_comma", "opt_number", "attr", "keyword_as_name", "opt_name2", 816 1.9 christos "opt_name", "opt_equalequal_name", "opt_ordinal", "opt_equal_name", 817 1.9 christos "opt_base", "anylang_id", "symbol_list", "opt_digits", "opt_id", 818 1.9 christos "NUMBER", "VMA", YY_NULLPTR 819 1.1 christos }; 820 1.8 christos 821 1.8 christos static const char * 822 1.8 christos yysymbol_name (yysymbol_kind_t yysymbol) 823 1.8 christos { 824 1.8 christos return yytname[yysymbol]; 825 1.8 christos } 826 1.1 christos #endif 827 1.1 christos 828 1.9 christos #define YYPACT_NINF (-85) 829 1.6 christos 830 1.8 christos #define yypact_value_is_default(Yyn) \ 831 1.8 christos ((Yyn) == YYPACT_NINF) 832 1.6 christos 833 1.9 christos #define YYTABLE_NINF (-49) 834 1.6 christos 835 1.8 christos #define yytable_value_is_error(Yyn) \ 836 1.6 christos 0 837 1.3 christos 838 1.8 christos /* YYPACT[STATE-NUM] -- Index in YYTABLE of the portion describing 839 1.8 christos STATE-NUM. */ 840 1.6 christos static const yytype_int8 yypact[] = 841 1.5 christos { 842 1.9 christos 93, 5, 5, -14, 7, 7, 38, 38, 16, 5, 843 1.9 christos 46, 7, -27, -27, 57, 36, -85, -85, -85, -85, 844 1.9 christos -85, -85, -85, -85, -85, -85, -85, -85, -85, -85, 845 1.9 christos -85, -85, -85, -85, -85, -85, -85, -85, -85, -85, 846 1.9 christos 61, 5, 76, -85, 102, 102, -85, -85, 95, 95, 847 1.9 christos -85, -85, -85, -85, 87, -85, 87, 100, 16, -85, 848 1.9 christos 5, -85, 84, -25, 46, -85, 97, -85, 101, 53, 849 1.9 christos 103, 37, -85, -85, -85, 5, 76, -85, 5, 98, 850 1.9 christos -85, -85, 7, -85, -85, -85, 38, -85, 87, -85, 851 1.9 christos -85, 5, 99, 106, 107, -85, 7, -85, 109, 7, 852 1.9 christos -27, 103, -85, -85, 110, -85, -85, -85, 7, 105, 853 1.9 christos 26, 111, -85, -85, 112, -85, 103, -85, -85, -85, 854 1.9 christos 56, 114, 115, -85, 85, -85, -85, -85, -85, -85, 855 1.9 christos -85, -85, -85, -85, -85, 105, 105, -85, 104, 63, 856 1.9 christos 104, 104, 56, -85, 96, -85, -85, -85, -85, 104, 857 1.9 christos 104, -85, -85 858 1.5 christos }; 859 1.3 christos 860 1.8 christos /* YYDEFACT[STATE-NUM] -- Default reduction number in state STATE-NUM. 861 1.8 christos Performed when YYTABLE does not specify something else to do. Zero 862 1.8 christos means the default is an error. */ 863 1.8 christos static const yytype_int8 yydefact[] = 864 1.5 christos { 865 1.9 christos 0, 84, 84, 0, 0, 0, 0, 0, 0, 19, 866 1.9 christos 0, 0, 0, 0, 0, 0, 3, 68, 61, 75, 867 1.9 christos 66, 56, 59, 60, 65, 67, 76, 55, 57, 58, 868 1.9 christos 71, 72, 63, 73, 77, 64, 74, 69, 70, 62, 869 1.9 christos 78, 0, 0, 83, 92, 92, 6, 103, 50, 50, 870 1.9 christos 51, 52, 53, 54, 9, 46, 10, 0, 11, 42, 871 1.9 christos 12, 20, 90, 0, 13, 34, 14, 93, 0, 0, 872 1.9 christos 96, 18, 16, 1, 2, 0, 79, 80, 0, 0, 873 1.9 christos 4, 5, 0, 7, 8, 47, 0, 44, 43, 41, 874 1.9 christos 21, 0, 88, 0, 0, 33, 0, 94, 100, 0, 875 1.9 christos 0, 97, 82, 81, 0, 49, 45, 89, 0, 48, 876 1.9 christos 86, 0, 15, 99, 102, 17, 98, 104, 91, 87, 877 1.9 christos 24, 0, 0, 40, 0, 101, 95, 29, 30, 27, 878 1.9 christos 28, 31, 32, 25, 26, 48, 48, 85, 86, 86, 879 1.9 christos 86, 86, 24, 39, 0, 37, 38, 22, 23, 86, 880 1.9 christos 86, 35, 36 881 1.5 christos }; 882 1.3 christos 883 1.8 christos /* YYPGOTO[NTERM-NUM]. */ 884 1.6 christos static const yytype_int16 yypgoto[] = 885 1.6 christos { 886 1.9 christos -85, -85, 131, -85, 88, 8, -85, -85, 83, -85, 887 1.9 christos 91, -3, -84, 108, 65, 113, -7, 150, -60, -85, 888 1.9 christos -85, 116, -12, -85, -85, -85, -5, -85 889 1.6 christos }; 890 1.6 christos 891 1.8 christos /* YYDEFGOTO[NTERM-NUM]. */ 892 1.8 christos static const yytype_uint8 yydefgoto[] = 893 1.5 christos { 894 1.9 christos 0, 15, 16, 60, 61, 135, 136, 64, 65, 58, 895 1.9 christos 59, 54, 86, 83, 55, 42, 43, 44, 123, 109, 896 1.9 christos 92, 80, 69, 71, 114, 126, 48, 118 897 1.5 christos }; 898 1.1 christos 899 1.8 christos /* YYTABLE[YYPACT[STATE-NUM]] -- What to do in state STATE-NUM. If 900 1.8 christos positive, shift that token. If negative, reduce the rule whose 901 1.8 christos number is the opposite. If YYTABLE_NINF, syntax error. */ 902 1.1 christos static const yytype_int16 yytable[] = 903 1.1 christos { 904 1.9 christos 49, 70, 62, 67, 56, 68, 66, 93, 17, 94, 905 1.9 christos 18, 19, 20, 21, 22, 23, 46, 24, 25, 26, 906 1.9 christos 27, 28, 29, 30, 31, 120, 32, 33, 34, 35, 907 1.9 christos 36, 37, 38, 39, 77, 40, 73, 41, 47, 1, 908 1.9 christos 2, 3, 4, 5, 6, 7, 57, 8, 9, 10, 909 1.9 christos 11, 141, 142, 62, 88, 121, 12, 13, 122, 101, 910 1.9 christos 50, 51, 52, 53, 14, 127, 128, 67, 102, 68, 911 1.9 christos 100, 103, 129, 130, 131, 132, 63, 105, 143, 145, 912 1.9 christos 146, 147, 133, 134, 107, 98, 99, 72, 116, 151, 913 1.9 christos 152, 112, 121, 75, 115, 144, 1, 2, 3, 4, 914 1.9 christos 5, 6, 7, 119, 8, 9, 10, 11, 78, -48, 915 1.9 christos -48, -48, -48, 12, 13, 139, 47, 79, 91, 140, 916 1.9 christos 85, 14, 50, 51, 52, 53, 149, 47, 82, 96, 917 1.9 christos 87, 97, 104, 121, 108, 98, 110, 111, 85, 150, 918 1.9 christos 113, 117, 125, 124, 137, 138, 74, 95, 90, 89, 919 1.9 christos 148, 106, 45, 0, 76, 0, 0, 84, 0, 0, 920 1.9 christos 0, 81 921 1.1 christos }; 922 1.1 christos 923 1.1 christos static const yytype_int16 yycheck[] = 924 1.1 christos { 925 1.9 christos 5, 13, 9, 30, 7, 32, 11, 32, 3, 34, 926 1.9 christos 5, 6, 7, 8, 9, 10, 30, 12, 13, 14, 927 1.9 christos 15, 16, 17, 18, 19, 109, 21, 22, 23, 24, 928 1.9 christos 25, 26, 27, 28, 41, 30, 0, 32, 31, 3, 929 1.9 christos 4, 5, 6, 7, 8, 9, 30, 11, 12, 13, 930 1.9 christos 14, 135, 136, 60, 57, 29, 20, 21, 32, 71, 931 1.9 christos 22, 23, 24, 25, 28, 9, 10, 30, 75, 32, 932 1.9 christos 33, 78, 16, 17, 18, 19, 30, 82, 138, 139, 933 1.9 christos 140, 141, 26, 27, 91, 32, 33, 30, 100, 149, 934 1.9 christos 150, 96, 29, 32, 99, 32, 3, 4, 5, 6, 935 1.9 christos 7, 8, 9, 108, 11, 12, 13, 14, 32, 22, 936 1.9 christos 23, 24, 25, 20, 21, 30, 31, 15, 34, 124, 937 1.9 christos 33, 28, 22, 23, 24, 25, 30, 31, 33, 32, 938 1.9 christos 30, 30, 34, 29, 35, 32, 30, 30, 33, 144, 939 1.9 christos 31, 31, 30, 32, 30, 30, 15, 64, 60, 58, 940 1.9 christos 142, 86, 2, -1, 41, -1, -1, 49, -1, -1, 941 1.9 christos -1, 45 942 1.1 christos }; 943 1.1 christos 944 1.8 christos /* YYSTOS[STATE-NUM] -- The symbol kind of the accessing symbol of 945 1.8 christos state STATE-NUM. */ 946 1.8 christos static const yytype_int8 yystos[] = 947 1.1 christos { 948 1.1 christos 0, 3, 4, 5, 6, 7, 8, 9, 11, 12, 949 1.9 christos 13, 14, 20, 21, 28, 37, 38, 3, 5, 6, 950 1.9 christos 7, 8, 9, 10, 12, 13, 14, 15, 16, 17, 951 1.9 christos 18, 19, 21, 22, 23, 24, 25, 26, 27, 28, 952 1.9 christos 30, 32, 51, 52, 53, 53, 30, 31, 62, 62, 953 1.9 christos 22, 23, 24, 25, 47, 50, 47, 30, 45, 46, 954 1.9 christos 39, 40, 52, 30, 43, 44, 62, 30, 32, 58, 955 1.9 christos 58, 59, 30, 0, 38, 32, 51, 52, 32, 15, 956 1.9 christos 57, 57, 33, 49, 49, 33, 48, 30, 47, 46, 957 1.9 christos 40, 34, 56, 32, 34, 44, 32, 30, 32, 33, 958 1.9 christos 33, 58, 52, 52, 34, 62, 50, 52, 35, 55, 959 1.9 christos 30, 30, 62, 31, 60, 62, 58, 31, 63, 62, 960 1.9 christos 48, 29, 32, 54, 32, 30, 61, 9, 10, 16, 961 1.9 christos 17, 18, 19, 26, 27, 41, 42, 30, 30, 30, 962 1.9 christos 62, 48, 48, 54, 32, 54, 54, 54, 41, 30, 963 1.9 christos 62, 54, 54 964 1.1 christos }; 965 1.1 christos 966 1.8 christos /* YYR1[RULE-NUM] -- Symbol kind of the left-hand side of rule RULE-NUM. */ 967 1.8 christos static const yytype_int8 yyr1[] = 968 1.6 christos { 969 1.9 christos 0, 36, 37, 37, 38, 38, 38, 38, 38, 38, 970 1.9 christos 38, 38, 38, 38, 38, 38, 38, 38, 38, 39, 971 1.9 christos 39, 39, 40, 41, 41, 42, 42, 42, 42, 42, 972 1.9 christos 42, 42, 42, 43, 43, 44, 44, 44, 44, 44, 973 1.9 christos 44, 45, 45, 46, 46, 47, 47, 48, 48, 49, 974 1.9 christos 49, 50, 50, 50, 50, 51, 51, 51, 51, 51, 975 1.9 christos 51, 51, 51, 51, 51, 51, 51, 51, 51, 51, 976 1.9 christos 51, 51, 51, 51, 51, 51, 51, 51, 52, 52, 977 1.9 christos 52, 52, 52, 53, 53, 54, 54, 55, 55, 56, 978 1.9 christos 56, 57, 57, 58, 58, 58, 59, 59, 59, 60, 979 1.9 christos 60, 61, 61, 62, 63 980 1.6 christos }; 981 1.1 christos 982 1.8 christos /* YYR2[RULE-NUM] -- Number of symbols on the right-hand side of rule RULE-NUM. */ 983 1.8 christos static const yytype_int8 yyr2[] = 984 1.6 christos { 985 1.6 christos 0, 2, 2, 1, 3, 3, 2, 3, 3, 2, 986 1.9 christos 2, 2, 2, 2, 2, 4, 2, 4, 2, 0, 987 1.9 christos 1, 2, 7, 3, 0, 1, 1, 1, 1, 1, 988 1.9 christos 1, 1, 1, 2, 1, 8, 8, 6, 6, 6, 989 1.9 christos 4, 2, 1, 2, 2, 3, 1, 1, 0, 2, 990 1.9 christos 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 991 1.6 christos 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 992 1.9 christos 1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 993 1.9 christos 2, 3, 3, 1, 0, 2, 0, 2, 0, 2, 994 1.9 christos 0, 3, 0, 1, 2, 4, 1, 2, 3, 1, 995 1.9 christos 0, 1, 0, 1, 1 996 1.6 christos }; 997 1.1 christos 998 1.1 christos 999 1.8 christos enum { YYENOMEM = -2 }; 1000 1.8 christos 1001 1.6 christos #define yyerrok (yyerrstatus = 0) 1002 1.6 christos #define yyclearin (yychar = YYEMPTY) 1003 1.6 christos 1004 1.6 christos #define YYACCEPT goto yyacceptlab 1005 1.6 christos #define YYABORT goto yyabortlab 1006 1.6 christos #define YYERROR goto yyerrorlab 1007 1.8 christos #define YYNOMEM goto yyexhaustedlab 1008 1.1 christos 1009 1.1 christos 1010 1.1 christos #define YYRECOVERING() (!!yyerrstatus) 1011 1.1 christos 1012 1.8 christos #define YYBACKUP(Token, Value) \ 1013 1.8 christos do \ 1014 1.8 christos if (yychar == YYEMPTY) \ 1015 1.8 christos { \ 1016 1.8 christos yychar = (Token); \ 1017 1.8 christos yylval = (Value); \ 1018 1.8 christos YYPOPSTACK (yylen); \ 1019 1.8 christos yystate = *yyssp; \ 1020 1.8 christos goto yybackup; \ 1021 1.8 christos } \ 1022 1.8 christos else \ 1023 1.8 christos { \ 1024 1.8 christos yyerror (YY_("syntax error: cannot back up")); \ 1025 1.8 christos YYERROR; \ 1026 1.8 christos } \ 1027 1.8 christos while (0) 1028 1.8 christos 1029 1.8 christos /* Backward compatibility with an undocumented macro. 1030 1.8 christos Use YYerror or YYUNDEF. */ 1031 1.8 christos #define YYERRCODE YYUNDEF 1032 1.1 christos 1033 1.1 christos 1034 1.1 christos /* Enable debugging if requested. */ 1035 1.1 christos #if YYDEBUG 1036 1.1 christos 1037 1.1 christos # ifndef YYFPRINTF 1038 1.1 christos # include <stdio.h> /* INFRINGES ON USER NAME SPACE */ 1039 1.1 christos # define YYFPRINTF fprintf 1040 1.1 christos # endif 1041 1.1 christos 1042 1.6 christos # define YYDPRINTF(Args) \ 1043 1.6 christos do { \ 1044 1.6 christos if (yydebug) \ 1045 1.6 christos YYFPRINTF Args; \ 1046 1.6 christos } while (0) 1047 1.6 christos 1048 1.6 christos 1049 1.3 christos 1050 1.8 christos 1051 1.8 christos # define YY_SYMBOL_PRINT(Title, Kind, Value, Location) \ 1052 1.6 christos do { \ 1053 1.6 christos if (yydebug) \ 1054 1.6 christos { \ 1055 1.6 christos YYFPRINTF (stderr, "%s ", Title); \ 1056 1.6 christos yy_symbol_print (stderr, \ 1057 1.8 christos Kind, Value); \ 1058 1.6 christos YYFPRINTF (stderr, "\n"); \ 1059 1.6 christos } \ 1060 1.6 christos } while (0) 1061 1.1 christos 1062 1.1 christos 1063 1.8 christos /*-----------------------------------. 1064 1.8 christos | Print this symbol's value on YYO. | 1065 1.8 christos `-----------------------------------*/ 1066 1.6 christos 1067 1.1 christos static void 1068 1.8 christos yy_symbol_value_print (FILE *yyo, 1069 1.8 christos yysymbol_kind_t yykind, YYSTYPE const * const yyvaluep) 1070 1.1 christos { 1071 1.8 christos FILE *yyoutput = yyo; 1072 1.8 christos YY_USE (yyoutput); 1073 1.1 christos if (!yyvaluep) 1074 1.1 christos return; 1075 1.8 christos YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN 1076 1.8 christos YY_USE (yykind); 1077 1.8 christos YY_IGNORE_MAYBE_UNINITIALIZED_END 1078 1.1 christos } 1079 1.1 christos 1080 1.1 christos 1081 1.8 christos /*---------------------------. 1082 1.8 christos | Print this symbol on YYO. | 1083 1.8 christos `---------------------------*/ 1084 1.1 christos 1085 1.1 christos static void 1086 1.8 christos yy_symbol_print (FILE *yyo, 1087 1.8 christos yysymbol_kind_t yykind, YYSTYPE const * const yyvaluep) 1088 1.1 christos { 1089 1.8 christos YYFPRINTF (yyo, "%s %s (", 1090 1.8 christos yykind < YYNTOKENS ? "token" : "nterm", yysymbol_name (yykind)); 1091 1.1 christos 1092 1.8 christos yy_symbol_value_print (yyo, yykind, yyvaluep); 1093 1.8 christos YYFPRINTF (yyo, ")"); 1094 1.1 christos } 1095 1.1 christos 1096 1.1 christos /*------------------------------------------------------------------. 1097 1.1 christos | yy_stack_print -- Print the state stack from its BOTTOM up to its | 1098 1.1 christos | TOP (included). | 1099 1.1 christos `------------------------------------------------------------------*/ 1100 1.1 christos 1101 1.1 christos static void 1102 1.8 christos yy_stack_print (yy_state_t *yybottom, yy_state_t *yytop) 1103 1.1 christos { 1104 1.1 christos YYFPRINTF (stderr, "Stack now"); 1105 1.6 christos for (; yybottom <= yytop; yybottom++) 1106 1.6 christos { 1107 1.6 christos int yybot = *yybottom; 1108 1.6 christos YYFPRINTF (stderr, " %d", yybot); 1109 1.6 christos } 1110 1.1 christos YYFPRINTF (stderr, "\n"); 1111 1.1 christos } 1112 1.1 christos 1113 1.6 christos # define YY_STACK_PRINT(Bottom, Top) \ 1114 1.6 christos do { \ 1115 1.6 christos if (yydebug) \ 1116 1.6 christos yy_stack_print ((Bottom), (Top)); \ 1117 1.6 christos } while (0) 1118 1.1 christos 1119 1.1 christos 1120 1.1 christos /*------------------------------------------------. 1121 1.1 christos | Report that the YYRULE is going to be reduced. | 1122 1.1 christos `------------------------------------------------*/ 1123 1.1 christos 1124 1.1 christos static void 1125 1.8 christos yy_reduce_print (yy_state_t *yyssp, YYSTYPE *yyvsp, 1126 1.8 christos int yyrule) 1127 1.1 christos { 1128 1.8 christos int yylno = yyrline[yyrule]; 1129 1.1 christos int yynrhs = yyr2[yyrule]; 1130 1.1 christos int yyi; 1131 1.8 christos YYFPRINTF (stderr, "Reducing stack by rule %d (line %d):\n", 1132 1.6 christos yyrule - 1, yylno); 1133 1.1 christos /* The symbols being reduced. */ 1134 1.1 christos for (yyi = 0; yyi < yynrhs; yyi++) 1135 1.1 christos { 1136 1.6 christos YYFPRINTF (stderr, " $%d = ", yyi + 1); 1137 1.6 christos yy_symbol_print (stderr, 1138 1.8 christos YY_ACCESSING_SYMBOL (+yyssp[yyi + 1 - yynrhs]), 1139 1.8 christos &yyvsp[(yyi + 1) - (yynrhs)]); 1140 1.6 christos YYFPRINTF (stderr, "\n"); 1141 1.1 christos } 1142 1.1 christos } 1143 1.1 christos 1144 1.6 christos # define YY_REDUCE_PRINT(Rule) \ 1145 1.6 christos do { \ 1146 1.6 christos if (yydebug) \ 1147 1.6 christos yy_reduce_print (yyssp, yyvsp, Rule); \ 1148 1.6 christos } while (0) 1149 1.1 christos 1150 1.1 christos /* Nonzero means print parse trace. It is left uninitialized so that 1151 1.1 christos multiple parsers can coexist. */ 1152 1.1 christos int yydebug; 1153 1.1 christos #else /* !YYDEBUG */ 1154 1.8 christos # define YYDPRINTF(Args) ((void) 0) 1155 1.8 christos # define YY_SYMBOL_PRINT(Title, Kind, Value, Location) 1156 1.1 christos # define YY_STACK_PRINT(Bottom, Top) 1157 1.1 christos # define YY_REDUCE_PRINT(Rule) 1158 1.1 christos #endif /* !YYDEBUG */ 1159 1.1 christos 1160 1.1 christos 1161 1.1 christos /* YYINITDEPTH -- initial size of the parser's stacks. */ 1162 1.6 christos #ifndef YYINITDEPTH 1163 1.1 christos # define YYINITDEPTH 200 1164 1.1 christos #endif 1165 1.1 christos 1166 1.1 christos /* YYMAXDEPTH -- maximum size the stacks can grow to (effective only 1167 1.1 christos if the built-in stack extension method is used). 1168 1.1 christos 1169 1.1 christos Do not make this value too large; the results are undefined if 1170 1.1 christos YYSTACK_ALLOC_MAXIMUM < YYSTACK_BYTES (YYMAXDEPTH) 1171 1.1 christos evaluated with infinite-precision integer arithmetic. */ 1172 1.1 christos 1173 1.1 christos #ifndef YYMAXDEPTH 1174 1.1 christos # define YYMAXDEPTH 10000 1175 1.1 christos #endif 1176 1.1 christos 1177 1.1 christos 1178 1.1 christos 1179 1.1 christos 1180 1.1 christos 1181 1.1 christos 1182 1.1 christos /*-----------------------------------------------. 1183 1.1 christos | Release the memory associated to this symbol. | 1184 1.1 christos `-----------------------------------------------*/ 1185 1.1 christos 1186 1.1 christos static void 1187 1.8 christos yydestruct (const char *yymsg, 1188 1.8 christos yysymbol_kind_t yykind, YYSTYPE *yyvaluep) 1189 1.1 christos { 1190 1.8 christos YY_USE (yyvaluep); 1191 1.1 christos if (!yymsg) 1192 1.1 christos yymsg = "Deleting"; 1193 1.8 christos YY_SYMBOL_PRINT (yymsg, yykind, yyvaluep, yylocationp); 1194 1.1 christos 1195 1.6 christos YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN 1196 1.8 christos YY_USE (yykind); 1197 1.6 christos YY_IGNORE_MAYBE_UNINITIALIZED_END 1198 1.1 christos } 1199 1.1 christos 1200 1.1 christos 1201 1.8 christos /* Lookahead token kind. */ 1202 1.1 christos int yychar; 1203 1.1 christos 1204 1.6 christos /* The semantic value of the lookahead symbol. */ 1205 1.1 christos YYSTYPE yylval; 1206 1.1 christos /* Number of syntax errors so far. */ 1207 1.1 christos int yynerrs; 1208 1.1 christos 1209 1.1 christos 1210 1.8 christos 1211 1.8 christos 1212 1.1 christos /*----------. 1213 1.1 christos | yyparse. | 1214 1.1 christos `----------*/ 1215 1.1 christos 1216 1.1 christos int 1217 1.1 christos yyparse (void) 1218 1.6 christos { 1219 1.8 christos yy_state_fast_t yystate = 0; 1220 1.6 christos /* Number of tokens to shift before error messages enabled. */ 1221 1.8 christos int yyerrstatus = 0; 1222 1.6 christos 1223 1.8 christos /* Refer to the stacks through separate pointers, to allow yyoverflow 1224 1.8 christos to reallocate them elsewhere. */ 1225 1.6 christos 1226 1.8 christos /* Their size. */ 1227 1.8 christos YYPTRDIFF_T yystacksize = YYINITDEPTH; 1228 1.6 christos 1229 1.8 christos /* The state stack: array, bottom, top. */ 1230 1.8 christos yy_state_t yyssa[YYINITDEPTH]; 1231 1.8 christos yy_state_t *yyss = yyssa; 1232 1.8 christos yy_state_t *yyssp = yyss; 1233 1.6 christos 1234 1.8 christos /* The semantic value stack: array, bottom, top. */ 1235 1.6 christos YYSTYPE yyvsa[YYINITDEPTH]; 1236 1.8 christos YYSTYPE *yyvs = yyvsa; 1237 1.8 christos YYSTYPE *yyvsp = yyvs; 1238 1.5 christos 1239 1.1 christos int yyn; 1240 1.8 christos /* The return value of yyparse. */ 1241 1.1 christos int yyresult; 1242 1.8 christos /* Lookahead symbol kind. */ 1243 1.8 christos yysymbol_kind_t yytoken = YYSYMBOL_YYEMPTY; 1244 1.6 christos /* The variables used to return semantic value and location from the 1245 1.6 christos action routines. */ 1246 1.6 christos YYSTYPE yyval; 1247 1.6 christos 1248 1.8 christos 1249 1.1 christos 1250 1.1 christos #define YYPOPSTACK(N) (yyvsp -= (N), yyssp -= (N)) 1251 1.1 christos 1252 1.1 christos /* The number of symbols on the RHS of the reduced rule. 1253 1.1 christos Keep to zero when no symbol should be popped. */ 1254 1.1 christos int yylen = 0; 1255 1.1 christos 1256 1.1 christos YYDPRINTF ((stderr, "Starting parse\n")); 1257 1.1 christos 1258 1.6 christos yychar = YYEMPTY; /* Cause a token to be read. */ 1259 1.8 christos 1260 1.1 christos goto yysetstate; 1261 1.1 christos 1262 1.8 christos 1263 1.1 christos /*------------------------------------------------------------. 1264 1.8 christos | yynewstate -- push a new state, which is found in yystate. | 1265 1.1 christos `------------------------------------------------------------*/ 1266 1.8 christos yynewstate: 1267 1.1 christos /* In all cases, when you get here, the value and location stacks 1268 1.1 christos have just been pushed. So pushing a state here evens the stacks. */ 1269 1.1 christos yyssp++; 1270 1.1 christos 1271 1.8 christos 1272 1.8 christos /*--------------------------------------------------------------------. 1273 1.8 christos | yysetstate -- set current state (the top of the stack) to yystate. | 1274 1.8 christos `--------------------------------------------------------------------*/ 1275 1.8 christos yysetstate: 1276 1.8 christos YYDPRINTF ((stderr, "Entering state %d\n", yystate)); 1277 1.8 christos YY_ASSERT (0 <= yystate && yystate < YYNSTATES); 1278 1.8 christos YY_IGNORE_USELESS_CAST_BEGIN 1279 1.8 christos *yyssp = YY_CAST (yy_state_t, yystate); 1280 1.8 christos YY_IGNORE_USELESS_CAST_END 1281 1.8 christos YY_STACK_PRINT (yyss, yyssp); 1282 1.1 christos 1283 1.1 christos if (yyss + yystacksize - 1 <= yyssp) 1284 1.8 christos #if !defined yyoverflow && !defined YYSTACK_RELOCATE 1285 1.8 christos YYNOMEM; 1286 1.8 christos #else 1287 1.1 christos { 1288 1.1 christos /* Get the current used size of the three stacks, in elements. */ 1289 1.8 christos YYPTRDIFF_T yysize = yyssp - yyss + 1; 1290 1.1 christos 1291 1.8 christos # if defined yyoverflow 1292 1.1 christos { 1293 1.6 christos /* Give user a chance to reallocate the stack. Use copies of 1294 1.6 christos these so that the &'s don't force the real ones into 1295 1.6 christos memory. */ 1296 1.8 christos yy_state_t *yyss1 = yyss; 1297 1.6 christos YYSTYPE *yyvs1 = yyvs; 1298 1.6 christos 1299 1.6 christos /* Each stack pointer address is followed by the size of the 1300 1.6 christos data in use in that stack, in bytes. This used to be a 1301 1.6 christos conditional around just the two extra args, but that might 1302 1.6 christos be undefined if yyoverflow is a macro. */ 1303 1.6 christos yyoverflow (YY_("memory exhausted"), 1304 1.8 christos &yyss1, yysize * YYSIZEOF (*yyssp), 1305 1.8 christos &yyvs1, yysize * YYSIZEOF (*yyvsp), 1306 1.6 christos &yystacksize); 1307 1.6 christos yyss = yyss1; 1308 1.6 christos yyvs = yyvs1; 1309 1.1 christos } 1310 1.8 christos # else /* defined YYSTACK_RELOCATE */ 1311 1.1 christos /* Extend the stack our own way. */ 1312 1.1 christos if (YYMAXDEPTH <= yystacksize) 1313 1.8 christos YYNOMEM; 1314 1.1 christos yystacksize *= 2; 1315 1.1 christos if (YYMAXDEPTH < yystacksize) 1316 1.6 christos yystacksize = YYMAXDEPTH; 1317 1.1 christos 1318 1.1 christos { 1319 1.8 christos yy_state_t *yyss1 = yyss; 1320 1.6 christos union yyalloc *yyptr = 1321 1.8 christos YY_CAST (union yyalloc *, 1322 1.8 christos YYSTACK_ALLOC (YY_CAST (YYSIZE_T, YYSTACK_BYTES (yystacksize)))); 1323 1.6 christos if (! yyptr) 1324 1.8 christos YYNOMEM; 1325 1.6 christos YYSTACK_RELOCATE (yyss_alloc, yyss); 1326 1.6 christos YYSTACK_RELOCATE (yyvs_alloc, yyvs); 1327 1.1 christos # undef YYSTACK_RELOCATE 1328 1.6 christos if (yyss1 != yyssa) 1329 1.6 christos YYSTACK_FREE (yyss1); 1330 1.1 christos } 1331 1.1 christos # endif 1332 1.1 christos 1333 1.1 christos yyssp = yyss + yysize - 1; 1334 1.1 christos yyvsp = yyvs + yysize - 1; 1335 1.1 christos 1336 1.8 christos YY_IGNORE_USELESS_CAST_BEGIN 1337 1.8 christos YYDPRINTF ((stderr, "Stack size increased to %ld\n", 1338 1.8 christos YY_CAST (long, yystacksize))); 1339 1.8 christos YY_IGNORE_USELESS_CAST_END 1340 1.1 christos 1341 1.1 christos if (yyss + yystacksize - 1 <= yyssp) 1342 1.6 christos YYABORT; 1343 1.1 christos } 1344 1.8 christos #endif /* !defined yyoverflow && !defined YYSTACK_RELOCATE */ 1345 1.1 christos 1346 1.1 christos 1347 1.6 christos if (yystate == YYFINAL) 1348 1.6 christos YYACCEPT; 1349 1.6 christos 1350 1.1 christos goto yybackup; 1351 1.1 christos 1352 1.8 christos 1353 1.1 christos /*-----------. 1354 1.1 christos | yybackup. | 1355 1.1 christos `-----------*/ 1356 1.1 christos yybackup: 1357 1.1 christos /* Do appropriate processing given the current state. Read a 1358 1.6 christos lookahead token if we need one and don't already have one. */ 1359 1.1 christos 1360 1.6 christos /* First try to decide what to do without reference to lookahead token. */ 1361 1.1 christos yyn = yypact[yystate]; 1362 1.6 christos if (yypact_value_is_default (yyn)) 1363 1.1 christos goto yydefault; 1364 1.1 christos 1365 1.6 christos /* Not known => get a lookahead token if don't already have one. */ 1366 1.1 christos 1367 1.8 christos /* YYCHAR is either empty, or end-of-input, or a valid lookahead. */ 1368 1.1 christos if (yychar == YYEMPTY) 1369 1.1 christos { 1370 1.8 christos YYDPRINTF ((stderr, "Reading a token\n")); 1371 1.6 christos yychar = yylex (); 1372 1.1 christos } 1373 1.1 christos 1374 1.1 christos if (yychar <= YYEOF) 1375 1.1 christos { 1376 1.8 christos yychar = YYEOF; 1377 1.8 christos yytoken = YYSYMBOL_YYEOF; 1378 1.1 christos YYDPRINTF ((stderr, "Now at end of input.\n")); 1379 1.1 christos } 1380 1.8 christos else if (yychar == YYerror) 1381 1.8 christos { 1382 1.8 christos /* The scanner already issued an error message, process directly 1383 1.8 christos to error recovery. But do not keep the error token as 1384 1.8 christos lookahead, it is too special and may lead us to an endless 1385 1.8 christos loop in error recovery. */ 1386 1.8 christos yychar = YYUNDEF; 1387 1.8 christos yytoken = YYSYMBOL_YYerror; 1388 1.8 christos goto yyerrlab1; 1389 1.8 christos } 1390 1.1 christos else 1391 1.1 christos { 1392 1.1 christos yytoken = YYTRANSLATE (yychar); 1393 1.1 christos YY_SYMBOL_PRINT ("Next token is", yytoken, &yylval, &yylloc); 1394 1.1 christos } 1395 1.1 christos 1396 1.1 christos /* If the proper action on seeing token YYTOKEN is to reduce or to 1397 1.1 christos detect an error, take that action. */ 1398 1.1 christos yyn += yytoken; 1399 1.1 christos if (yyn < 0 || YYLAST < yyn || yycheck[yyn] != yytoken) 1400 1.1 christos goto yydefault; 1401 1.1 christos yyn = yytable[yyn]; 1402 1.1 christos if (yyn <= 0) 1403 1.1 christos { 1404 1.6 christos if (yytable_value_is_error (yyn)) 1405 1.6 christos goto yyerrlab; 1406 1.1 christos yyn = -yyn; 1407 1.1 christos goto yyreduce; 1408 1.1 christos } 1409 1.1 christos 1410 1.1 christos /* Count tokens shifted since error; after three, turn off error 1411 1.1 christos status. */ 1412 1.1 christos if (yyerrstatus) 1413 1.1 christos yyerrstatus--; 1414 1.1 christos 1415 1.6 christos /* Shift the lookahead token. */ 1416 1.1 christos YY_SYMBOL_PRINT ("Shifting", yytoken, &yylval, &yylloc); 1417 1.1 christos yystate = yyn; 1418 1.6 christos YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN 1419 1.1 christos *++yyvsp = yylval; 1420 1.6 christos YY_IGNORE_MAYBE_UNINITIALIZED_END 1421 1.1 christos 1422 1.8 christos /* Discard the shifted token. */ 1423 1.8 christos yychar = YYEMPTY; 1424 1.1 christos goto yynewstate; 1425 1.1 christos 1426 1.1 christos 1427 1.1 christos /*-----------------------------------------------------------. 1428 1.1 christos | yydefault -- do the default action for the current state. | 1429 1.1 christos `-----------------------------------------------------------*/ 1430 1.1 christos yydefault: 1431 1.1 christos yyn = yydefact[yystate]; 1432 1.1 christos if (yyn == 0) 1433 1.1 christos goto yyerrlab; 1434 1.1 christos goto yyreduce; 1435 1.1 christos 1436 1.1 christos 1437 1.1 christos /*-----------------------------. 1438 1.8 christos | yyreduce -- do a reduction. | 1439 1.1 christos `-----------------------------*/ 1440 1.1 christos yyreduce: 1441 1.1 christos /* yyn is the number of a rule to reduce with. */ 1442 1.1 christos yylen = yyr2[yyn]; 1443 1.1 christos 1444 1.1 christos /* If YYLEN is nonzero, implement the default value of the action: 1445 1.6 christos '$$ = $1'. 1446 1.1 christos 1447 1.1 christos Otherwise, the following line sets YYVAL to garbage. 1448 1.1 christos This behavior is undocumented and Bison 1449 1.1 christos users should not rely upon it. Assigning to YYVAL 1450 1.1 christos unconditionally makes the parser a bit smaller, and it avoids a 1451 1.1 christos GCC warning that YYVAL may be used uninitialized. */ 1452 1.1 christos yyval = yyvsp[1-yylen]; 1453 1.1 christos 1454 1.1 christos 1455 1.1 christos YY_REDUCE_PRINT (yyn); 1456 1.1 christos switch (yyn) 1457 1.1 christos { 1458 1.8 christos case 4: /* command: NAME opt_name opt_base */ 1459 1.9 christos #line 147 "deffilep.y" 1460 1.8 christos { def_image_name ((yyvsp[-1].id), (yyvsp[0].vma), 0); } 1461 1.9 christos #line 1462 "deffilep.c" 1462 1.1 christos break; 1463 1.1 christos 1464 1.8 christos case 5: /* command: LIBRARY opt_name opt_base */ 1465 1.9 christos #line 148 "deffilep.y" 1466 1.8 christos { def_image_name ((yyvsp[-1].id), (yyvsp[0].vma), 1); } 1467 1.9 christos #line 1468 "deffilep.c" 1468 1.1 christos break; 1469 1.1 christos 1470 1.8 christos case 6: /* command: DESCRIPTION ID */ 1471 1.9 christos #line 149 "deffilep.y" 1472 1.8 christos { def_description ((yyvsp[0].id));} 1473 1.9 christos #line 1474 "deffilep.c" 1474 1.1 christos break; 1475 1.1 christos 1476 1.8 christos case 7: /* command: STACKSIZE_K NUMBER opt_number */ 1477 1.9 christos #line 150 "deffilep.y" 1478 1.8 christos { def_stacksize ((yyvsp[-1].number), (yyvsp[0].number));} 1479 1.9 christos #line 1480 "deffilep.c" 1480 1.1 christos break; 1481 1.1 christos 1482 1.8 christos case 8: /* command: HEAPSIZE NUMBER opt_number */ 1483 1.9 christos #line 151 "deffilep.y" 1484 1.8 christos { def_heapsize ((yyvsp[-1].number), (yyvsp[0].number));} 1485 1.9 christos #line 1486 "deffilep.c" 1486 1.1 christos break; 1487 1.1 christos 1488 1.8 christos case 9: /* command: CODE attr_list */ 1489 1.9 christos #line 152 "deffilep.y" 1490 1.8 christos { def_section ("CODE", (yyvsp[0].number));} 1491 1.9 christos #line 1492 "deffilep.c" 1492 1.1 christos break; 1493 1.1 christos 1494 1.8 christos case 10: /* command: DATAU attr_list */ 1495 1.9 christos #line 153 "deffilep.y" 1496 1.8 christos { def_section ("DATA", (yyvsp[0].number));} 1497 1.9 christos #line 1498 "deffilep.c" 1498 1.1 christos break; 1499 1.1 christos 1500 1.8 christos case 14: /* command: VERSIONK NUMBER */ 1501 1.9 christos #line 157 "deffilep.y" 1502 1.8 christos { def_version ((yyvsp[0].number), 0);} 1503 1.9 christos #line 1504 "deffilep.c" 1504 1.1 christos break; 1505 1.1 christos 1506 1.8 christos case 15: /* command: VERSIONK NUMBER '.' NUMBER */ 1507 1.9 christos #line 158 "deffilep.y" 1508 1.8 christos { def_version ((yyvsp[-2].number), (yyvsp[0].number));} 1509 1.9 christos #line 1510 "deffilep.c" 1510 1.1 christos break; 1511 1.1 christos 1512 1.8 christos case 16: /* command: DIRECTIVE ID */ 1513 1.9 christos #line 159 "deffilep.y" 1514 1.8 christos { def_directive ((yyvsp[0].id));} 1515 1.9 christos #line 1516 "deffilep.c" 1516 1.1 christos break; 1517 1.1 christos 1518 1.8 christos case 17: /* command: ALIGNCOMM anylang_id ',' NUMBER */ 1519 1.9 christos #line 160 "deffilep.y" 1520 1.8 christos { def_aligncomm ((yyvsp[-2].id), (yyvsp[0].number));} 1521 1.9 christos #line 1522 "deffilep.c" 1522 1.1 christos break; 1523 1.1 christos 1524 1.9 christos case 22: /* expline: opt_name2 opt_equal_name opt_ordinal opt_comma exp_opt_list opt_comma opt_equalequal_name */ 1525 1.9 christos #line 176 "deffilep.y" 1526 1.8 christos { def_exports ((yyvsp[-6].id), (yyvsp[-5].id), (yyvsp[-4].number), (yyvsp[-2].number), (yyvsp[0].id)); } 1527 1.9 christos #line 1528 "deffilep.c" 1528 1.1 christos break; 1529 1.1 christos 1530 1.9 christos case 23: /* exp_opt_list: exp_opt opt_comma exp_opt_list */ 1531 1.9 christos #line 182 "deffilep.y" 1532 1.8 christos { (yyval.number) = (yyvsp[-2].number) | (yyvsp[0].number); } 1533 1.9 christos #line 1534 "deffilep.c" 1534 1.1 christos break; 1535 1.1 christos 1536 1.9 christos case 24: /* exp_opt_list: %empty */ 1537 1.9 christos #line 183 "deffilep.y" 1538 1.8 christos { (yyval.number) = 0; } 1539 1.9 christos #line 1540 "deffilep.c" 1540 1.1 christos break; 1541 1.1 christos 1542 1.9 christos case 25: /* exp_opt: NONAMEU */ 1543 1.9 christos #line 186 "deffilep.y" 1544 1.8 christos { (yyval.number) = 1; } 1545 1.9 christos #line 1546 "deffilep.c" 1546 1.1 christos break; 1547 1.1 christos 1548 1.9 christos case 26: /* exp_opt: NONAMEL */ 1549 1.9 christos #line 187 "deffilep.y" 1550 1.8 christos { (yyval.number) = 1; } 1551 1.9 christos #line 1552 "deffilep.c" 1552 1.1 christos break; 1553 1.1 christos 1554 1.9 christos case 27: /* exp_opt: CONSTANTU */ 1555 1.9 christos #line 188 "deffilep.y" 1556 1.8 christos { (yyval.number) = 2; } 1557 1.9 christos #line 1558 "deffilep.c" 1558 1.1 christos break; 1559 1.1 christos 1560 1.9 christos case 28: /* exp_opt: CONSTANTL */ 1561 1.9 christos #line 189 "deffilep.y" 1562 1.8 christos { (yyval.number) = 2; } 1563 1.9 christos #line 1564 "deffilep.c" 1564 1.1 christos break; 1565 1.1 christos 1566 1.9 christos case 29: /* exp_opt: DATAU */ 1567 1.9 christos #line 190 "deffilep.y" 1568 1.8 christos { (yyval.number) = 4; } 1569 1.9 christos #line 1570 "deffilep.c" 1570 1.1 christos break; 1571 1.1 christos 1572 1.9 christos case 30: /* exp_opt: DATAL */ 1573 1.9 christos #line 191 "deffilep.y" 1574 1.8 christos { (yyval.number) = 4; } 1575 1.9 christos #line 1576 "deffilep.c" 1576 1.1 christos break; 1577 1.1 christos 1578 1.9 christos case 31: /* exp_opt: PRIVATEU */ 1579 1.9 christos #line 192 "deffilep.y" 1580 1.8 christos { (yyval.number) = 8; } 1581 1.9 christos #line 1582 "deffilep.c" 1582 1.1 christos break; 1583 1.1 christos 1584 1.9 christos case 32: /* exp_opt: PRIVATEL */ 1585 1.9 christos #line 193 "deffilep.y" 1586 1.8 christos { (yyval.number) = 8; } 1587 1.9 christos #line 1588 "deffilep.c" 1588 1.1 christos break; 1589 1.1 christos 1590 1.9 christos case 35: /* impline: ID '=' ID '.' ID '.' ID opt_equalequal_name */ 1591 1.9 christos #line 202 "deffilep.y" 1592 1.8 christos { def_import ((yyvsp[-7].id), (yyvsp[-5].id), (yyvsp[-3].id), (yyvsp[-1].id), -1, (yyvsp[0].id)); } 1593 1.9 christos #line 1594 "deffilep.c" 1594 1.1 christos break; 1595 1.1 christos 1596 1.9 christos case 36: /* impline: ID '=' ID '.' ID '.' NUMBER opt_equalequal_name */ 1597 1.9 christos #line 204 "deffilep.y" 1598 1.8 christos { def_import ((yyvsp[-7].id), (yyvsp[-5].id), (yyvsp[-3].id), 0, (yyvsp[-1].number), (yyvsp[0].id)); } 1599 1.9 christos #line 1600 "deffilep.c" 1600 1.1 christos break; 1601 1.1 christos 1602 1.9 christos case 37: /* impline: ID '=' ID '.' ID opt_equalequal_name */ 1603 1.9 christos #line 206 "deffilep.y" 1604 1.8 christos { def_import ((yyvsp[-5].id), (yyvsp[-3].id), 0, (yyvsp[-1].id), -1, (yyvsp[0].id)); } 1605 1.9 christos #line 1606 "deffilep.c" 1606 1.1 christos break; 1607 1.1 christos 1608 1.9 christos case 38: /* impline: ID '=' ID '.' NUMBER opt_equalequal_name */ 1609 1.9 christos #line 208 "deffilep.y" 1610 1.8 christos { def_import ((yyvsp[-5].id), (yyvsp[-3].id), 0, 0, (yyvsp[-1].number), (yyvsp[0].id)); } 1611 1.9 christos #line 1612 "deffilep.c" 1612 1.1 christos break; 1613 1.1 christos 1614 1.9 christos case 39: /* impline: ID '.' ID '.' ID opt_equalequal_name */ 1615 1.9 christos #line 210 "deffilep.y" 1616 1.8 christos { def_import( 0, (yyvsp[-5].id), (yyvsp[-3].id), (yyvsp[-1].id), -1, (yyvsp[0].id)); } 1617 1.9 christos #line 1618 "deffilep.c" 1618 1.1 christos break; 1619 1.1 christos 1620 1.9 christos case 40: /* impline: ID '.' ID opt_equalequal_name */ 1621 1.9 christos #line 212 "deffilep.y" 1622 1.8 christos { def_import ( 0, (yyvsp[-3].id), 0, (yyvsp[-1].id), -1, (yyvsp[0].id)); } 1623 1.9 christos #line 1624 "deffilep.c" 1624 1.1 christos break; 1625 1.1 christos 1626 1.9 christos case 43: /* secline: ID attr_list */ 1627 1.9 christos #line 221 "deffilep.y" 1628 1.8 christos { def_section ((yyvsp[-1].id), (yyvsp[0].number));} 1629 1.9 christos #line 1630 "deffilep.c" 1630 1.1 christos break; 1631 1.1 christos 1632 1.9 christos case 44: /* secline: ID ID */ 1633 1.9 christos #line 222 "deffilep.y" 1634 1.8 christos { def_section_alt ((yyvsp[-1].id), (yyvsp[0].id));} 1635 1.9 christos #line 1636 "deffilep.c" 1636 1.1 christos break; 1637 1.1 christos 1638 1.9 christos case 45: /* attr_list: attr_list opt_comma attr */ 1639 1.9 christos #line 226 "deffilep.y" 1640 1.8 christos { (yyval.number) = (yyvsp[-2].number) | (yyvsp[0].number); } 1641 1.9 christos #line 1642 "deffilep.c" 1642 1.1 christos break; 1643 1.1 christos 1644 1.9 christos case 46: /* attr_list: attr */ 1645 1.9 christos #line 227 "deffilep.y" 1646 1.8 christos { (yyval.number) = (yyvsp[0].number); } 1647 1.9 christos #line 1648 "deffilep.c" 1648 1.1 christos break; 1649 1.1 christos 1650 1.9 christos case 49: /* opt_number: ',' NUMBER */ 1651 1.9 christos #line 234 "deffilep.y" 1652 1.8 christos { (yyval.number)=(yyvsp[0].number);} 1653 1.9 christos #line 1654 "deffilep.c" 1654 1.1 christos break; 1655 1.1 christos 1656 1.9 christos case 50: /* opt_number: %empty */ 1657 1.9 christos #line 235 "deffilep.y" 1658 1.8 christos { (yyval.number)=-1;} 1659 1.9 christos #line 1660 "deffilep.c" 1660 1.1 christos break; 1661 1.1 christos 1662 1.9 christos case 51: /* attr: READ */ 1663 1.9 christos #line 239 "deffilep.y" 1664 1.8 christos { (yyval.number) = 1;} 1665 1.9 christos #line 1666 "deffilep.c" 1666 1.1 christos break; 1667 1.1 christos 1668 1.9 christos case 52: /* attr: WRITE */ 1669 1.9 christos #line 240 "deffilep.y" 1670 1.8 christos { (yyval.number) = 2;} 1671 1.9 christos #line 1672 "deffilep.c" 1672 1.1 christos break; 1673 1.1 christos 1674 1.9 christos case 53: /* attr: EXECUTE */ 1675 1.9 christos #line 241 "deffilep.y" 1676 1.8 christos { (yyval.number)=4;} 1677 1.9 christos #line 1678 "deffilep.c" 1678 1.1 christos break; 1679 1.1 christos 1680 1.9 christos case 54: /* attr: SHARED_K */ 1681 1.9 christos #line 242 "deffilep.y" 1682 1.8 christos { (yyval.number)=8;} 1683 1.9 christos #line 1684 "deffilep.c" 1684 1.1 christos break; 1685 1.1 christos 1686 1.9 christos case 55: /* keyword_as_name: BASE */ 1687 1.9 christos #line 246 "deffilep.y" 1688 1.8 christos { (yyval.id_const) = "BASE"; } 1689 1.9 christos #line 1690 "deffilep.c" 1690 1.1 christos break; 1691 1.1 christos 1692 1.9 christos case 56: /* keyword_as_name: CODE */ 1693 1.9 christos #line 247 "deffilep.y" 1694 1.8 christos { (yyval.id_const) = "CODE"; } 1695 1.9 christos #line 1696 "deffilep.c" 1696 1.1 christos break; 1697 1.1 christos 1698 1.9 christos case 57: /* keyword_as_name: CONSTANTU */ 1699 1.9 christos #line 248 "deffilep.y" 1700 1.8 christos { (yyval.id_const) = "CONSTANT"; } 1701 1.9 christos #line 1702 "deffilep.c" 1702 1.1 christos break; 1703 1.1 christos 1704 1.9 christos case 58: /* keyword_as_name: CONSTANTL */ 1705 1.9 christos #line 249 "deffilep.y" 1706 1.8 christos { (yyval.id_const) = "constant"; } 1707 1.9 christos #line 1708 "deffilep.c" 1708 1.1 christos break; 1709 1.1 christos 1710 1.9 christos case 59: /* keyword_as_name: DATAU */ 1711 1.9 christos #line 250 "deffilep.y" 1712 1.8 christos { (yyval.id_const) = "DATA"; } 1713 1.9 christos #line 1714 "deffilep.c" 1714 1.1 christos break; 1715 1.1 christos 1716 1.9 christos case 60: /* keyword_as_name: DATAL */ 1717 1.9 christos #line 251 "deffilep.y" 1718 1.8 christos { (yyval.id_const) = "data"; } 1719 1.9 christos #line 1720 "deffilep.c" 1720 1.1 christos break; 1721 1.1 christos 1722 1.9 christos case 61: /* keyword_as_name: DESCRIPTION */ 1723 1.9 christos #line 252 "deffilep.y" 1724 1.8 christos { (yyval.id_const) = "DESCRIPTION"; } 1725 1.9 christos #line 1726 "deffilep.c" 1726 1.1 christos break; 1727 1.1 christos 1728 1.9 christos case 62: /* keyword_as_name: DIRECTIVE */ 1729 1.9 christos #line 253 "deffilep.y" 1730 1.8 christos { (yyval.id_const) = "DIRECTIVE"; } 1731 1.9 christos #line 1732 "deffilep.c" 1732 1.9 christos break; 1733 1.9 christos 1734 1.9 christos case 63: /* keyword_as_name: EXCLUDE_SYMBOLS */ 1735 1.9 christos #line 254 "deffilep.y" 1736 1.9 christos { (yyval.id_const) = "EXCLUDE_SYMBOLS"; } 1737 1.9 christos #line 1738 "deffilep.c" 1738 1.1 christos break; 1739 1.1 christos 1740 1.9 christos case 64: /* keyword_as_name: EXECUTE */ 1741 1.9 christos #line 255 "deffilep.y" 1742 1.8 christos { (yyval.id_const) = "EXECUTE"; } 1743 1.9 christos #line 1744 "deffilep.c" 1744 1.1 christos break; 1745 1.1 christos 1746 1.9 christos case 65: /* keyword_as_name: EXPORTS */ 1747 1.9 christos #line 256 "deffilep.y" 1748 1.8 christos { (yyval.id_const) = "EXPORTS"; } 1749 1.9 christos #line 1750 "deffilep.c" 1750 1.1 christos break; 1751 1.1 christos 1752 1.9 christos case 66: /* keyword_as_name: HEAPSIZE */ 1753 1.9 christos #line 257 "deffilep.y" 1754 1.8 christos { (yyval.id_const) = "HEAPSIZE"; } 1755 1.9 christos #line 1756 "deffilep.c" 1756 1.1 christos break; 1757 1.1 christos 1758 1.9 christos case 67: /* keyword_as_name: IMPORTS */ 1759 1.9 christos #line 258 "deffilep.y" 1760 1.8 christos { (yyval.id_const) = "IMPORTS"; } 1761 1.9 christos #line 1762 "deffilep.c" 1762 1.1 christos break; 1763 1.1 christos 1764 1.9 christos case 68: /* keyword_as_name: NAME */ 1765 1.9 christos #line 265 "deffilep.y" 1766 1.8 christos { (yyval.id_const) = "NAME"; } 1767 1.9 christos #line 1768 "deffilep.c" 1768 1.1 christos break; 1769 1.1 christos 1770 1.9 christos case 69: /* keyword_as_name: NONAMEU */ 1771 1.9 christos #line 266 "deffilep.y" 1772 1.8 christos { (yyval.id_const) = "NONAME"; } 1773 1.9 christos #line 1774 "deffilep.c" 1774 1.1 christos break; 1775 1.1 christos 1776 1.9 christos case 70: /* keyword_as_name: NONAMEL */ 1777 1.9 christos #line 267 "deffilep.y" 1778 1.8 christos { (yyval.id_const) = "noname"; } 1779 1.9 christos #line 1780 "deffilep.c" 1780 1.1 christos break; 1781 1.1 christos 1782 1.9 christos case 71: /* keyword_as_name: PRIVATEU */ 1783 1.9 christos #line 268 "deffilep.y" 1784 1.8 christos { (yyval.id_const) = "PRIVATE"; } 1785 1.9 christos #line 1786 "deffilep.c" 1786 1.1 christos break; 1787 1.1 christos 1788 1.9 christos case 72: /* keyword_as_name: PRIVATEL */ 1789 1.9 christos #line 269 "deffilep.y" 1790 1.8 christos { (yyval.id_const) = "private"; } 1791 1.9 christos #line 1792 "deffilep.c" 1792 1.1 christos break; 1793 1.1 christos 1794 1.9 christos case 73: /* keyword_as_name: READ */ 1795 1.9 christos #line 270 "deffilep.y" 1796 1.8 christos { (yyval.id_const) = "READ"; } 1797 1.9 christos #line 1798 "deffilep.c" 1798 1.1 christos break; 1799 1.1 christos 1800 1.9 christos case 74: /* keyword_as_name: SHARED_K */ 1801 1.9 christos #line 271 "deffilep.y" 1802 1.8 christos { (yyval.id_const) = "SHARED"; } 1803 1.9 christos #line 1804 "deffilep.c" 1804 1.1 christos break; 1805 1.1 christos 1806 1.9 christos case 75: /* keyword_as_name: STACKSIZE_K */ 1807 1.9 christos #line 272 "deffilep.y" 1808 1.8 christos { (yyval.id_const) = "STACKSIZE"; } 1809 1.9 christos #line 1810 "deffilep.c" 1810 1.1 christos break; 1811 1.1 christos 1812 1.9 christos case 76: /* keyword_as_name: VERSIONK */ 1813 1.9 christos #line 273 "deffilep.y" 1814 1.8 christos { (yyval.id_const) = "VERSION"; } 1815 1.9 christos #line 1816 "deffilep.c" 1816 1.1 christos break; 1817 1.1 christos 1818 1.9 christos case 77: /* keyword_as_name: WRITE */ 1819 1.9 christos #line 274 "deffilep.y" 1820 1.8 christos { (yyval.id_const) = "WRITE"; } 1821 1.9 christos #line 1822 "deffilep.c" 1822 1.1 christos break; 1823 1.1 christos 1824 1.9 christos case 78: /* opt_name2: ID */ 1825 1.9 christos #line 277 "deffilep.y" 1826 1.8 christos { (yyval.id) = (yyvsp[0].id); } 1827 1.9 christos #line 1828 "deffilep.c" 1828 1.1 christos break; 1829 1.1 christos 1830 1.9 christos case 79: /* opt_name2: '.' keyword_as_name */ 1831 1.9 christos #line 279 "deffilep.y" 1832 1.8 christos { 1833 1.6 christos char *name = xmalloc (strlen ((yyvsp[0].id_const)) + 2); 1834 1.6 christos sprintf (name, ".%s", (yyvsp[0].id_const)); 1835 1.1 christos (yyval.id) = name; 1836 1.1 christos } 1837 1.9 christos #line 1838 "deffilep.c" 1838 1.1 christos break; 1839 1.1 christos 1840 1.9 christos case 80: /* opt_name2: '.' opt_name2 */ 1841 1.9 christos #line 285 "deffilep.y" 1842 1.8 christos { 1843 1.6 christos char *name = def_pool_alloc (strlen ((yyvsp[0].id)) + 2); 1844 1.6 christos sprintf (name, ".%s", (yyvsp[0].id)); 1845 1.1 christos (yyval.id) = name; 1846 1.1 christos } 1847 1.9 christos #line 1848 "deffilep.c" 1848 1.1 christos break; 1849 1.1 christos 1850 1.9 christos case 81: /* opt_name2: keyword_as_name '.' opt_name2 */ 1851 1.9 christos #line 291 "deffilep.y" 1852 1.8 christos { 1853 1.6 christos char *name = def_pool_alloc (strlen ((yyvsp[-2].id_const)) + 1 + strlen ((yyvsp[0].id)) + 1); 1854 1.6 christos sprintf (name, "%s.%s", (yyvsp[-2].id_const), (yyvsp[0].id)); 1855 1.1 christos (yyval.id) = name; 1856 1.1 christos } 1857 1.9 christos #line 1858 "deffilep.c" 1858 1.1 christos break; 1859 1.1 christos 1860 1.9 christos case 82: /* opt_name2: ID '.' opt_name2 */ 1861 1.9 christos #line 297 "deffilep.y" 1862 1.8 christos { 1863 1.6 christos char *name = def_pool_alloc (strlen ((yyvsp[-2].id)) + 1 + strlen ((yyvsp[0].id)) + 1); 1864 1.6 christos sprintf (name, "%s.%s", (yyvsp[-2].id), (yyvsp[0].id)); 1865 1.1 christos (yyval.id) = name; 1866 1.1 christos } 1867 1.9 christos #line 1868 "deffilep.c" 1868 1.1 christos break; 1869 1.1 christos 1870 1.9 christos case 83: /* opt_name: opt_name2 */ 1871 1.9 christos #line 304 "deffilep.y" 1872 1.8 christos { (yyval.id) = (yyvsp[0].id); } 1873 1.9 christos #line 1874 "deffilep.c" 1874 1.1 christos break; 1875 1.1 christos 1876 1.9 christos case 84: /* opt_name: %empty */ 1877 1.9 christos #line 305 "deffilep.y" 1878 1.8 christos { (yyval.id) = ""; } 1879 1.9 christos #line 1880 "deffilep.c" 1880 1.1 christos break; 1881 1.1 christos 1882 1.9 christos case 85: /* opt_equalequal_name: EQUAL ID */ 1883 1.9 christos #line 308 "deffilep.y" 1884 1.8 christos { (yyval.id) = (yyvsp[0].id); } 1885 1.9 christos #line 1886 "deffilep.c" 1886 1.1 christos break; 1887 1.1 christos 1888 1.9 christos case 86: /* opt_equalequal_name: %empty */ 1889 1.9 christos #line 309 "deffilep.y" 1890 1.8 christos { (yyval.id) = 0; } 1891 1.9 christos #line 1892 "deffilep.c" 1892 1.1 christos break; 1893 1.1 christos 1894 1.9 christos case 87: /* opt_ordinal: '@' NUMBER */ 1895 1.9 christos #line 313 "deffilep.y" 1896 1.8 christos { (yyval.number) = (yyvsp[0].number);} 1897 1.9 christos #line 1898 "deffilep.c" 1898 1.1 christos break; 1899 1.1 christos 1900 1.9 christos case 88: /* opt_ordinal: %empty */ 1901 1.9 christos #line 314 "deffilep.y" 1902 1.8 christos { (yyval.number) = -1;} 1903 1.9 christos #line 1904 "deffilep.c" 1904 1.1 christos break; 1905 1.1 christos 1906 1.9 christos case 89: /* opt_equal_name: '=' opt_name2 */ 1907 1.9 christos #line 318 "deffilep.y" 1908 1.8 christos { (yyval.id) = (yyvsp[0].id); } 1909 1.9 christos #line 1910 "deffilep.c" 1910 1.1 christos break; 1911 1.1 christos 1912 1.9 christos case 90: /* opt_equal_name: %empty */ 1913 1.9 christos #line 319 "deffilep.y" 1914 1.8 christos { (yyval.id) = 0; } 1915 1.9 christos #line 1916 "deffilep.c" 1916 1.1 christos break; 1917 1.1 christos 1918 1.9 christos case 91: /* opt_base: BASE '=' VMA */ 1919 1.9 christos #line 322 "deffilep.y" 1920 1.8 christos { (yyval.vma) = (yyvsp[0].vma);} 1921 1.9 christos #line 1922 "deffilep.c" 1922 1.1 christos break; 1923 1.1 christos 1924 1.9 christos case 92: /* opt_base: %empty */ 1925 1.9 christos #line 323 "deffilep.y" 1926 1.8 christos { (yyval.vma) = (bfd_vma) -1;} 1927 1.9 christos #line 1928 "deffilep.c" 1928 1.1 christos break; 1929 1.1 christos 1930 1.9 christos case 93: /* anylang_id: ID */ 1931 1.9 christos #line 326 "deffilep.y" 1932 1.8 christos { (yyval.id) = (yyvsp[0].id); } 1933 1.9 christos #line 1934 "deffilep.c" 1934 1.1 christos break; 1935 1.1 christos 1936 1.9 christos case 94: /* anylang_id: '.' ID */ 1937 1.9 christos #line 328 "deffilep.y" 1938 1.8 christos { 1939 1.6 christos char *id = def_pool_alloc (strlen ((yyvsp[0].id)) + 2); 1940 1.6 christos sprintf (id, ".%s", (yyvsp[0].id)); 1941 1.1 christos (yyval.id) = id; 1942 1.1 christos } 1943 1.9 christos #line 1944 "deffilep.c" 1944 1.1 christos break; 1945 1.1 christos 1946 1.9 christos case 95: /* anylang_id: anylang_id '.' opt_digits opt_id */ 1947 1.9 christos #line 334 "deffilep.y" 1948 1.8 christos { 1949 1.6 christos char *id = def_pool_alloc (strlen ((yyvsp[-3].id)) + 1 + strlen ((yyvsp[-1].digits)) + strlen ((yyvsp[0].id)) + 1); 1950 1.6 christos sprintf (id, "%s.%s%s", (yyvsp[-3].id), (yyvsp[-1].digits), (yyvsp[0].id)); 1951 1.1 christos (yyval.id) = id; 1952 1.1 christos } 1953 1.9 christos #line 1954 "deffilep.c" 1954 1.9 christos break; 1955 1.9 christos 1956 1.9 christos case 96: /* symbol_list: anylang_id */ 1957 1.9 christos #line 342 "deffilep.y" 1958 1.9 christos { def_exclude_symbols ((yyvsp[0].id)); } 1959 1.9 christos #line 1960 "deffilep.c" 1960 1.9 christos break; 1961 1.9 christos 1962 1.9 christos case 97: /* symbol_list: symbol_list anylang_id */ 1963 1.9 christos #line 343 "deffilep.y" 1964 1.9 christos { def_exclude_symbols ((yyvsp[0].id)); } 1965 1.9 christos #line 1966 "deffilep.c" 1966 1.9 christos break; 1967 1.9 christos 1968 1.9 christos case 98: /* symbol_list: symbol_list ',' anylang_id */ 1969 1.9 christos #line 344 "deffilep.y" 1970 1.9 christos { def_exclude_symbols ((yyvsp[0].id)); } 1971 1.9 christos #line 1972 "deffilep.c" 1972 1.1 christos break; 1973 1.1 christos 1974 1.9 christos case 99: /* opt_digits: DIGITS */ 1975 1.9 christos #line 347 "deffilep.y" 1976 1.8 christos { (yyval.digits) = (yyvsp[0].digits); } 1977 1.9 christos #line 1978 "deffilep.c" 1978 1.1 christos break; 1979 1.1 christos 1980 1.9 christos case 100: /* opt_digits: %empty */ 1981 1.9 christos #line 348 "deffilep.y" 1982 1.8 christos { (yyval.digits) = ""; } 1983 1.9 christos #line 1984 "deffilep.c" 1984 1.1 christos break; 1985 1.1 christos 1986 1.9 christos case 101: /* opt_id: ID */ 1987 1.9 christos #line 351 "deffilep.y" 1988 1.8 christos { (yyval.id) = (yyvsp[0].id); } 1989 1.9 christos #line 1990 "deffilep.c" 1990 1.1 christos break; 1991 1.1 christos 1992 1.9 christos case 102: /* opt_id: %empty */ 1993 1.9 christos #line 352 "deffilep.y" 1994 1.8 christos { (yyval.id) = ""; } 1995 1.9 christos #line 1996 "deffilep.c" 1996 1.1 christos break; 1997 1.1 christos 1998 1.9 christos case 103: /* NUMBER: DIGITS */ 1999 1.9 christos #line 355 "deffilep.y" 2000 1.8 christos { (yyval.number) = strtoul ((yyvsp[0].digits), 0, 0); } 2001 1.9 christos #line 2002 "deffilep.c" 2002 1.3 christos break; 2003 1.3 christos 2004 1.9 christos case 104: /* VMA: DIGITS */ 2005 1.9 christos #line 357 "deffilep.y" 2006 1.8 christos { (yyval.vma) = (bfd_vma) strtoull ((yyvsp[0].digits), 0, 0); } 2007 1.9 christos #line 2008 "deffilep.c" 2008 1.1 christos break; 2009 1.1 christos 2010 1.1 christos 2011 1.9 christos #line 2012 "deffilep.c" 2012 1.8 christos 2013 1.1 christos default: break; 2014 1.1 christos } 2015 1.6 christos /* User semantic actions sometimes alter yychar, and that requires 2016 1.6 christos that yytoken be updated with the new translation. We take the 2017 1.6 christos approach of translating immediately before every use of yytoken. 2018 1.6 christos One alternative is translating here after every semantic action, 2019 1.6 christos but that translation would be missed if the semantic action invokes 2020 1.6 christos YYABORT, YYACCEPT, or YYERROR immediately after altering yychar or 2021 1.6 christos if it invokes YYBACKUP. In the case of YYABORT or YYACCEPT, an 2022 1.6 christos incorrect destructor might then be invoked immediately. In the 2023 1.6 christos case of YYERROR or YYBACKUP, subsequent parser actions might lead 2024 1.6 christos to an incorrect destructor call or verbose syntax error message 2025 1.6 christos before the lookahead is translated. */ 2026 1.8 christos YY_SYMBOL_PRINT ("-> $$ =", YY_CAST (yysymbol_kind_t, yyr1[yyn]), &yyval, &yyloc); 2027 1.1 christos 2028 1.1 christos YYPOPSTACK (yylen); 2029 1.1 christos yylen = 0; 2030 1.1 christos 2031 1.1 christos *++yyvsp = yyval; 2032 1.1 christos 2033 1.6 christos /* Now 'shift' the result of the reduction. Determine what state 2034 1.1 christos that goes to, based on the state we popped back to and the rule 2035 1.1 christos number reduced by. */ 2036 1.8 christos { 2037 1.8 christos const int yylhs = yyr1[yyn] - YYNTOKENS; 2038 1.8 christos const int yyi = yypgoto[yylhs] + *yyssp; 2039 1.8 christos yystate = (0 <= yyi && yyi <= YYLAST && yycheck[yyi] == *yyssp 2040 1.8 christos ? yytable[yyi] 2041 1.8 christos : yydefgoto[yylhs]); 2042 1.8 christos } 2043 1.1 christos 2044 1.1 christos goto yynewstate; 2045 1.1 christos 2046 1.1 christos 2047 1.6 christos /*--------------------------------------. 2048 1.6 christos | yyerrlab -- here on detecting error. | 2049 1.6 christos `--------------------------------------*/ 2050 1.1 christos yyerrlab: 2051 1.6 christos /* Make sure we have latest lookahead translation. See comments at 2052 1.6 christos user semantic actions for why this is necessary. */ 2053 1.8 christos yytoken = yychar == YYEMPTY ? YYSYMBOL_YYEMPTY : YYTRANSLATE (yychar); 2054 1.1 christos /* If not already recovering from an error, report this error. */ 2055 1.1 christos if (!yyerrstatus) 2056 1.1 christos { 2057 1.1 christos ++yynerrs; 2058 1.1 christos yyerror (YY_("syntax error")); 2059 1.1 christos } 2060 1.1 christos 2061 1.1 christos if (yyerrstatus == 3) 2062 1.1 christos { 2063 1.6 christos /* If just tried and failed to reuse lookahead token after an 2064 1.6 christos error, discard it. */ 2065 1.1 christos 2066 1.1 christos if (yychar <= YYEOF) 2067 1.6 christos { 2068 1.6 christos /* Return failure if at end of input. */ 2069 1.6 christos if (yychar == YYEOF) 2070 1.6 christos YYABORT; 2071 1.6 christos } 2072 1.1 christos else 2073 1.6 christos { 2074 1.6 christos yydestruct ("Error: discarding", 2075 1.6 christos yytoken, &yylval); 2076 1.6 christos yychar = YYEMPTY; 2077 1.6 christos } 2078 1.1 christos } 2079 1.1 christos 2080 1.6 christos /* Else will try to reuse lookahead token after shifting the error 2081 1.1 christos token. */ 2082 1.1 christos goto yyerrlab1; 2083 1.1 christos 2084 1.1 christos 2085 1.1 christos /*---------------------------------------------------. 2086 1.1 christos | yyerrorlab -- error raised explicitly by YYERROR. | 2087 1.1 christos `---------------------------------------------------*/ 2088 1.1 christos yyerrorlab: 2089 1.8 christos /* Pacify compilers when the user code never invokes YYERROR and the 2090 1.8 christos label yyerrorlab therefore never appears in user code. */ 2091 1.8 christos if (0) 2092 1.8 christos YYERROR; 2093 1.8 christos ++yynerrs; 2094 1.1 christos 2095 1.6 christos /* Do not reclaim the symbols of the rule whose action triggered 2096 1.1 christos this YYERROR. */ 2097 1.1 christos YYPOPSTACK (yylen); 2098 1.1 christos yylen = 0; 2099 1.1 christos YY_STACK_PRINT (yyss, yyssp); 2100 1.1 christos yystate = *yyssp; 2101 1.1 christos goto yyerrlab1; 2102 1.1 christos 2103 1.1 christos 2104 1.1 christos /*-------------------------------------------------------------. 2105 1.1 christos | yyerrlab1 -- common code for both syntax error and YYERROR. | 2106 1.1 christos `-------------------------------------------------------------*/ 2107 1.1 christos yyerrlab1: 2108 1.6 christos yyerrstatus = 3; /* Each real token shifted decrements this. */ 2109 1.1 christos 2110 1.8 christos /* Pop stack until we find a state that shifts the error token. */ 2111 1.1 christos for (;;) 2112 1.1 christos { 2113 1.1 christos yyn = yypact[yystate]; 2114 1.6 christos if (!yypact_value_is_default (yyn)) 2115 1.6 christos { 2116 1.8 christos yyn += YYSYMBOL_YYerror; 2117 1.8 christos if (0 <= yyn && yyn <= YYLAST && yycheck[yyn] == YYSYMBOL_YYerror) 2118 1.6 christos { 2119 1.6 christos yyn = yytable[yyn]; 2120 1.6 christos if (0 < yyn) 2121 1.6 christos break; 2122 1.6 christos } 2123 1.6 christos } 2124 1.1 christos 2125 1.1 christos /* Pop the current state because it cannot handle the error token. */ 2126 1.1 christos if (yyssp == yyss) 2127 1.6 christos YYABORT; 2128 1.1 christos 2129 1.1 christos 2130 1.1 christos yydestruct ("Error: popping", 2131 1.8 christos YY_ACCESSING_SYMBOL (yystate), yyvsp); 2132 1.1 christos YYPOPSTACK (1); 2133 1.1 christos yystate = *yyssp; 2134 1.1 christos YY_STACK_PRINT (yyss, yyssp); 2135 1.1 christos } 2136 1.1 christos 2137 1.6 christos YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN 2138 1.1 christos *++yyvsp = yylval; 2139 1.6 christos YY_IGNORE_MAYBE_UNINITIALIZED_END 2140 1.1 christos 2141 1.1 christos 2142 1.1 christos /* Shift the error token. */ 2143 1.8 christos YY_SYMBOL_PRINT ("Shifting", YY_ACCESSING_SYMBOL (yyn), yyvsp, yylsp); 2144 1.1 christos 2145 1.1 christos yystate = yyn; 2146 1.1 christos goto yynewstate; 2147 1.1 christos 2148 1.1 christos 2149 1.1 christos /*-------------------------------------. 2150 1.1 christos | yyacceptlab -- YYACCEPT comes here. | 2151 1.1 christos `-------------------------------------*/ 2152 1.1 christos yyacceptlab: 2153 1.1 christos yyresult = 0; 2154 1.8 christos goto yyreturnlab; 2155 1.8 christos 2156 1.1 christos 2157 1.1 christos /*-----------------------------------. 2158 1.1 christos | yyabortlab -- YYABORT comes here. | 2159 1.1 christos `-----------------------------------*/ 2160 1.1 christos yyabortlab: 2161 1.1 christos yyresult = 1; 2162 1.8 christos goto yyreturnlab; 2163 1.8 christos 2164 1.1 christos 2165 1.8 christos /*-----------------------------------------------------------. 2166 1.8 christos | yyexhaustedlab -- YYNOMEM (memory exhaustion) comes here. | 2167 1.8 christos `-----------------------------------------------------------*/ 2168 1.1 christos yyexhaustedlab: 2169 1.1 christos yyerror (YY_("memory exhausted")); 2170 1.1 christos yyresult = 2; 2171 1.8 christos goto yyreturnlab; 2172 1.8 christos 2173 1.1 christos 2174 1.8 christos /*----------------------------------------------------------. 2175 1.8 christos | yyreturnlab -- parsing is finished, clean up and return. | 2176 1.8 christos `----------------------------------------------------------*/ 2177 1.8 christos yyreturnlab: 2178 1.6 christos if (yychar != YYEMPTY) 2179 1.6 christos { 2180 1.6 christos /* Make sure we have latest lookahead translation. See comments at 2181 1.6 christos user semantic actions for why this is necessary. */ 2182 1.6 christos yytoken = YYTRANSLATE (yychar); 2183 1.6 christos yydestruct ("Cleanup: discarding lookahead", 2184 1.6 christos yytoken, &yylval); 2185 1.6 christos } 2186 1.6 christos /* Do not reclaim the symbols of the rule whose action triggered 2187 1.1 christos this YYABORT or YYACCEPT. */ 2188 1.1 christos YYPOPSTACK (yylen); 2189 1.1 christos YY_STACK_PRINT (yyss, yyssp); 2190 1.1 christos while (yyssp != yyss) 2191 1.1 christos { 2192 1.1 christos yydestruct ("Cleanup: popping", 2193 1.8 christos YY_ACCESSING_SYMBOL (+*yyssp), yyvsp); 2194 1.1 christos YYPOPSTACK (1); 2195 1.1 christos } 2196 1.1 christos #ifndef yyoverflow 2197 1.1 christos if (yyss != yyssa) 2198 1.1 christos YYSTACK_FREE (yyss); 2199 1.1 christos #endif 2200 1.8 christos 2201 1.6 christos return yyresult; 2202 1.1 christos } 2203 1.8 christos 2204 1.9 christos #line 359 "deffilep.y" 2205 1.1 christos 2206 1.1 christos 2207 1.1 christos /***************************************************************************** 2208 1.1 christos API 2209 1.1 christos *****************************************************************************/ 2210 1.1 christos 2211 1.1 christos static FILE *the_file; 2212 1.1 christos static const char *def_filename; 2213 1.1 christos static int linenumber; 2214 1.1 christos static def_file *def; 2215 1.1 christos static int saw_newline; 2216 1.1 christos 2217 1.1 christos struct directive 2218 1.1 christos { 2219 1.1 christos struct directive *next; 2220 1.1 christos char *name; 2221 1.1 christos int len; 2222 1.1 christos }; 2223 1.1 christos 2224 1.1 christos static struct directive *directives = 0; 2225 1.1 christos 2226 1.1 christos def_file * 2227 1.1 christos def_file_empty (void) 2228 1.1 christos { 2229 1.1 christos def_file *rv = xmalloc (sizeof (def_file)); 2230 1.1 christos memset (rv, 0, sizeof (def_file)); 2231 1.1 christos rv->is_dll = -1; 2232 1.1 christos rv->base_address = (bfd_vma) -1; 2233 1.1 christos rv->stack_reserve = rv->stack_commit = -1; 2234 1.1 christos rv->heap_reserve = rv->heap_commit = -1; 2235 1.1 christos rv->version_major = rv->version_minor = -1; 2236 1.1 christos return rv; 2237 1.1 christos } 2238 1.1 christos 2239 1.1 christos def_file * 2240 1.1 christos def_file_parse (const char *filename, def_file *add_to) 2241 1.1 christos { 2242 1.1 christos struct directive *d; 2243 1.1 christos 2244 1.1 christos the_file = fopen (filename, "r"); 2245 1.1 christos def_filename = filename; 2246 1.1 christos linenumber = 1; 2247 1.1 christos if (!the_file) 2248 1.1 christos { 2249 1.1 christos perror (filename); 2250 1.1 christos return 0; 2251 1.1 christos } 2252 1.1 christos if (add_to) 2253 1.1 christos { 2254 1.1 christos def = add_to; 2255 1.1 christos } 2256 1.1 christos else 2257 1.1 christos { 2258 1.1 christos def = def_file_empty (); 2259 1.1 christos } 2260 1.1 christos 2261 1.1 christos saw_newline = 1; 2262 1.1 christos if (def_parse ()) 2263 1.1 christos { 2264 1.1 christos def_file_free (def); 2265 1.1 christos fclose (the_file); 2266 1.1 christos def_pool_free (); 2267 1.1 christos return 0; 2268 1.1 christos } 2269 1.1 christos 2270 1.1 christos fclose (the_file); 2271 1.1 christos 2272 1.1 christos while ((d = directives) != NULL) 2273 1.1 christos { 2274 1.1 christos #if TRACE 2275 1.1 christos printf ("Adding directive %08x `%s'\n", d->name, d->name); 2276 1.1 christos #endif 2277 1.1 christos def_file_add_directive (def, d->name, d->len); 2278 1.1 christos directives = d->next; 2279 1.1 christos free (d->name); 2280 1.1 christos free (d); 2281 1.1 christos } 2282 1.1 christos def_pool_free (); 2283 1.1 christos 2284 1.1 christos return def; 2285 1.1 christos } 2286 1.1 christos 2287 1.1 christos void 2288 1.1 christos def_file_free (def_file *fdef) 2289 1.1 christos { 2290 1.1 christos int i; 2291 1.9 christos unsigned int ui; 2292 1.1 christos 2293 1.1 christos if (!fdef) 2294 1.1 christos return; 2295 1.8 christos free (fdef->name); 2296 1.8 christos free (fdef->description); 2297 1.1 christos 2298 1.1 christos if (fdef->section_defs) 2299 1.1 christos { 2300 1.1 christos for (i = 0; i < fdef->num_section_defs; i++) 2301 1.1 christos { 2302 1.8 christos free (fdef->section_defs[i].name); 2303 1.8 christos free (fdef->section_defs[i].class); 2304 1.1 christos } 2305 1.1 christos free (fdef->section_defs); 2306 1.1 christos } 2307 1.1 christos 2308 1.9 christos for (i = 0; i < fdef->num_exports; i++) 2309 1.1 christos { 2310 1.9 christos if (fdef->exports[i].internal_name != fdef->exports[i].name) 2311 1.9 christos free (fdef->exports[i].internal_name); 2312 1.9 christos free (fdef->exports[i].name); 2313 1.9 christos free (fdef->exports[i].its_name); 2314 1.1 christos } 2315 1.9 christos free (fdef->exports); 2316 1.1 christos 2317 1.9 christos for (i = 0; i < fdef->num_imports; i++) 2318 1.1 christos { 2319 1.9 christos if (fdef->imports[i].internal_name != fdef->imports[i].name) 2320 1.9 christos free (fdef->imports[i].internal_name); 2321 1.9 christos free (fdef->imports[i].name); 2322 1.9 christos free (fdef->imports[i].its_name); 2323 1.1 christos } 2324 1.9 christos free (fdef->imports); 2325 1.1 christos 2326 1.1 christos while (fdef->modules) 2327 1.1 christos { 2328 1.1 christos def_file_module *m = fdef->modules; 2329 1.1 christos 2330 1.1 christos fdef->modules = fdef->modules->next; 2331 1.1 christos free (m); 2332 1.1 christos } 2333 1.1 christos 2334 1.1 christos while (fdef->aligncomms) 2335 1.1 christos { 2336 1.1 christos def_file_aligncomm *c = fdef->aligncomms; 2337 1.1 christos 2338 1.1 christos fdef->aligncomms = fdef->aligncomms->next; 2339 1.1 christos free (c->symbol_name); 2340 1.1 christos free (c); 2341 1.1 christos } 2342 1.1 christos 2343 1.9 christos for (ui = 0; ui < fdef->num_exclude_symbols; ui++) 2344 1.9 christos { 2345 1.9 christos free (fdef->exclude_symbols[ui].symbol_name); 2346 1.9 christos } 2347 1.9 christos free (fdef->exclude_symbols); 2348 1.9 christos 2349 1.1 christos free (fdef); 2350 1.1 christos } 2351 1.1 christos 2352 1.1 christos #ifdef DEF_FILE_PRINT 2353 1.1 christos void 2354 1.1 christos def_file_print (FILE *file, def_file *fdef) 2355 1.1 christos { 2356 1.1 christos int i; 2357 1.1 christos 2358 1.1 christos fprintf (file, ">>>> def_file at 0x%08x\n", fdef); 2359 1.1 christos if (fdef->name) 2360 1.1 christos fprintf (file, " name: %s\n", fdef->name ? fdef->name : "(unspecified)"); 2361 1.1 christos if (fdef->is_dll != -1) 2362 1.1 christos fprintf (file, " is dll: %s\n", fdef->is_dll ? "yes" : "no"); 2363 1.1 christos if (fdef->base_address != (bfd_vma) -1) 2364 1.9 christos fprintf (file, " base address: 0x%" PRIx64 "\n", 2365 1.9 christos (uint64_t) fdef->base_address); 2366 1.1 christos if (fdef->description) 2367 1.1 christos fprintf (file, " description: `%s'\n", fdef->description); 2368 1.1 christos if (fdef->stack_reserve != -1) 2369 1.1 christos fprintf (file, " stack reserve: 0x%08x\n", fdef->stack_reserve); 2370 1.1 christos if (fdef->stack_commit != -1) 2371 1.1 christos fprintf (file, " stack commit: 0x%08x\n", fdef->stack_commit); 2372 1.1 christos if (fdef->heap_reserve != -1) 2373 1.1 christos fprintf (file, " heap reserve: 0x%08x\n", fdef->heap_reserve); 2374 1.1 christos if (fdef->heap_commit != -1) 2375 1.1 christos fprintf (file, " heap commit: 0x%08x\n", fdef->heap_commit); 2376 1.1 christos 2377 1.1 christos if (fdef->num_section_defs > 0) 2378 1.1 christos { 2379 1.1 christos fprintf (file, " section defs:\n"); 2380 1.1 christos 2381 1.1 christos for (i = 0; i < fdef->num_section_defs; i++) 2382 1.1 christos { 2383 1.1 christos fprintf (file, " name: `%s', class: `%s', flags:", 2384 1.1 christos fdef->section_defs[i].name, fdef->section_defs[i].class); 2385 1.1 christos if (fdef->section_defs[i].flag_read) 2386 1.1 christos fprintf (file, " R"); 2387 1.1 christos if (fdef->section_defs[i].flag_write) 2388 1.1 christos fprintf (file, " W"); 2389 1.1 christos if (fdef->section_defs[i].flag_execute) 2390 1.1 christos fprintf (file, " X"); 2391 1.1 christos if (fdef->section_defs[i].flag_shared) 2392 1.1 christos fprintf (file, " S"); 2393 1.1 christos fprintf (file, "\n"); 2394 1.1 christos } 2395 1.1 christos } 2396 1.1 christos 2397 1.1 christos if (fdef->num_exports > 0) 2398 1.1 christos { 2399 1.1 christos fprintf (file, " exports:\n"); 2400 1.1 christos 2401 1.1 christos for (i = 0; i < fdef->num_exports; i++) 2402 1.1 christos { 2403 1.1 christos fprintf (file, " name: `%s', int: `%s', ordinal: %d, flags:", 2404 1.1 christos fdef->exports[i].name, fdef->exports[i].internal_name, 2405 1.1 christos fdef->exports[i].ordinal); 2406 1.1 christos if (fdef->exports[i].flag_private) 2407 1.1 christos fprintf (file, " P"); 2408 1.1 christos if (fdef->exports[i].flag_constant) 2409 1.1 christos fprintf (file, " C"); 2410 1.1 christos if (fdef->exports[i].flag_noname) 2411 1.1 christos fprintf (file, " N"); 2412 1.1 christos if (fdef->exports[i].flag_data) 2413 1.1 christos fprintf (file, " D"); 2414 1.1 christos fprintf (file, "\n"); 2415 1.1 christos } 2416 1.1 christos } 2417 1.1 christos 2418 1.1 christos if (fdef->num_imports > 0) 2419 1.1 christos { 2420 1.1 christos fprintf (file, " imports:\n"); 2421 1.1 christos 2422 1.1 christos for (i = 0; i < fdef->num_imports; i++) 2423 1.1 christos { 2424 1.1 christos fprintf (file, " int: %s, from: `%s', name: `%s', ordinal: %d\n", 2425 1.1 christos fdef->imports[i].internal_name, 2426 1.1 christos fdef->imports[i].module, 2427 1.1 christos fdef->imports[i].name, 2428 1.1 christos fdef->imports[i].ordinal); 2429 1.1 christos } 2430 1.1 christos } 2431 1.1 christos 2432 1.1 christos if (fdef->version_major != -1) 2433 1.1 christos fprintf (file, " version: %d.%d\n", fdef->version_major, fdef->version_minor); 2434 1.1 christos 2435 1.1 christos fprintf (file, "<<<< def_file at 0x%08x\n", fdef); 2436 1.1 christos } 2437 1.1 christos #endif 2438 1.1 christos 2439 1.1 christos /* Helper routine to check for identity of string pointers, 2440 1.1 christos which might be NULL. */ 2441 1.1 christos 2442 1.1 christos static int 2443 1.1 christos are_names_equal (const char *s1, const char *s2) 2444 1.1 christos { 2445 1.1 christos if (!s1 && !s2) 2446 1.1 christos return 0; 2447 1.1 christos if (!s1 || !s2) 2448 1.1 christos return (!s1 ? -1 : 1); 2449 1.1 christos return strcmp (s1, s2); 2450 1.1 christos } 2451 1.1 christos 2452 1.1 christos static int 2453 1.1 christos cmp_export_elem (const def_file_export *e, const char *ex_name, 2454 1.1 christos const char *in_name, const char *its_name, 2455 1.1 christos int ord) 2456 1.1 christos { 2457 1.1 christos int r; 2458 1.1 christos 2459 1.10 christos if ((r = are_names_equal (its_name ? its_name : ex_name, 2460 1.10 christos e->its_name ? e->its_name : e->name)) != 0) 2461 1.1 christos return r; 2462 1.1 christos if ((r = are_names_equal (in_name, e->internal_name)) != 0) 2463 1.1 christos return r; 2464 1.1 christos return (ord - e->ordinal); 2465 1.1 christos } 2466 1.1 christos 2467 1.1 christos /* Search the position of the identical element, or returns the position 2468 1.1 christos of the next higher element. If last valid element is smaller, then MAX 2469 1.9 christos is returned. The max parameter indicates the number of elements in the 2470 1.9 christos array. On return, *is_ident indicates whether the returned array index 2471 1.9 christos points at an element which is identical to the one searched for. */ 2472 1.1 christos 2473 1.9 christos static unsigned int 2474 1.9 christos find_export_in_list (def_file_export *b, unsigned int max, 2475 1.1 christos const char *ex_name, const char *in_name, 2476 1.9 christos const char *its_name, int ord, bool *is_ident) 2477 1.1 christos { 2478 1.9 christos int e; 2479 1.9 christos unsigned int l, r, p; 2480 1.1 christos 2481 1.9 christos *is_ident = false; 2482 1.1 christos if (!max) 2483 1.1 christos return 0; 2484 1.1 christos if ((e = cmp_export_elem (b, ex_name, in_name, its_name, ord)) <= 0) 2485 1.1 christos { 2486 1.1 christos if (!e) 2487 1.9 christos *is_ident = true; 2488 1.1 christos return 0; 2489 1.1 christos } 2490 1.1 christos if (max == 1) 2491 1.1 christos return 1; 2492 1.1 christos if ((e = cmp_export_elem (b + (max - 1), ex_name, in_name, its_name, ord)) > 0) 2493 1.1 christos return max; 2494 1.1 christos else if (!e || max == 2) 2495 1.1 christos { 2496 1.1 christos if (!e) 2497 1.9 christos *is_ident = true; 2498 1.1 christos return max - 1; 2499 1.1 christos } 2500 1.1 christos l = 0; r = max - 1; 2501 1.1 christos while (l < r) 2502 1.1 christos { 2503 1.1 christos p = (l + r) / 2; 2504 1.1 christos e = cmp_export_elem (b + p, ex_name, in_name, its_name, ord); 2505 1.1 christos if (!e) 2506 1.6 christos { 2507 1.9 christos *is_ident = true; 2508 1.6 christos return p; 2509 1.6 christos } 2510 1.1 christos else if (e < 0) 2511 1.6 christos r = p - 1; 2512 1.1 christos else if (e > 0) 2513 1.6 christos l = p + 1; 2514 1.1 christos } 2515 1.1 christos if ((e = cmp_export_elem (b + l, ex_name, in_name, its_name, ord)) > 0) 2516 1.1 christos ++l; 2517 1.1 christos else if (!e) 2518 1.9 christos *is_ident = true; 2519 1.1 christos return l; 2520 1.1 christos } 2521 1.1 christos 2522 1.1 christos def_file_export * 2523 1.1 christos def_file_add_export (def_file *fdef, 2524 1.1 christos const char *external_name, 2525 1.1 christos const char *internal_name, 2526 1.1 christos int ordinal, 2527 1.1 christos const char *its_name, 2528 1.9 christos bool *is_dup) 2529 1.1 christos { 2530 1.1 christos def_file_export *e; 2531 1.9 christos unsigned int pos; 2532 1.1 christos 2533 1.1 christos if (internal_name && !external_name) 2534 1.1 christos external_name = internal_name; 2535 1.1 christos if (external_name && !internal_name) 2536 1.1 christos internal_name = external_name; 2537 1.1 christos 2538 1.1 christos /* We need to avoid duplicates. */ 2539 1.9 christos *is_dup = false; 2540 1.1 christos pos = find_export_in_list (fdef->exports, fdef->num_exports, 2541 1.1 christos external_name, internal_name, 2542 1.1 christos its_name, ordinal, is_dup); 2543 1.1 christos 2544 1.9 christos if (*is_dup) 2545 1.1 christos return (fdef->exports + pos); 2546 1.1 christos 2547 1.9 christos if ((unsigned)fdef->num_exports >= fdef->max_exports) 2548 1.1 christos { 2549 1.9 christos fdef->max_exports += SYMBOL_LIST_ARRAY_GROW; 2550 1.9 christos fdef->exports = xrealloc (fdef->exports, 2551 1.9 christos fdef->max_exports * sizeof (def_file_export)); 2552 1.1 christos } 2553 1.1 christos 2554 1.1 christos e = fdef->exports + pos; 2555 1.9 christos /* If we're inserting in the middle of the array, we need to move the 2556 1.9 christos following elements forward. */ 2557 1.9 christos if (pos != (unsigned)fdef->num_exports) 2558 1.1 christos memmove (&e[1], e, (sizeof (def_file_export) * (fdef->num_exports - pos))); 2559 1.9 christos /* Wipe the element for use as a new entry. */ 2560 1.1 christos memset (e, 0, sizeof (def_file_export)); 2561 1.1 christos e->name = xstrdup (external_name); 2562 1.1 christos e->internal_name = xstrdup (internal_name); 2563 1.1 christos e->its_name = (its_name ? xstrdup (its_name) : NULL); 2564 1.1 christos e->ordinal = ordinal; 2565 1.1 christos fdef->num_exports++; 2566 1.1 christos return e; 2567 1.1 christos } 2568 1.1 christos 2569 1.1 christos def_file_module * 2570 1.1 christos def_get_module (def_file *fdef, const char *name) 2571 1.1 christos { 2572 1.1 christos def_file_module *s; 2573 1.1 christos 2574 1.1 christos for (s = fdef->modules; s; s = s->next) 2575 1.1 christos if (strcmp (s->name, name) == 0) 2576 1.1 christos return s; 2577 1.1 christos 2578 1.1 christos return NULL; 2579 1.1 christos } 2580 1.1 christos 2581 1.1 christos static def_file_module * 2582 1.1 christos def_stash_module (def_file *fdef, const char *name) 2583 1.1 christos { 2584 1.1 christos def_file_module *s; 2585 1.1 christos 2586 1.1 christos if ((s = def_get_module (fdef, name)) != NULL) 2587 1.1 christos return s; 2588 1.1 christos s = xmalloc (sizeof (def_file_module) + strlen (name)); 2589 1.1 christos s->next = fdef->modules; 2590 1.1 christos fdef->modules = s; 2591 1.1 christos s->user_data = 0; 2592 1.1 christos strcpy (s->name, name); 2593 1.1 christos return s; 2594 1.1 christos } 2595 1.1 christos 2596 1.1 christos static int 2597 1.1 christos cmp_import_elem (const def_file_import *e, const char *ex_name, 2598 1.1 christos const char *in_name, const char *module, 2599 1.1 christos int ord) 2600 1.1 christos { 2601 1.1 christos int r; 2602 1.1 christos 2603 1.1 christos if ((r = are_names_equal (module, (e->module ? e->module->name : NULL)))) 2604 1.1 christos return r; 2605 1.1 christos if ((r = are_names_equal (ex_name, e->name)) != 0) 2606 1.1 christos return r; 2607 1.1 christos if ((r = are_names_equal (in_name, e->internal_name)) != 0) 2608 1.1 christos return r; 2609 1.1 christos if (ord != e->ordinal) 2610 1.1 christos return (ord < e->ordinal ? -1 : 1); 2611 1.1 christos return 0; 2612 1.1 christos } 2613 1.1 christos 2614 1.1 christos /* Search the position of the identical element, or returns the position 2615 1.1 christos of the next higher element. If last valid element is smaller, then MAX 2616 1.9 christos is returned. The max parameter indicates the number of elements in the 2617 1.9 christos array. On return, *is_ident indicates whether the returned array index 2618 1.9 christos points at an element which is identical to the one searched for. */ 2619 1.1 christos 2620 1.9 christos static unsigned int 2621 1.9 christos find_import_in_list (def_file_import *b, unsigned int max, 2622 1.1 christos const char *ex_name, const char *in_name, 2623 1.9 christos const char *module, int ord, bool *is_ident) 2624 1.1 christos { 2625 1.9 christos int e; 2626 1.9 christos unsigned int l, r, p; 2627 1.1 christos 2628 1.9 christos *is_ident = false; 2629 1.1 christos if (!max) 2630 1.1 christos return 0; 2631 1.1 christos if ((e = cmp_import_elem (b, ex_name, in_name, module, ord)) <= 0) 2632 1.1 christos { 2633 1.1 christos if (!e) 2634 1.9 christos *is_ident = true; 2635 1.1 christos return 0; 2636 1.1 christos } 2637 1.1 christos if (max == 1) 2638 1.1 christos return 1; 2639 1.1 christos if ((e = cmp_import_elem (b + (max - 1), ex_name, in_name, module, ord)) > 0) 2640 1.1 christos return max; 2641 1.1 christos else if (!e || max == 2) 2642 1.1 christos { 2643 1.1 christos if (!e) 2644 1.9 christos *is_ident = true; 2645 1.1 christos return max - 1; 2646 1.1 christos } 2647 1.1 christos l = 0; r = max - 1; 2648 1.1 christos while (l < r) 2649 1.1 christos { 2650 1.1 christos p = (l + r) / 2; 2651 1.1 christos e = cmp_import_elem (b + p, ex_name, in_name, module, ord); 2652 1.1 christos if (!e) 2653 1.6 christos { 2654 1.9 christos *is_ident = true; 2655 1.6 christos return p; 2656 1.6 christos } 2657 1.1 christos else if (e < 0) 2658 1.6 christos r = p - 1; 2659 1.1 christos else if (e > 0) 2660 1.6 christos l = p + 1; 2661 1.1 christos } 2662 1.1 christos if ((e = cmp_import_elem (b + l, ex_name, in_name, module, ord)) > 0) 2663 1.1 christos ++l; 2664 1.1 christos else if (!e) 2665 1.9 christos *is_ident = true; 2666 1.1 christos return l; 2667 1.1 christos } 2668 1.1 christos 2669 1.6 christos static void 2670 1.6 christos fill_in_import (def_file_import *i, 2671 1.6 christos const char *name, 2672 1.6 christos def_file_module *module, 2673 1.6 christos int ordinal, 2674 1.6 christos const char *internal_name, 2675 1.6 christos const char *its_name) 2676 1.6 christos { 2677 1.6 christos memset (i, 0, sizeof (def_file_import)); 2678 1.6 christos if (name) 2679 1.6 christos i->name = xstrdup (name); 2680 1.6 christos i->module = module; 2681 1.6 christos i->ordinal = ordinal; 2682 1.6 christos if (internal_name) 2683 1.6 christos i->internal_name = xstrdup (internal_name); 2684 1.6 christos else 2685 1.6 christos i->internal_name = i->name; 2686 1.6 christos i->its_name = (its_name ? xstrdup (its_name) : NULL); 2687 1.6 christos } 2688 1.6 christos 2689 1.1 christos def_file_import * 2690 1.1 christos def_file_add_import (def_file *fdef, 2691 1.1 christos const char *name, 2692 1.1 christos const char *module, 2693 1.1 christos int ordinal, 2694 1.1 christos const char *internal_name, 2695 1.1 christos const char *its_name, 2696 1.9 christos bool *is_dup) 2697 1.1 christos { 2698 1.1 christos def_file_import *i; 2699 1.9 christos unsigned int pos; 2700 1.1 christos 2701 1.1 christos /* We need to avoid here duplicates. */ 2702 1.9 christos *is_dup = false; 2703 1.1 christos pos = find_import_in_list (fdef->imports, fdef->num_imports, 2704 1.1 christos name, 2705 1.1 christos (!internal_name ? name : internal_name), 2706 1.1 christos module, ordinal, is_dup); 2707 1.9 christos if (*is_dup) 2708 1.1 christos return fdef->imports + pos; 2709 1.1 christos 2710 1.9 christos if ((unsigned)fdef->num_imports >= fdef->max_imports) 2711 1.1 christos { 2712 1.9 christos fdef->max_imports += SYMBOL_LIST_ARRAY_GROW; 2713 1.9 christos fdef->imports = xrealloc (fdef->imports, 2714 1.9 christos fdef->max_imports * sizeof (def_file_import)); 2715 1.1 christos } 2716 1.1 christos i = fdef->imports + pos; 2717 1.9 christos /* If we're inserting in the middle of the array, we need to move the 2718 1.9 christos following elements forward. */ 2719 1.9 christos if (pos != (unsigned)fdef->num_imports) 2720 1.6 christos memmove (i + 1, i, sizeof (def_file_import) * (fdef->num_imports - pos)); 2721 1.6 christos 2722 1.6 christos fill_in_import (i, name, def_stash_module (fdef, module), ordinal, 2723 1.6 christos internal_name, its_name); 2724 1.6 christos fdef->num_imports++; 2725 1.6 christos 2726 1.6 christos return i; 2727 1.6 christos } 2728 1.6 christos 2729 1.6 christos int 2730 1.6 christos def_file_add_import_from (def_file *fdef, 2731 1.6 christos int num_imports, 2732 1.6 christos const char *name, 2733 1.6 christos const char *module, 2734 1.6 christos int ordinal, 2735 1.6 christos const char *internal_name, 2736 1.6 christos const char *its_name ATTRIBUTE_UNUSED) 2737 1.6 christos { 2738 1.6 christos def_file_import *i; 2739 1.9 christos bool is_dup; 2740 1.9 christos unsigned int pos; 2741 1.6 christos 2742 1.6 christos /* We need to avoid here duplicates. */ 2743 1.9 christos is_dup = false; 2744 1.6 christos pos = find_import_in_list (fdef->imports, fdef->num_imports, 2745 1.6 christos name, internal_name ? internal_name : name, 2746 1.6 christos module, ordinal, &is_dup); 2747 1.9 christos if (is_dup) 2748 1.6 christos return -1; 2749 1.9 christos if (fdef->imports && pos != (unsigned)fdef->num_imports) 2750 1.6 christos { 2751 1.6 christos i = fdef->imports + pos; 2752 1.6 christos if (i->module && strcmp (i->module->name, module) == 0) 2753 1.6 christos return -1; 2754 1.6 christos } 2755 1.6 christos 2756 1.9 christos if ((unsigned)fdef->num_imports + num_imports - 1 >= fdef->max_imports) 2757 1.6 christos { 2758 1.9 christos fdef->max_imports = fdef->num_imports + num_imports + 2759 1.9 christos SYMBOL_LIST_ARRAY_GROW; 2760 1.6 christos 2761 1.9 christos fdef->imports = xrealloc (fdef->imports, 2762 1.9 christos fdef->max_imports * sizeof (def_file_import)); 2763 1.6 christos } 2764 1.6 christos i = fdef->imports + pos; 2765 1.9 christos /* If we're inserting in the middle of the array, we need to move the 2766 1.9 christos following elements forward. */ 2767 1.9 christos if (pos != (unsigned)fdef->num_imports) 2768 1.6 christos memmove (i + num_imports, i, 2769 1.6 christos sizeof (def_file_import) * (fdef->num_imports - pos)); 2770 1.6 christos 2771 1.6 christos return pos; 2772 1.6 christos } 2773 1.6 christos 2774 1.6 christos def_file_import * 2775 1.6 christos def_file_add_import_at (def_file *fdef, 2776 1.6 christos int pos, 2777 1.6 christos const char *name, 2778 1.6 christos const char *module, 2779 1.6 christos int ordinal, 2780 1.6 christos const char *internal_name, 2781 1.6 christos const char *its_name) 2782 1.6 christos { 2783 1.6 christos def_file_import *i = fdef->imports + pos; 2784 1.6 christos 2785 1.6 christos fill_in_import (i, name, def_stash_module (fdef, module), ordinal, 2786 1.6 christos internal_name, its_name); 2787 1.1 christos fdef->num_imports++; 2788 1.1 christos 2789 1.1 christos return i; 2790 1.1 christos } 2791 1.1 christos 2792 1.9 christos /* Search the position of the identical element, or returns the position 2793 1.9 christos of the next higher element. If last valid element is smaller, then MAX 2794 1.9 christos is returned. The max parameter indicates the number of elements in the 2795 1.9 christos array. On return, *is_ident indicates whether the returned array index 2796 1.9 christos points at an element which is identical to the one searched for. */ 2797 1.9 christos 2798 1.9 christos static unsigned int 2799 1.9 christos find_exclude_in_list (def_file_exclude_symbol *b, unsigned int max, 2800 1.9 christos const char *name, bool *is_ident) 2801 1.9 christos { 2802 1.9 christos int e; 2803 1.9 christos unsigned int l, r, p; 2804 1.9 christos 2805 1.9 christos *is_ident = false; 2806 1.9 christos if (!max) 2807 1.9 christos return 0; 2808 1.9 christos if ((e = strcmp (b[0].symbol_name, name)) <= 0) 2809 1.9 christos { 2810 1.9 christos if (!e) 2811 1.9 christos *is_ident = true; 2812 1.9 christos return 0; 2813 1.9 christos } 2814 1.9 christos if (max == 1) 2815 1.9 christos return 1; 2816 1.9 christos if ((e = strcmp (b[max - 1].symbol_name, name)) > 0) 2817 1.9 christos return max; 2818 1.9 christos else if (!e || max == 2) 2819 1.9 christos { 2820 1.9 christos if (!e) 2821 1.9 christos *is_ident = true; 2822 1.9 christos return max - 1; 2823 1.9 christos } 2824 1.9 christos l = 0; r = max - 1; 2825 1.9 christos while (l < r) 2826 1.9 christos { 2827 1.9 christos p = (l + r) / 2; 2828 1.9 christos e = strcmp (b[p].symbol_name, name); 2829 1.9 christos if (!e) 2830 1.9 christos { 2831 1.9 christos *is_ident = true; 2832 1.9 christos return p; 2833 1.9 christos } 2834 1.9 christos else if (e < 0) 2835 1.9 christos r = p - 1; 2836 1.9 christos else if (e > 0) 2837 1.9 christos l = p + 1; 2838 1.9 christos } 2839 1.9 christos if ((e = strcmp (b[l].symbol_name, name)) > 0) 2840 1.9 christos ++l; 2841 1.9 christos else if (!e) 2842 1.9 christos *is_ident = true; 2843 1.9 christos return l; 2844 1.9 christos } 2845 1.9 christos 2846 1.9 christos static def_file_exclude_symbol * 2847 1.9 christos def_file_add_exclude_symbol (def_file *fdef, const char *name) 2848 1.9 christos { 2849 1.9 christos def_file_exclude_symbol *e; 2850 1.9 christos unsigned pos; 2851 1.9 christos bool is_dup = false; 2852 1.9 christos 2853 1.9 christos pos = find_exclude_in_list (fdef->exclude_symbols, fdef->num_exclude_symbols, 2854 1.9 christos name, &is_dup); 2855 1.9 christos 2856 1.9 christos /* We need to avoid duplicates. */ 2857 1.9 christos if (is_dup) 2858 1.9 christos return (fdef->exclude_symbols + pos); 2859 1.9 christos 2860 1.9 christos if (fdef->num_exclude_symbols >= fdef->max_exclude_symbols) 2861 1.9 christos { 2862 1.9 christos fdef->max_exclude_symbols += SYMBOL_LIST_ARRAY_GROW; 2863 1.9 christos fdef->exclude_symbols = xrealloc (fdef->exclude_symbols, 2864 1.9 christos fdef->max_exclude_symbols * sizeof (def_file_exclude_symbol)); 2865 1.9 christos } 2866 1.9 christos 2867 1.9 christos e = fdef->exclude_symbols + pos; 2868 1.9 christos /* If we're inserting in the middle of the array, we need to move the 2869 1.9 christos following elements forward. */ 2870 1.9 christos if (pos != fdef->num_exclude_symbols) 2871 1.9 christos memmove (&e[1], e, (sizeof (def_file_exclude_symbol) * (fdef->num_exclude_symbols - pos))); 2872 1.9 christos /* Wipe the element for use as a new entry. */ 2873 1.9 christos memset (e, 0, sizeof (def_file_exclude_symbol)); 2874 1.9 christos e->symbol_name = xstrdup (name); 2875 1.9 christos fdef->num_exclude_symbols++; 2876 1.9 christos return e; 2877 1.9 christos } 2878 1.9 christos 2879 1.1 christos struct 2880 1.1 christos { 2881 1.1 christos char *param; 2882 1.1 christos int token; 2883 1.1 christos } 2884 1.1 christos diropts[] = 2885 1.1 christos { 2886 1.1 christos { "-heap", HEAPSIZE }, 2887 1.1 christos { "-stack", STACKSIZE_K }, 2888 1.1 christos { "-attr", SECTIONS }, 2889 1.1 christos { "-export", EXPORTS }, 2890 1.1 christos { "-aligncomm", ALIGNCOMM }, 2891 1.9 christos { "-exclude-symbols", EXCLUDE_SYMBOLS }, 2892 1.1 christos { 0, 0 } 2893 1.1 christos }; 2894 1.1 christos 2895 1.1 christos void 2896 1.1 christos def_file_add_directive (def_file *my_def, const char *param, int len) 2897 1.1 christos { 2898 1.1 christos def_file *save_def = def; 2899 1.1 christos const char *pend = param + len; 2900 1.1 christos char * tend = (char *) param; 2901 1.1 christos int i; 2902 1.1 christos 2903 1.1 christos def = my_def; 2904 1.1 christos 2905 1.1 christos while (param < pend) 2906 1.1 christos { 2907 1.1 christos while (param < pend 2908 1.1 christos && (ISSPACE (*param) || *param == '\n' || *param == 0)) 2909 1.1 christos param++; 2910 1.1 christos 2911 1.1 christos if (param == pend) 2912 1.1 christos break; 2913 1.1 christos 2914 1.1 christos /* Scan forward until we encounter any of: 2915 1.6 christos - the end of the buffer 2916 1.1 christos - the start of a new option 2917 1.6 christos - a newline separating options 2918 1.6 christos - a NUL separating options. */ 2919 1.1 christos for (tend = (char *) (param + 1); 2920 1.1 christos (tend < pend 2921 1.1 christos && !(ISSPACE (tend[-1]) && *tend == '-') 2922 1.1 christos && *tend != '\n' && *tend != 0); 2923 1.1 christos tend++) 2924 1.1 christos ; 2925 1.1 christos 2926 1.1 christos for (i = 0; diropts[i].param; i++) 2927 1.1 christos { 2928 1.1 christos len = strlen (diropts[i].param); 2929 1.1 christos 2930 1.1 christos if (tend - param >= len 2931 1.1 christos && strncmp (param, diropts[i].param, len) == 0 2932 1.1 christos && (param[len] == ':' || param[len] == ' ')) 2933 1.1 christos { 2934 1.1 christos lex_parse_string_end = tend; 2935 1.1 christos lex_parse_string = param + len + 1; 2936 1.1 christos lex_forced_token = diropts[i].token; 2937 1.1 christos saw_newline = 0; 2938 1.1 christos if (def_parse ()) 2939 1.1 christos continue; 2940 1.1 christos break; 2941 1.1 christos } 2942 1.1 christos } 2943 1.1 christos 2944 1.1 christos if (!diropts[i].param) 2945 1.1 christos { 2946 1.3 christos if (tend < pend) 2947 1.3 christos { 2948 1.3 christos char saved; 2949 1.1 christos 2950 1.3 christos saved = * tend; 2951 1.3 christos * tend = 0; 2952 1.3 christos /* xgettext:c-format */ 2953 1.3 christos einfo (_("Warning: .drectve `%s' unrecognized\n"), param); 2954 1.3 christos * tend = saved; 2955 1.3 christos } 2956 1.3 christos else 2957 1.3 christos { 2958 1.3 christos einfo (_("Warning: corrupt .drectve at end of def file\n")); 2959 1.3 christos } 2960 1.1 christos } 2961 1.1 christos 2962 1.1 christos lex_parse_string = 0; 2963 1.1 christos param = tend; 2964 1.1 christos } 2965 1.1 christos 2966 1.1 christos def = save_def; 2967 1.1 christos def_pool_free (); 2968 1.1 christos } 2969 1.1 christos 2970 1.1 christos /* Parser Callbacks. */ 2971 1.1 christos 2972 1.1 christos static void 2973 1.3 christos def_image_name (const char *name, bfd_vma base, int is_dll) 2974 1.1 christos { 2975 1.1 christos /* If a LIBRARY or NAME statement is specified without a name, there is nothing 2976 1.1 christos to do here. We retain the output filename specified on command line. */ 2977 1.1 christos if (*name) 2978 1.1 christos { 2979 1.1 christos const char* image_name = lbasename (name); 2980 1.1 christos 2981 1.1 christos if (image_name != name) 2982 1.9 christos einfo (_("%s:%d: Warning: path components stripped from %s, '%s'\n"), 2983 1.1 christos def_filename, linenumber, is_dll ? "LIBRARY" : "NAME", 2984 1.1 christos name); 2985 1.8 christos free (def->name); 2986 1.3 christos /* Append the default suffix, if none specified. */ 2987 1.1 christos if (strchr (image_name, '.') == 0) 2988 1.1 christos { 2989 1.1 christos const char * suffix = is_dll ? ".dll" : ".exe"; 2990 1.1 christos 2991 1.1 christos def->name = xmalloc (strlen (image_name) + strlen (suffix) + 1); 2992 1.1 christos sprintf (def->name, "%s%s", image_name, suffix); 2993 1.6 christos } 2994 1.1 christos else 2995 1.1 christos def->name = xstrdup (image_name); 2996 1.1 christos } 2997 1.1 christos 2998 1.1 christos /* Honor a BASE address statement, even if LIBRARY string is empty. */ 2999 1.1 christos def->base_address = base; 3000 1.1 christos def->is_dll = is_dll; 3001 1.1 christos } 3002 1.1 christos 3003 1.1 christos static void 3004 1.1 christos def_description (const char *text) 3005 1.1 christos { 3006 1.1 christos int len = def->description ? strlen (def->description) : 0; 3007 1.1 christos 3008 1.1 christos len += strlen (text) + 1; 3009 1.1 christos if (def->description) 3010 1.1 christos { 3011 1.1 christos def->description = xrealloc (def->description, len); 3012 1.1 christos strcat (def->description, text); 3013 1.1 christos } 3014 1.1 christos else 3015 1.1 christos { 3016 1.1 christos def->description = xmalloc (len); 3017 1.1 christos strcpy (def->description, text); 3018 1.1 christos } 3019 1.1 christos } 3020 1.1 christos 3021 1.1 christos static void 3022 1.1 christos def_stacksize (int reserve, int commit) 3023 1.1 christos { 3024 1.1 christos def->stack_reserve = reserve; 3025 1.1 christos def->stack_commit = commit; 3026 1.1 christos } 3027 1.1 christos 3028 1.1 christos static void 3029 1.1 christos def_heapsize (int reserve, int commit) 3030 1.1 christos { 3031 1.1 christos def->heap_reserve = reserve; 3032 1.1 christos def->heap_commit = commit; 3033 1.1 christos } 3034 1.1 christos 3035 1.1 christos static void 3036 1.1 christos def_section (const char *name, int attr) 3037 1.1 christos { 3038 1.1 christos def_file_section *s; 3039 1.1 christos int max_sections = ROUND_UP (def->num_section_defs, 4); 3040 1.1 christos 3041 1.1 christos if (def->num_section_defs >= max_sections) 3042 1.1 christos { 3043 1.1 christos max_sections = ROUND_UP (def->num_section_defs+1, 4); 3044 1.1 christos 3045 1.1 christos if (def->section_defs) 3046 1.1 christos def->section_defs = xrealloc (def->section_defs, 3047 1.1 christos max_sections * sizeof (def_file_import)); 3048 1.1 christos else 3049 1.1 christos def->section_defs = xmalloc (max_sections * sizeof (def_file_import)); 3050 1.1 christos } 3051 1.1 christos s = def->section_defs + def->num_section_defs; 3052 1.1 christos memset (s, 0, sizeof (def_file_section)); 3053 1.1 christos s->name = xstrdup (name); 3054 1.1 christos if (attr & 1) 3055 1.1 christos s->flag_read = 1; 3056 1.1 christos if (attr & 2) 3057 1.1 christos s->flag_write = 1; 3058 1.1 christos if (attr & 4) 3059 1.1 christos s->flag_execute = 1; 3060 1.1 christos if (attr & 8) 3061 1.1 christos s->flag_shared = 1; 3062 1.1 christos 3063 1.1 christos def->num_section_defs++; 3064 1.1 christos } 3065 1.1 christos 3066 1.1 christos static void 3067 1.1 christos def_section_alt (const char *name, const char *attr) 3068 1.1 christos { 3069 1.1 christos int aval = 0; 3070 1.1 christos 3071 1.1 christos for (; *attr; attr++) 3072 1.1 christos { 3073 1.1 christos switch (*attr) 3074 1.1 christos { 3075 1.1 christos case 'R': 3076 1.1 christos case 'r': 3077 1.1 christos aval |= 1; 3078 1.1 christos break; 3079 1.1 christos case 'W': 3080 1.1 christos case 'w': 3081 1.1 christos aval |= 2; 3082 1.1 christos break; 3083 1.1 christos case 'X': 3084 1.1 christos case 'x': 3085 1.1 christos aval |= 4; 3086 1.1 christos break; 3087 1.1 christos case 'S': 3088 1.1 christos case 's': 3089 1.1 christos aval |= 8; 3090 1.1 christos break; 3091 1.1 christos } 3092 1.1 christos } 3093 1.1 christos def_section (name, aval); 3094 1.1 christos } 3095 1.1 christos 3096 1.1 christos static void 3097 1.1 christos def_exports (const char *external_name, 3098 1.1 christos const char *internal_name, 3099 1.1 christos int ordinal, 3100 1.1 christos int flags, 3101 1.1 christos const char *its_name) 3102 1.1 christos { 3103 1.1 christos def_file_export *dfe; 3104 1.9 christos bool is_dup = false; 3105 1.1 christos 3106 1.1 christos if (!internal_name && external_name) 3107 1.1 christos internal_name = external_name; 3108 1.1 christos #if TRACE 3109 1.1 christos printf ("def_exports, ext=%s int=%s\n", external_name, internal_name); 3110 1.1 christos #endif 3111 1.1 christos 3112 1.1 christos dfe = def_file_add_export (def, external_name, internal_name, ordinal, 3113 1.1 christos its_name, &is_dup); 3114 1.1 christos 3115 1.1 christos /* We might check here for flag redefinition and warn. For now we 3116 1.1 christos ignore duplicates silently. */ 3117 1.1 christos if (is_dup) 3118 1.1 christos return; 3119 1.1 christos 3120 1.1 christos if (flags & 1) 3121 1.1 christos dfe->flag_noname = 1; 3122 1.1 christos if (flags & 2) 3123 1.1 christos dfe->flag_constant = 1; 3124 1.1 christos if (flags & 4) 3125 1.1 christos dfe->flag_data = 1; 3126 1.1 christos if (flags & 8) 3127 1.1 christos dfe->flag_private = 1; 3128 1.1 christos } 3129 1.1 christos 3130 1.1 christos static void 3131 1.1 christos def_import (const char *internal_name, 3132 1.1 christos const char *module, 3133 1.1 christos const char *dllext, 3134 1.1 christos const char *name, 3135 1.1 christos int ordinal, 3136 1.1 christos const char *its_name) 3137 1.1 christos { 3138 1.1 christos char *buf = 0; 3139 1.1 christos const char *ext = dllext ? dllext : "dll"; 3140 1.9 christos bool is_dup = false; 3141 1.3 christos 3142 1.1 christos buf = xmalloc (strlen (module) + strlen (ext) + 2); 3143 1.1 christos sprintf (buf, "%s.%s", module, ext); 3144 1.1 christos module = buf; 3145 1.1 christos 3146 1.1 christos def_file_add_import (def, name, module, ordinal, internal_name, its_name, 3147 1.1 christos &is_dup); 3148 1.1 christos free (buf); 3149 1.1 christos } 3150 1.1 christos 3151 1.1 christos static void 3152 1.1 christos def_version (int major, int minor) 3153 1.1 christos { 3154 1.1 christos def->version_major = major; 3155 1.1 christos def->version_minor = minor; 3156 1.1 christos } 3157 1.1 christos 3158 1.1 christos static void 3159 1.1 christos def_directive (char *str) 3160 1.1 christos { 3161 1.1 christos struct directive *d = xmalloc (sizeof (struct directive)); 3162 1.1 christos 3163 1.1 christos d->next = directives; 3164 1.1 christos directives = d; 3165 1.1 christos d->name = xstrdup (str); 3166 1.1 christos d->len = strlen (str); 3167 1.1 christos } 3168 1.1 christos 3169 1.1 christos static void 3170 1.1 christos def_aligncomm (char *str, int align) 3171 1.1 christos { 3172 1.1 christos def_file_aligncomm *c, *p; 3173 1.3 christos 3174 1.1 christos p = NULL; 3175 1.1 christos c = def->aligncomms; 3176 1.1 christos while (c != NULL) 3177 1.1 christos { 3178 1.1 christos int e = strcmp (c->symbol_name, str); 3179 1.1 christos if (!e) 3180 1.1 christos { 3181 1.1 christos /* Not sure if we want to allow here duplicates with 3182 1.1 christos different alignments, but for now we keep them. */ 3183 1.1 christos e = (int) c->alignment - align; 3184 1.1 christos if (!e) 3185 1.1 christos return; 3186 1.1 christos } 3187 1.1 christos if (e > 0) 3188 1.6 christos break; 3189 1.1 christos c = (p = c)->next; 3190 1.1 christos } 3191 1.1 christos 3192 1.1 christos c = xmalloc (sizeof (def_file_aligncomm)); 3193 1.1 christos c->symbol_name = xstrdup (str); 3194 1.1 christos c->alignment = (unsigned int) align; 3195 1.1 christos if (!p) 3196 1.1 christos { 3197 1.1 christos c->next = def->aligncomms; 3198 1.1 christos def->aligncomms = c; 3199 1.1 christos } 3200 1.1 christos else 3201 1.1 christos { 3202 1.1 christos c->next = p->next; 3203 1.1 christos p->next = c; 3204 1.1 christos } 3205 1.1 christos } 3206 1.1 christos 3207 1.8 christos static void 3208 1.9 christos def_exclude_symbols (char *str) 3209 1.9 christos { 3210 1.9 christos def_file_add_exclude_symbol (def, str); 3211 1.9 christos } 3212 1.9 christos 3213 1.9 christos static void 3214 1.1 christos def_error (const char *err) 3215 1.1 christos { 3216 1.1 christos einfo ("%P: %s:%d: %s\n", 3217 1.1 christos def_filename ? def_filename : "<unknown-file>", linenumber, err); 3218 1.1 christos } 3219 1.1 christos 3220 1.1 christos 3221 1.1 christos /* Lexical Scanner. */ 3222 1.1 christos 3223 1.1 christos #undef TRACE 3224 1.1 christos #define TRACE 0 3225 1.1 christos 3226 1.1 christos /* Never freed, but always reused as needed, so no real leak. */ 3227 1.1 christos static char *buffer = 0; 3228 1.1 christos static int buflen = 0; 3229 1.1 christos static int bufptr = 0; 3230 1.1 christos 3231 1.1 christos static void 3232 1.1 christos put_buf (char c) 3233 1.1 christos { 3234 1.1 christos if (bufptr == buflen) 3235 1.1 christos { 3236 1.1 christos buflen += 50; /* overly reasonable, eh? */ 3237 1.1 christos if (buffer) 3238 1.1 christos buffer = xrealloc (buffer, buflen + 1); 3239 1.1 christos else 3240 1.1 christos buffer = xmalloc (buflen + 1); 3241 1.1 christos } 3242 1.1 christos buffer[bufptr++] = c; 3243 1.1 christos buffer[bufptr] = 0; /* not optimal, but very convenient. */ 3244 1.1 christos } 3245 1.1 christos 3246 1.1 christos static struct 3247 1.1 christos { 3248 1.1 christos char *name; 3249 1.1 christos int token; 3250 1.1 christos } 3251 1.1 christos tokens[] = 3252 1.1 christos { 3253 1.1 christos { "BASE", BASE }, 3254 1.1 christos { "CODE", CODE }, 3255 1.1 christos { "CONSTANT", CONSTANTU }, 3256 1.1 christos { "constant", CONSTANTL }, 3257 1.1 christos { "DATA", DATAU }, 3258 1.1 christos { "data", DATAL }, 3259 1.1 christos { "DESCRIPTION", DESCRIPTION }, 3260 1.1 christos { "DIRECTIVE", DIRECTIVE }, 3261 1.9 christos { "EXCLUDE_SYMBOLS", EXCLUDE_SYMBOLS }, 3262 1.1 christos { "EXECUTE", EXECUTE }, 3263 1.1 christos { "EXPORTS", EXPORTS }, 3264 1.1 christos { "HEAPSIZE", HEAPSIZE }, 3265 1.1 christos { "IMPORTS", IMPORTS }, 3266 1.1 christos { "LIBRARY", LIBRARY }, 3267 1.1 christos { "NAME", NAME }, 3268 1.1 christos { "NONAME", NONAMEU }, 3269 1.1 christos { "noname", NONAMEL }, 3270 1.1 christos { "PRIVATE", PRIVATEU }, 3271 1.1 christos { "private", PRIVATEL }, 3272 1.1 christos { "READ", READ }, 3273 1.1 christos { "SECTIONS", SECTIONS }, 3274 1.1 christos { "SEGMENTS", SECTIONS }, 3275 1.8 christos { "SHARED", SHARED_K }, 3276 1.1 christos { "STACKSIZE", STACKSIZE_K }, 3277 1.1 christos { "VERSION", VERSIONK }, 3278 1.1 christos { "WRITE", WRITE }, 3279 1.1 christos { 0, 0 } 3280 1.1 christos }; 3281 1.1 christos 3282 1.1 christos static int 3283 1.1 christos def_getc (void) 3284 1.1 christos { 3285 1.1 christos int rv; 3286 1.1 christos 3287 1.1 christos if (lex_parse_string) 3288 1.1 christos { 3289 1.1 christos if (lex_parse_string >= lex_parse_string_end) 3290 1.1 christos rv = EOF; 3291 1.1 christos else 3292 1.1 christos rv = *lex_parse_string++; 3293 1.1 christos } 3294 1.1 christos else 3295 1.1 christos { 3296 1.1 christos rv = fgetc (the_file); 3297 1.1 christos } 3298 1.1 christos if (rv == '\n') 3299 1.1 christos saw_newline = 1; 3300 1.1 christos return rv; 3301 1.1 christos } 3302 1.1 christos 3303 1.1 christos static int 3304 1.1 christos def_ungetc (int c) 3305 1.1 christos { 3306 1.1 christos if (lex_parse_string) 3307 1.1 christos { 3308 1.1 christos lex_parse_string--; 3309 1.1 christos return c; 3310 1.1 christos } 3311 1.1 christos else 3312 1.1 christos return ungetc (c, the_file); 3313 1.1 christos } 3314 1.1 christos 3315 1.1 christos static int 3316 1.1 christos def_lex (void) 3317 1.1 christos { 3318 1.1 christos int c, i, q; 3319 1.1 christos 3320 1.1 christos if (lex_forced_token) 3321 1.1 christos { 3322 1.1 christos i = lex_forced_token; 3323 1.1 christos lex_forced_token = 0; 3324 1.1 christos #if TRACE 3325 1.1 christos printf ("lex: forcing token %d\n", i); 3326 1.1 christos #endif 3327 1.1 christos return i; 3328 1.1 christos } 3329 1.1 christos 3330 1.1 christos c = def_getc (); 3331 1.1 christos 3332 1.1 christos /* Trim leading whitespace. */ 3333 1.1 christos while (c != EOF && (c == ' ' || c == '\t') && saw_newline) 3334 1.1 christos c = def_getc (); 3335 1.1 christos 3336 1.1 christos if (c == EOF) 3337 1.1 christos { 3338 1.1 christos #if TRACE 3339 1.1 christos printf ("lex: EOF\n"); 3340 1.1 christos #endif 3341 1.1 christos return 0; 3342 1.1 christos } 3343 1.1 christos 3344 1.1 christos if (saw_newline && c == ';') 3345 1.1 christos { 3346 1.1 christos do 3347 1.1 christos { 3348 1.1 christos c = def_getc (); 3349 1.1 christos } 3350 1.1 christos while (c != EOF && c != '\n'); 3351 1.1 christos if (c == '\n') 3352 1.1 christos return def_lex (); 3353 1.1 christos return 0; 3354 1.1 christos } 3355 1.1 christos 3356 1.1 christos /* Must be something else. */ 3357 1.1 christos saw_newline = 0; 3358 1.1 christos 3359 1.1 christos if (ISDIGIT (c)) 3360 1.1 christos { 3361 1.1 christos bufptr = 0; 3362 1.1 christos while (c != EOF && (ISXDIGIT (c) || (c == 'x'))) 3363 1.1 christos { 3364 1.1 christos put_buf (c); 3365 1.1 christos c = def_getc (); 3366 1.1 christos } 3367 1.1 christos if (c != EOF) 3368 1.1 christos def_ungetc (c); 3369 1.1 christos yylval.digits = def_pool_strdup (buffer); 3370 1.1 christos #if TRACE 3371 1.1 christos printf ("lex: `%s' returns DIGITS\n", buffer); 3372 1.1 christos #endif 3373 1.1 christos return DIGITS; 3374 1.1 christos } 3375 1.1 christos 3376 1.1 christos if (ISALPHA (c) || strchr ("$:-_?@", c)) 3377 1.1 christos { 3378 1.1 christos bufptr = 0; 3379 1.1 christos q = c; 3380 1.1 christos put_buf (c); 3381 1.1 christos c = def_getc (); 3382 1.1 christos 3383 1.1 christos if (q == '@') 3384 1.1 christos { 3385 1.6 christos if (ISBLANK (c) ) /* '@' followed by whitespace. */ 3386 1.1 christos return (q); 3387 1.6 christos else if (ISDIGIT (c)) /* '@' followed by digit. */ 3388 1.6 christos { 3389 1.1 christos def_ungetc (c); 3390 1.6 christos return (q); 3391 1.1 christos } 3392 1.1 christos #if TRACE 3393 1.1 christos printf ("lex: @ returns itself\n"); 3394 1.1 christos #endif 3395 1.1 christos } 3396 1.1 christos 3397 1.1 christos while (c != EOF && (ISALNUM (c) || strchr ("$:-_?/@<>", c))) 3398 1.1 christos { 3399 1.1 christos put_buf (c); 3400 1.1 christos c = def_getc (); 3401 1.1 christos } 3402 1.1 christos if (c != EOF) 3403 1.1 christos def_ungetc (c); 3404 1.1 christos if (ISALPHA (q)) /* Check for tokens. */ 3405 1.1 christos { 3406 1.6 christos for (i = 0; tokens[i].name; i++) 3407 1.1 christos if (strcmp (tokens[i].name, buffer) == 0) 3408 1.1 christos { 3409 1.1 christos #if TRACE 3410 1.1 christos printf ("lex: `%s' is a string token\n", buffer); 3411 1.1 christos #endif 3412 1.1 christos return tokens[i].token; 3413 1.1 christos } 3414 1.1 christos } 3415 1.1 christos #if TRACE 3416 1.1 christos printf ("lex: `%s' returns ID\n", buffer); 3417 1.1 christos #endif 3418 1.1 christos yylval.id = def_pool_strdup (buffer); 3419 1.1 christos return ID; 3420 1.1 christos } 3421 1.1 christos 3422 1.1 christos if (c == '\'' || c == '"') 3423 1.1 christos { 3424 1.1 christos q = c; 3425 1.1 christos c = def_getc (); 3426 1.1 christos bufptr = 0; 3427 1.1 christos 3428 1.1 christos while (c != EOF && c != q) 3429 1.1 christos { 3430 1.1 christos put_buf (c); 3431 1.1 christos c = def_getc (); 3432 1.1 christos } 3433 1.1 christos yylval.id = def_pool_strdup (buffer); 3434 1.1 christos #if TRACE 3435 1.1 christos printf ("lex: `%s' returns ID\n", buffer); 3436 1.1 christos #endif 3437 1.1 christos return ID; 3438 1.1 christos } 3439 1.1 christos 3440 1.1 christos if ( c == '=') 3441 1.1 christos { 3442 1.1 christos c = def_getc (); 3443 1.1 christos if (c == '=') 3444 1.6 christos { 3445 1.1 christos #if TRACE 3446 1.6 christos printf ("lex: `==' returns EQUAL\n"); 3447 1.1 christos #endif 3448 1.6 christos return EQUAL; 3449 1.6 christos } 3450 1.1 christos def_ungetc (c); 3451 1.1 christos #if TRACE 3452 1.1 christos printf ("lex: `=' returns itself\n"); 3453 1.1 christos #endif 3454 1.1 christos return '='; 3455 1.1 christos } 3456 1.1 christos if (c == '.' || c == ',') 3457 1.1 christos { 3458 1.1 christos #if TRACE 3459 1.1 christos printf ("lex: `%c' returns itself\n", c); 3460 1.1 christos #endif 3461 1.1 christos return c; 3462 1.1 christos } 3463 1.1 christos 3464 1.1 christos if (c == '\n') 3465 1.1 christos { 3466 1.1 christos linenumber++; 3467 1.1 christos saw_newline = 1; 3468 1.1 christos } 3469 1.1 christos 3470 1.1 christos /*printf ("lex: 0x%02x ignored\n", c); */ 3471 1.1 christos return def_lex (); 3472 1.1 christos } 3473 1.1 christos 3474 1.1 christos static char * 3475 1.1 christos def_pool_alloc (size_t sz) 3476 1.1 christos { 3477 1.1 christos def_pool_str *e; 3478 1.1 christos 3479 1.1 christos e = (def_pool_str *) xmalloc (sizeof (def_pool_str) + sz); 3480 1.1 christos e->next = pool_strs; 3481 1.1 christos pool_strs = e; 3482 1.1 christos return e->data; 3483 1.1 christos } 3484 1.1 christos 3485 1.1 christos static char * 3486 1.1 christos def_pool_strdup (const char *str) 3487 1.1 christos { 3488 1.1 christos char *s; 3489 1.1 christos size_t len; 3490 1.1 christos if (!str) 3491 1.1 christos return NULL; 3492 1.1 christos len = strlen (str) + 1; 3493 1.1 christos s = def_pool_alloc (len); 3494 1.1 christos memcpy (s, str, len); 3495 1.1 christos return s; 3496 1.1 christos } 3497 1.1 christos 3498 1.1 christos static void 3499 1.1 christos def_pool_free (void) 3500 1.1 christos { 3501 1.1 christos def_pool_str *p; 3502 1.1 christos while ((p = pool_strs) != NULL) 3503 1.1 christos { 3504 1.1 christos pool_strs = p->next; 3505 1.1 christos free (p); 3506 1.1 christos } 3507 1.1 christos } 3508