1 #line 2 "scan-code.c" 2 3 #line 4 "scan-code.c" 4 5 #define YY_INT_ALIGNED short int 6 7 /* A lexical scanner generated by flex */ 8 9 /* %not-for-header */ 10 11 /* %if-c-only */ 12 /* %if-not-reentrant */ 13 #define yy_create_buffer code__create_buffer 14 #define yy_delete_buffer code__delete_buffer 15 #define yy_flex_debug code__flex_debug 16 #define yy_init_buffer code__init_buffer 17 #define yy_flush_buffer code__flush_buffer 18 #define yy_load_buffer_state code__load_buffer_state 19 #define yy_switch_to_buffer code__switch_to_buffer 20 #define yyin code_in 21 #define yyleng code_leng 22 #define yylex code_lex 23 #define yylineno code_lineno 24 #define yyout code_out 25 #define yyrestart code_restart 26 #define yytext code_text 27 #define yywrap code_wrap 28 #define yyalloc code_alloc 29 #define yyrealloc code_realloc 30 #define yyfree code_free 31 32 /* %endif */ 33 /* %endif */ 34 /* %ok-for-header */ 35 36 #define FLEX_SCANNER 37 #define YY_FLEX_MAJOR_VERSION 2 38 #define YY_FLEX_MINOR_VERSION 5 39 #define YY_FLEX_SUBMINOR_VERSION 37 40 #if YY_FLEX_SUBMINOR_VERSION > 0 41 #define FLEX_BETA 42 #endif 43 44 /* %if-c++-only */ 45 /* %endif */ 46 47 /* %if-c-only */ 48 49 /* %endif */ 50 51 /* %if-c-only */ 52 53 /* %endif */ 54 55 /* First, we deal with platform-specific or compiler-specific issues. */ 56 57 /* begin standard C headers. */ 58 /* %if-c-only */ 59 #include <stdio.h> 60 #include <string.h> 61 #include <errno.h> 62 #include <stdlib.h> 63 /* %endif */ 64 65 /* %if-tables-serialization */ 66 /* %endif */ 67 /* end standard C headers. */ 68 69 /* %if-c-or-c++ */ 70 /* flex integer type definitions */ 71 72 #ifndef FLEXINT_H 73 #define FLEXINT_H 74 75 /* C99 systems have <inttypes.h>. Non-C99 systems may or may not. */ 76 77 #if defined (__STDC_VERSION__) && __STDC_VERSION__ >= 199901L 78 79 /* C99 says to define __STDC_LIMIT_MACROS before including stdint.h, 80 * if you want the limit (max/min) macros for int types. 81 */ 82 #ifndef __STDC_LIMIT_MACROS 83 #define __STDC_LIMIT_MACROS 1 84 #endif 85 86 #include <inttypes.h> 87 typedef int8_t flex_int8_t; 88 typedef uint8_t flex_uint8_t; 89 typedef int16_t flex_int16_t; 90 typedef uint16_t flex_uint16_t; 91 typedef int32_t flex_int32_t; 92 typedef uint32_t flex_uint32_t; 93 #else 94 typedef signed char flex_int8_t; 95 typedef short int flex_int16_t; 96 typedef int flex_int32_t; 97 typedef unsigned char flex_uint8_t; 98 typedef unsigned short int flex_uint16_t; 99 typedef unsigned int flex_uint32_t; 100 101 /* Limits of integral types. */ 102 #ifndef INT8_MIN 103 #define INT8_MIN (-128) 104 #endif 105 #ifndef INT16_MIN 106 #define INT16_MIN (-32767-1) 107 #endif 108 #ifndef INT32_MIN 109 #define INT32_MIN (-2147483647-1) 110 #endif 111 #ifndef INT8_MAX 112 #define INT8_MAX (127) 113 #endif 114 #ifndef INT16_MAX 115 #define INT16_MAX (32767) 116 #endif 117 #ifndef INT32_MAX 118 #define INT32_MAX (2147483647) 119 #endif 120 #ifndef UINT8_MAX 121 #define UINT8_MAX (255U) 122 #endif 123 #ifndef UINT16_MAX 124 #define UINT16_MAX (65535U) 125 #endif 126 #ifndef UINT32_MAX 127 #define UINT32_MAX (4294967295U) 128 #endif 129 130 #endif /* ! C99 */ 131 132 #endif /* ! FLEXINT_H */ 133 134 /* %endif */ 135 136 /* %if-c++-only */ 137 /* %endif */ 138 139 #ifdef __cplusplus 140 141 /* The "const" storage-class-modifier is valid. */ 142 #define YY_USE_CONST 143 144 #else /* ! __cplusplus */ 145 146 /* C99 requires __STDC__ to be defined as 1. */ 147 #if defined (__STDC__) 148 149 #define YY_USE_CONST 150 151 #endif /* defined (__STDC__) */ 152 #endif /* ! __cplusplus */ 153 154 #ifdef YY_USE_CONST 155 #define yyconst const 156 #else 157 #define yyconst 158 #endif 159 160 /* %not-for-header */ 161 162 /* Returned upon end-of-file. */ 163 #define YY_NULL 0 164 /* %ok-for-header */ 165 166 /* %not-for-header */ 167 168 /* Promotes a possibly negative, possibly signed char to an unsigned 169 * integer for use as an array index. If the signed char is negative, 170 * we want to instead treat it as an 8-bit unsigned char, hence the 171 * double cast. 172 */ 173 #define YY_SC_TO_UI(c) ((unsigned int) (unsigned char) c) 174 /* %ok-for-header */ 175 176 /* %if-reentrant */ 177 /* %endif */ 178 179 /* %if-not-reentrant */ 180 181 /* %endif */ 182 183 /* Enter a start condition. This macro really ought to take a parameter, 184 * but we do it the disgusting crufty way forced on us by the ()-less 185 * definition of BEGIN. 186 */ 187 #define BEGIN (yy_start) = 1 + 2 * 188 189 /* Translate the current start state into a value that can be later handed 190 * to BEGIN to return to the state. The YYSTATE alias is for lex 191 * compatibility. 192 */ 193 #define YY_START (((yy_start) - 1) / 2) 194 #define YYSTATE YY_START 195 196 /* Action number for EOF rule of a given start state. */ 197 #define YY_STATE_EOF(state) (YY_END_OF_BUFFER + state + 1) 198 199 /* Special action meaning "start processing a new file". */ 200 #define YY_NEW_FILE code_restart(code_in ) 201 202 #define YY_END_OF_BUFFER_CHAR 0 203 204 /* Size of default input buffer. */ 205 #ifndef YY_BUF_SIZE 206 #define YY_BUF_SIZE 16384 207 #endif 208 209 /* The state buf must be large enough to hold one state per character in the main buffer. 210 */ 211 #define YY_STATE_BUF_SIZE ((YY_BUF_SIZE + 2) * sizeof(yy_state_type)) 212 213 #ifndef YY_TYPEDEF_YY_BUFFER_STATE 214 #define YY_TYPEDEF_YY_BUFFER_STATE 215 typedef struct yy_buffer_state *YY_BUFFER_STATE; 216 #endif 217 218 #ifndef YY_TYPEDEF_YY_SIZE_T 219 #define YY_TYPEDEF_YY_SIZE_T 220 typedef size_t yy_size_t; 221 #endif 222 223 /* %if-not-reentrant */ 224 extern yy_size_t code_leng; 225 /* %endif */ 226 227 /* %if-c-only */ 228 /* %if-not-reentrant */ 229 extern FILE *code_in, *code_out; 230 /* %endif */ 231 /* %endif */ 232 233 #define EOB_ACT_CONTINUE_SCAN 0 234 #define EOB_ACT_END_OF_FILE 1 235 #define EOB_ACT_LAST_MATCH 2 236 237 #define YY_LESS_LINENO(n) 238 239 /* Return all but the first "n" matched characters back to the input stream. */ 240 #define yyless(n) \ 241 do \ 242 { \ 243 /* Undo effects of setting up code_text. */ \ 244 int yyless_macro_arg = (n); \ 245 YY_LESS_LINENO(yyless_macro_arg);\ 246 *yy_cp = (yy_hold_char); \ 247 YY_RESTORE_YY_MORE_OFFSET \ 248 (yy_c_buf_p) = yy_cp = yy_bp + yyless_macro_arg - YY_MORE_ADJ; \ 249 YY_DO_BEFORE_ACTION; /* set up code_text again */ \ 250 } \ 251 while ( 0 ) 252 253 #define unput(c) yyunput( c, (yytext_ptr) ) 254 255 #ifndef YY_STRUCT_YY_BUFFER_STATE 256 #define YY_STRUCT_YY_BUFFER_STATE 257 struct yy_buffer_state 258 { 259 /* %if-c-only */ 260 FILE *yy_input_file; 261 /* %endif */ 262 263 /* %if-c++-only */ 264 /* %endif */ 265 266 char *yy_ch_buf; /* input buffer */ 267 char *yy_buf_pos; /* current position in input buffer */ 268 269 /* Size of input buffer in bytes, not including room for EOB 270 * characters. 271 */ 272 yy_size_t yy_buf_size; 273 274 /* Number of characters read into yy_ch_buf, not including EOB 275 * characters. 276 */ 277 yy_size_t yy_n_chars; 278 279 /* Whether we "own" the buffer - i.e., we know we created it, 280 * and can realloc() it to grow it, and should free() it to 281 * delete it. 282 */ 283 int yy_is_our_buffer; 284 285 /* Whether this is an "interactive" input source; if so, and 286 * if we're using stdio for input, then we want to use getc() 287 * instead of fread(), to make sure we stop fetching input after 288 * each newline. 289 */ 290 int yy_is_interactive; 291 292 /* Whether we're considered to be at the beginning of a line. 293 * If so, '^' rules will be active on the next match, otherwise 294 * not. 295 */ 296 int yy_at_bol; 297 298 int yy_bs_lineno; /**< The line count. */ 299 int yy_bs_column; /**< The column count. */ 300 301 /* Whether to try to fill the input buffer when we reach the 302 * end of it. 303 */ 304 int yy_fill_buffer; 305 306 int yy_buffer_status; 307 308 #define YY_BUFFER_NEW 0 309 #define YY_BUFFER_NORMAL 1 310 /* When an EOF's been seen but there's still some text to process 311 * then we mark the buffer as YY_EOF_PENDING, to indicate that we 312 * shouldn't try reading from the input source any more. We might 313 * still have a bunch of tokens to match, though, because of 314 * possible backing-up. 315 * 316 * When we actually see the EOF, we change the status to "new" 317 * (via code_restart()), so that the user can continue scanning by 318 * just pointing code_in at a new input file. 319 */ 320 #define YY_BUFFER_EOF_PENDING 2 321 322 }; 323 #endif /* !YY_STRUCT_YY_BUFFER_STATE */ 324 325 /* %if-c-only Standard (non-C++) definition */ 326 /* %not-for-header */ 327 328 /* %if-not-reentrant */ 329 330 /* Stack of input buffers. */ 331 static size_t yy_buffer_stack_top = 0; /**< index of top of stack. */ 332 static size_t yy_buffer_stack_max = 0; /**< capacity of stack. */ 333 static YY_BUFFER_STATE * yy_buffer_stack = 0; /**< Stack as an array. */ 334 /* %endif */ 335 /* %ok-for-header */ 336 337 /* %endif */ 338 339 /* We provide macros for accessing buffer states in case in the 340 * future we want to put the buffer states in a more general 341 * "scanner state". 342 * 343 * Returns the top of the stack, or NULL. 344 */ 345 #define YY_CURRENT_BUFFER ( (yy_buffer_stack) \ 346 ? (yy_buffer_stack)[(yy_buffer_stack_top)] \ 347 : NULL) 348 349 /* Same as previous macro, but useful when we know that the buffer stack is not 350 * NULL or when we need an lvalue. For internal use only. 351 */ 352 #define YY_CURRENT_BUFFER_LVALUE (yy_buffer_stack)[(yy_buffer_stack_top)] 353 354 /* %if-c-only Standard (non-C++) definition */ 355 356 /* %if-not-reentrant */ 357 /* %not-for-header */ 358 359 /* yy_hold_char holds the character lost when code_text is formed. */ 360 static char yy_hold_char; 361 static yy_size_t yy_n_chars; /* number of characters read into yy_ch_buf */ 362 yy_size_t code_leng; 363 364 /* Points to current character in buffer. */ 365 static char *yy_c_buf_p = (char *) 0; 366 static int yy_init = 0; /* whether we need to initialize */ 367 static int yy_start = 0; /* start state number */ 368 369 /* Flag which is used to allow code_wrap()'s to do buffer switches 370 * instead of setting up a fresh code_in. A bit of a hack ... 371 */ 372 static int yy_did_buffer_switch_on_eof; 373 /* %ok-for-header */ 374 375 /* %endif */ 376 377 void code_restart (FILE *input_file ); 378 void code__switch_to_buffer (YY_BUFFER_STATE new_buffer ); 379 YY_BUFFER_STATE code__create_buffer (FILE *file,int size ); 380 void code__delete_buffer (YY_BUFFER_STATE b ); 381 void code__flush_buffer (YY_BUFFER_STATE b ); 382 void code_push_buffer_state (YY_BUFFER_STATE new_buffer ); 383 void code_pop_buffer_state (void ); 384 385 static void code_ensure_buffer_stack (void ); 386 static void code__load_buffer_state (void ); 387 static void code__init_buffer (YY_BUFFER_STATE b,FILE *file ); 388 389 #define YY_FLUSH_BUFFER code__flush_buffer(YY_CURRENT_BUFFER ) 390 391 YY_BUFFER_STATE code__scan_buffer (char *base,yy_size_t size ); 392 YY_BUFFER_STATE code__scan_string (yyconst char *yy_str ); 393 YY_BUFFER_STATE code__scan_bytes (yyconst char *bytes,yy_size_t len ); 394 395 /* %endif */ 396 397 void *code_alloc (yy_size_t ); 398 void *code_realloc (void *,yy_size_t ); 399 void code_free (void * ); 400 401 #define yy_new_buffer code__create_buffer 402 403 #define yy_set_interactive(is_interactive) \ 404 { \ 405 if ( ! YY_CURRENT_BUFFER ){ \ 406 code_ensure_buffer_stack (); \ 407 YY_CURRENT_BUFFER_LVALUE = \ 408 code__create_buffer(code_in,YY_BUF_SIZE ); \ 409 } \ 410 YY_CURRENT_BUFFER_LVALUE->yy_is_interactive = is_interactive; \ 411 } 412 413 #define yy_set_bol(at_bol) \ 414 { \ 415 if ( ! YY_CURRENT_BUFFER ){\ 416 code_ensure_buffer_stack (); \ 417 YY_CURRENT_BUFFER_LVALUE = \ 418 code__create_buffer(code_in,YY_BUF_SIZE ); \ 419 } \ 420 YY_CURRENT_BUFFER_LVALUE->yy_at_bol = at_bol; \ 421 } 422 423 #define YY_AT_BOL() (YY_CURRENT_BUFFER_LVALUE->yy_at_bol) 424 425 /* %% [1.0] code_text/code_in/code_out/yy_state_type/code_lineno etc. def's & init go here */ 426 /* Begin user sect3 */ 427 428 #define code_wrap() 1 429 #define YY_SKIP_YYWRAP 430 431 #define FLEX_DEBUG 432 433 typedef unsigned char YY_CHAR; 434 435 FILE *code_in = (FILE *) 0, *code_out = (FILE *) 0; 436 437 typedef int yy_state_type; 438 439 extern int code_lineno; 440 441 int code_lineno = 1; 442 443 extern char *code_text; 444 #define yytext_ptr code_text 445 446 /* %if-c-only Standard (non-C++) definition */ 447 448 static yy_state_type yy_get_previous_state (void ); 449 static yy_state_type yy_try_NUL_trans (yy_state_type current_state ); 450 static int yy_get_next_buffer (void ); 451 static void yy_fatal_error (yyconst char msg[] ); 452 453 /* %endif */ 454 455 /* Done after the current pattern has been matched and before the 456 * corresponding action - sets up code_text. 457 */ 458 #define YY_DO_BEFORE_ACTION \ 459 (yytext_ptr) = yy_bp; \ 460 /* %% [2.0] code to fiddle code_text and code_leng for yymore() goes here \ */\ 461 code_leng = (size_t) (yy_cp - yy_bp); \ 462 (yy_hold_char) = *yy_cp; \ 463 *yy_cp = '\0'; \ 464 /* %% [3.0] code to copy yytext_ptr to code_text[] goes here, if %array \ */\ 465 (yy_c_buf_p) = yy_cp; 466 467 /* %% [4.0] data tables for the DFA and the user's section 1 definitions go here */ 468 #define YY_NUM_RULES 29 469 #define YY_END_OF_BUFFER 30 470 /* This struct is not used in this scanner, 471 but its presence is necessary. */ 472 struct yy_trans_info 473 { 474 flex_int32_t yy_verify; 475 flex_int32_t yy_nxt; 476 }; 477 static yyconst flex_int16_t yy_accept[101] = 478 { 0, 479 0, 0, 0, 0, 3, 3, 4, 4, 4, 4, 480 19, 19, 0, 0, 30, 28, 27, 28, 2, 28, 481 6, 28, 5, 24, 21, 20, 20, 8, 18, 11, 482 7, 24, 15, 11, 23, 23, 12, 24, 16, 17, 483 8, 11, 7, 28, 11, 12, 1, 0, 0, 3, 484 4, 4, 4, 4, 13, 0, 13, 13, 0, 0, 485 9, 10, 0, 14, 0, 14, 14, 0, 23, 23, 486 0, 19, 25, 0, 26, 0, 0, 0, 0, 0, 487 0, 0, 13, 0, 0, 0, 0, 14, 0, 23, 488 0, 0, 0, 0, 0, 23, 0, 23, 22, 0 489 490 } ; 491 492 static yyconst flex_int32_t yy_ec[256] = 493 { 0, 494 1, 1, 1, 1, 1, 1, 1, 1, 2, 3, 495 4, 2, 5, 1, 1, 1, 1, 1, 1, 1, 496 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 497 1, 2, 1, 6, 7, 8, 1, 1, 9, 1, 498 1, 10, 1, 1, 11, 12, 13, 14, 14, 14, 499 14, 14, 14, 14, 14, 14, 14, 1, 15, 16, 500 1, 17, 1, 18, 19, 20, 20, 20, 20, 21, 501 20, 20, 22, 20, 20, 23, 20, 20, 20, 20, 502 20, 20, 20, 20, 20, 20, 20, 20, 24, 20, 503 25, 26, 27, 1, 20, 1, 20, 20, 20, 20, 504 505 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 506 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 507 20, 20, 28, 1, 29, 1, 1, 1, 1, 1, 508 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 509 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 510 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 511 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 512 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 513 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 514 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 515 516 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 517 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 518 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 519 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 520 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 521 1, 1, 1, 1, 1 522 } ; 523 524 static yyconst flex_int32_t yy_meta[31] = 525 { 0, 526 1, 1, 2, 1, 1, 1, 1, 3, 1, 1, 527 4, 5, 1, 6, 1, 1, 2, 1, 7, 7, 528 7, 7, 7, 7, 3, 1, 8, 1, 1, 2 529 } ; 530 531 static yyconst flex_int16_t yy_base[113] = 532 { 0, 533 0, 1, 21, 41, 66, 0, 4, 8, 12, 14, 534 93, 0, 118, 0, 242, 243, 243, 7, 243, 0, 535 243, 39, 243, 243, 243, 243, 243, 243, 243, 138, 536 243, 34, 243, 42, 0, 217, 243, 33, 243, 243, 537 243, 8, 243, 44, 232, 243, 243, 59, 69, 213, 538 243, 73, 212, 76, 243, 223, 0, 222, 0, 0, 539 243, 243, 79, 243, 205, 0, 202, 0, 0, 188, 540 83, 175, 243, 0, 243, 86, 19, 126, 130, 135, 541 138, 122, 0, 151, 140, 162, 143, 0, 128, 132, 542 168, 130, 128, 108, 37, 36, 47, 29, 0, 243, 543 544 172, 180, 186, 188, 192, 199, 203, 207, 210, 217, 545 222, 227 546 } ; 547 548 static yyconst flex_int16_t yy_def[113] = 549 { 0, 550 101, 101, 101, 101, 101, 5, 5, 5, 5, 5, 551 100, 11, 101, 13, 100, 100, 100, 100, 100, 100, 552 100, 102, 100, 100, 100, 100, 100, 100, 100, 100, 553 100, 100, 100, 103, 104, 104, 100, 100, 100, 100, 554 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 555 100, 100, 100, 100, 100, 100, 105, 100, 106, 107, 556 100, 100, 100, 100, 100, 108, 100, 109, 104, 104, 557 100, 100, 100, 110, 100, 100, 100, 100, 100, 100, 558 100, 102, 105, 106, 111, 100, 100, 108, 112, 104, 559 100, 110, 30, 111, 112, 104, 100, 104, 104, 0, 560 561 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 562 100, 100 563 } ; 564 565 static yyconst flex_int16_t yy_nxt[274] = 566 { 0, 567 100, 49, 50, 49, 100, 100, 16, 17, 17, 21, 568 16, 100, 100, 21, 16, 73, 16, 17, 17, 47, 569 23, 100, 23, 74, 17, 17, 17, 17, 17, 22, 570 18, 47, 48, 22, 71, 72, 71, 22, 17, 22, 571 52, 53, 52, 61, 48, 17, 62, 17, 17, 64, 572 18, 99, 65, 61, 73, 67, 62, 98, 17, 63, 573 76, 77, 76, 64, 54, 17, 68, 17, 19, 63, 574 49, 50, 49, 17, 79, 53, 79, 81, 82, 81, 575 86, 87, 86, 17, 71, 72, 71, 76, 77, 76, 576 17, 20, 17, 24, 25, 26, 24, 27, 28, 29, 577 578 30, 31, 24, 24, 24, 32, 24, 33, 24, 24, 579 34, 35, 35, 35, 35, 35, 36, 37, 38, 37, 580 39, 40, 24, 41, 100, 42, 43, 49, 50, 49, 581 44, 79, 53, 79, 55, 45, 79, 53, 79, 81, 582 82, 81, 46, 100, 46, 55, 97, 54, 56, 57, 583 96, 58, 61, 59, 64, 62, 57, 57, 57, 57, 584 57, 57, 60, 86, 87, 86, 55, 93, 63, 71, 585 72, 71, 16, 16, 16, 16, 16, 16, 16, 16, 586 51, 51, 51, 51, 51, 51, 51, 51, 66, 66, 587 66, 66, 66, 69, 69, 83, 83, 83, 83, 84, 588 589 91, 84, 84, 84, 84, 84, 84, 85, 90, 85, 590 88, 88, 88, 88, 89, 67, 89, 92, 67, 92, 591 92, 92, 92, 92, 92, 94, 94, 94, 94, 94, 592 95, 95, 95, 95, 95, 58, 58, 80, 78, 75, 593 70, 100, 15, 100, 100, 100, 100, 100, 100, 100, 594 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 595 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 596 100, 100, 100 597 } ; 598 599 static yyconst flex_int16_t yy_chk[274] = 600 { 0, 601 0, 20, 20, 20, 0, 0, 7, 1, 2, 7, 602 8, 0, 0, 8, 9, 42, 10, 1, 2, 18, 603 9, 0, 10, 42, 1, 2, 1, 2, 3, 7, 604 3, 77, 18, 8, 38, 38, 38, 9, 3, 10, 605 22, 22, 22, 32, 77, 3, 32, 3, 4, 34, 606 4, 98, 34, 44, 97, 34, 44, 96, 4, 32, 607 48, 48, 48, 95, 22, 4, 34, 4, 5, 44, 608 49, 49, 49, 5, 52, 52, 52, 54, 54, 54, 609 63, 63, 63, 5, 71, 71, 71, 76, 76, 76, 610 5, 5, 5, 11, 11, 11, 11, 11, 11, 11, 611 612 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 613 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 614 11, 11, 11, 13, 82, 13, 13, 78, 78, 78, 615 13, 79, 79, 79, 94, 13, 80, 80, 80, 81, 616 81, 81, 13, 93, 13, 30, 92, 82, 30, 30, 617 90, 30, 87, 30, 89, 87, 30, 30, 30, 30, 618 30, 30, 30, 86, 86, 86, 85, 84, 87, 91, 619 91, 91, 101, 101, 101, 101, 101, 101, 101, 101, 620 102, 102, 102, 102, 102, 102, 102, 102, 103, 103, 621 103, 103, 103, 104, 104, 105, 105, 105, 105, 106, 622 623 72, 106, 106, 106, 106, 106, 106, 107, 70, 107, 624 108, 108, 108, 108, 109, 67, 109, 110, 65, 110, 625 110, 110, 110, 110, 110, 111, 111, 111, 111, 111, 626 112, 112, 112, 112, 112, 58, 56, 53, 50, 45, 627 36, 15, 100, 100, 100, 100, 100, 100, 100, 100, 628 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 629 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 630 100, 100, 100 631 } ; 632 633 static yy_state_type yy_last_accepting_state; 634 static char *yy_last_accepting_cpos; 635 636 extern int code__flex_debug; 637 int code__flex_debug = 1; 638 639 static yyconst flex_int16_t yy_rule_linenum[29] = 640 { 0, 641 132, 142, 143, 153, 158, 163, 169, 174, 179, 183, 642 187, 192, 200, 207, 215, 216, 217, 244, 246, 247, 643 248, 252, 260, 262, 267, 275, 285, 288 644 } ; 645 646 /* The intent behind this definition is that it'll catch 647 * any uses of REJECT which flex missed. 648 */ 649 #define REJECT reject_used_but_not_detected 650 #define yymore() yymore_used_but_not_detected 651 #define YY_MORE_ADJ 0 652 #define YY_RESTORE_YY_MORE_OFFSET 653 char *code_text; 654 #line 1 "scan-code.l" 655 /* Bison Action Scanner -*- C -*- 656 657 Copyright (C) 2006-2012 Free Software Foundation, Inc. 658 659 This file is part of Bison, the GNU Compiler Compiler. 660 661 This program is free software: you can redistribute it and/or modify 662 it under the terms of the GNU General Public License as published by 663 the Free Software Foundation, either version 3 of the License, or 664 (at your option) any later version. 665 666 This program is distributed in the hope that it will be useful, 667 but WITHOUT ANY WARRANTY; without even the implied warranty of 668 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 669 GNU General Public License for more details. 670 671 You should have received a copy of the GNU General Public License 672 along with this program. If not, see <http://www.gnu.org/licenses/>. */ 673 #define YY_NO_INPUT 1 674 #line 24 "scan-code.l" 675 /* Work around a bug in flex 2.5.31. See Debian bug 333231 676 <http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=333231>. */ 677 #undef code_wrap 678 #define code_wrap() 1 679 680 #define FLEX_PREFIX(Id) code_ ## Id 681 #include "flex-scanner.h" 682 683 #include "complain.h" 684 #include "reader.h" 685 #include "getargs.h" 686 #include "scan-code.h" 687 #include "symlist.h" 688 689 #include <c-ctype.h> 690 #include <get-errno.h> 691 #include <quote.h> 692 693 /* The current calling start condition: SC_RULE_ACTION or 694 SC_SYMBOL_ACTION. */ 695 # define YY_DECL static char *code_lex (code_props *self, int sc_context) 696 YY_DECL; 697 698 #define YY_USER_ACTION location_compute (loc, &loc->end, code_text, code_leng); 699 700 static char *fetch_type_name (char *cp, char const **type_name, 701 location dollar_loc); 702 703 static void handle_action_dollar (symbol_list *rule, char *cp, 704 location dollar_loc); 705 static void handle_action_at (symbol_list *rule, char *cp, location at_loc); 706 707 /* A string to be pushed to obstack after dollar/at has been handled. */ 708 static char *ref_tail_fields; 709 710 static location the_location; 711 static location *loc = &the_location; 712 713 /* A string representing the most recent translation. */ 714 static char *last_string; 715 716 /* True if an untyped $$ or $n was seen. */ 717 static bool untyped_var_seen; 718 719 /* C and C++ comments in code. */ 720 721 /* Strings and characters in code. */ 722 723 /* Whether in a rule or symbol action. Specifies the translation 724 of $ and @. */ 725 726 /* POSIX says that a tag must be both an id and a C union member, but 727 historically almost any character is allowed in a tag. We disallow 728 NUL and newline, as this simplifies our implementation. */ 729 /* Zero or more instances of backslash-newline. Following GCC, allow 730 white space between the backslash and the newline. */ 731 /* C style identifier. Must start with letter. Will be used for 732 named symbol references. Shall be kept synchronized with 733 scan-gram.l "letter" and "id". */ 734 #line 735 "scan-code.c" 735 736 #define INITIAL 0 737 #define SC_COMMENT 1 738 #define SC_LINE_COMMENT 2 739 #define SC_STRING 3 740 #define SC_CHARACTER 4 741 #define SC_RULE_ACTION 5 742 #define SC_SYMBOL_ACTION 6 743 744 #ifndef YY_NO_UNISTD_H 745 /* Special case for "unistd.h", since it is non-ANSI. We include it way 746 * down here because we want the user's section 1 to have been scanned first. 747 * The user has a chance to override it with an option. 748 */ 749 /* %if-c-only */ 750 #include <unistd.h> 751 /* %endif */ 752 /* %if-c++-only */ 753 /* %endif */ 754 #endif 755 756 #ifndef YY_EXTRA_TYPE 757 #define YY_EXTRA_TYPE void * 758 #endif 759 760 /* %if-c-only Reentrant structure and macros (non-C++). */ 761 /* %if-reentrant */ 762 /* %if-c-only */ 763 764 static int yy_init_globals (void ); 765 766 /* %endif */ 767 /* %if-reentrant */ 768 /* %endif */ 769 /* %endif End reentrant structures and macros. */ 770 771 /* Accessor methods to globals. 772 These are made visible to non-reentrant scanners for convenience. */ 773 774 int code_lex_destroy (void ); 775 776 int code_get_debug (void ); 777 778 void code_set_debug (int debug_flag ); 779 780 YY_EXTRA_TYPE code_get_extra (void ); 781 782 void code_set_extra (YY_EXTRA_TYPE user_defined ); 783 784 FILE *code_get_in (void ); 785 786 void code_set_in (FILE * in_str ); 787 788 FILE *code_get_out (void ); 789 790 void code_set_out (FILE * out_str ); 791 792 yy_size_t code_get_leng (void ); 793 794 char *code_get_text (void ); 795 796 int code_get_lineno (void ); 797 798 void code_set_lineno (int line_number ); 799 800 /* %if-bison-bridge */ 801 /* %endif */ 802 803 /* Macros after this point can all be overridden by user definitions in 804 * section 1. 805 */ 806 807 #ifndef YY_SKIP_YYWRAP 808 #ifdef __cplusplus 809 extern "C" int code_wrap (void ); 810 #else 811 extern int code_wrap (void ); 812 #endif 813 #endif 814 815 /* %not-for-header */ 816 817 /* %ok-for-header */ 818 819 /* %endif */ 820 821 #ifndef yytext_ptr 822 static void yy_flex_strncpy (char *,yyconst char *,int ); 823 #endif 824 825 #ifdef YY_NEED_STRLEN 826 static int yy_flex_strlen (yyconst char * ); 827 #endif 828 829 #ifndef YY_NO_INPUT 830 /* %if-c-only Standard (non-C++) definition */ 831 /* %not-for-header */ 832 833 #ifdef __cplusplus 834 static int yyinput (void ); 835 #else 836 static int input (void ); 837 #endif 838 /* %ok-for-header */ 839 840 /* %endif */ 841 #endif 842 843 /* %if-c-only */ 844 845 /* %endif */ 846 847 /* Amount of stuff to slurp up with each read. */ 848 #ifndef YY_READ_BUF_SIZE 849 #define YY_READ_BUF_SIZE 8192 850 #endif 851 852 /* Copy whatever the last rule matched to the standard output. */ 853 #ifndef ECHO 854 /* %if-c-only Standard (non-C++) definition */ 855 /* This used to be an fputs(), but since the string might contain NUL's, 856 * we now use fwrite(). 857 */ 858 #define ECHO do { if (fwrite( code_text, code_leng, 1, code_out )) {} } while (0) 859 /* %endif */ 860 /* %if-c++-only C++ definition */ 861 /* %endif */ 862 #endif 863 864 /* Gets input and stuffs it into "buf". number of characters read, or YY_NULL, 865 * is returned in "result". 866 */ 867 #ifndef YY_INPUT 868 #define YY_INPUT(buf,result,max_size) \ 869 /* %% [5.0] fread()/read() definition of YY_INPUT goes here unless we're doing C++ \ */\ 870 if ( YY_CURRENT_BUFFER_LVALUE->yy_is_interactive ) \ 871 { \ 872 int c = '*'; \ 873 size_t n; \ 874 for ( n = 0; n < max_size && \ 875 (c = getc( code_in )) != EOF && c != '\n'; ++n ) \ 876 buf[n] = (char) c; \ 877 if ( c == '\n' ) \ 878 buf[n++] = (char) c; \ 879 if ( c == EOF && ferror( code_in ) ) \ 880 YY_FATAL_ERROR( "input in flex scanner failed" ); \ 881 result = n; \ 882 } \ 883 else \ 884 { \ 885 errno=0; \ 886 while ( (result = fread(buf, 1, max_size, code_in))==0 && ferror(code_in)) \ 887 { \ 888 if( errno != EINTR) \ 889 { \ 890 YY_FATAL_ERROR( "input in flex scanner failed" ); \ 891 break; \ 892 } \ 893 errno=0; \ 894 clearerr(code_in); \ 895 } \ 896 }\ 897 \ 898 /* %if-c++-only C++ definition \ */\ 899 /* %endif */ 900 901 #endif 902 903 /* No semi-colon after return; correct usage is to write "yyterminate();" - 904 * we don't want an extra ';' after the "return" because that will cause 905 * some compilers to complain about unreachable statements. 906 */ 907 #ifndef yyterminate 908 #define yyterminate() return YY_NULL 909 #endif 910 911 /* Number of entries by which start-condition stack grows. */ 912 #ifndef YY_START_STACK_INCR 913 #define YY_START_STACK_INCR 25 914 #endif 915 916 /* Report a fatal error. */ 917 #ifndef YY_FATAL_ERROR 918 /* %if-c-only */ 919 #define YY_FATAL_ERROR(msg) yy_fatal_error( msg ) 920 /* %endif */ 921 /* %if-c++-only */ 922 /* %endif */ 923 #endif 924 925 /* %if-tables-serialization structures and prototypes */ 926 /* %not-for-header */ 927 928 /* %ok-for-header */ 929 930 /* %not-for-header */ 931 932 /* %tables-yydmap generated elements */ 933 /* %endif */ 934 /* end tables serialization structures and prototypes */ 935 936 /* %ok-for-header */ 937 938 /* Default declaration of generated scanner - a define so the user can 939 * easily add parameters. 940 */ 941 #ifndef YY_DECL 942 #define YY_DECL_IS_OURS 1 943 /* %if-c-only Standard (non-C++) definition */ 944 945 extern int code_lex (void); 946 947 #define YY_DECL int code_lex (void) 948 /* %endif */ 949 /* %if-c++-only C++ definition */ 950 /* %endif */ 951 #endif /* !YY_DECL */ 952 953 /* Code executed at the beginning of each rule, after code_text and code_leng 954 * have been set up. 955 */ 956 #ifndef YY_USER_ACTION 957 #define YY_USER_ACTION 958 #endif 959 960 /* Code executed at the end of each rule. */ 961 #ifndef YY_BREAK 962 #define YY_BREAK break; 963 #endif 964 965 /* %% [6.0] YY_RULE_SETUP definition goes here */ 966 #define YY_RULE_SETUP \ 967 YY_USER_ACTION 968 969 /* %not-for-header */ 970 971 /** The main scanner function which does all the work. 972 */ 973 YY_DECL 974 { 975 register yy_state_type yy_current_state; 976 register char *yy_cp, *yy_bp; 977 register int yy_act; 978 979 /* %% [7.0] user's declarations go here */ 980 #line 94 "scan-code.l" 981 982 983 984 /* Nesting level of the current code in braces. */ 985 int braces_level = 0; 986 987 /* Whether a semicolon is probably needed. 988 989 The heuristic is that a semicolon is not needed after '{', '}', 990 ';', or a C preprocessor directive, and that whitespaces and 991 comments do not affect this flag. Note that '{' does not need a 992 semicolon because of '{}'. A semicolon may be needed before a 993 cpp directive, but don't bother. 994 995 While it is maintained in several start-conditions (factoring 996 opportunities), it is meaningful only for SC_RULE_ACTION. */ 997 bool need_semicolon = false; 998 999 /* Whether in a C preprocessor directive. Don't use a start condition 1000 for this because, at the end of strings and comments, we still need 1001 to know whether we're in a directive. */ 1002 bool in_cpp = false; 1003 1004 /* This scanner is special: it is invoked only once, henceforth 1005 is expected to return only once. This initialization is 1006 therefore done once per action to translate. */ 1007 aver (sc_context == SC_SYMBOL_ACTION 1008 || sc_context == SC_RULE_ACTION 1009 || sc_context == INITIAL); 1010 BEGIN sc_context; 1011 1012 1013 /*------------------------------------------------------------. 1014 | Scanning a C comment. The initial '/ *' is already eaten. | 1015 `------------------------------------------------------------*/ 1016 1017 #line 1018 "scan-code.c" 1018 1019 if ( !(yy_init) ) 1020 { 1021 (yy_init) = 1; 1022 1023 #ifdef YY_USER_INIT 1024 YY_USER_INIT; 1025 #endif 1026 1027 if ( ! (yy_start) ) 1028 (yy_start) = 1; /* first start state */ 1029 1030 if ( ! code_in ) 1031 /* %if-c-only */ 1032 code_in = stdin; 1033 /* %endif */ 1034 /* %if-c++-only */ 1035 /* %endif */ 1036 1037 if ( ! code_out ) 1038 /* %if-c-only */ 1039 code_out = stdout; 1040 /* %endif */ 1041 /* %if-c++-only */ 1042 /* %endif */ 1043 1044 if ( ! YY_CURRENT_BUFFER ) { 1045 code_ensure_buffer_stack (); 1046 YY_CURRENT_BUFFER_LVALUE = 1047 code__create_buffer(code_in,YY_BUF_SIZE ); 1048 } 1049 1050 code__load_buffer_state( ); 1051 } 1052 1053 while ( 1 ) /* loops until end-of-file is reached */ 1054 { 1055 /* %% [8.0] yymore()-related code goes here */ 1056 yy_cp = (yy_c_buf_p); 1057 1058 /* Support of code_text. */ 1059 *yy_cp = (yy_hold_char); 1060 1061 /* yy_bp points to the position in yy_ch_buf of the start of 1062 * the current run. 1063 */ 1064 yy_bp = yy_cp; 1065 1066 /* %% [9.0] code to set up and find next match goes here */ 1067 yy_current_state = (yy_start); 1068 yy_match: 1069 do 1070 { 1071 register YY_CHAR yy_c = yy_ec[YY_SC_TO_UI(*yy_cp)]; 1072 if ( yy_accept[yy_current_state] ) 1073 { 1074 (yy_last_accepting_state) = yy_current_state; 1075 (yy_last_accepting_cpos) = yy_cp; 1076 } 1077 while ( yy_chk[yy_base[yy_current_state] + yy_c] != yy_current_state ) 1078 { 1079 yy_current_state = (int) yy_def[yy_current_state]; 1080 if ( yy_current_state >= 101 ) 1081 yy_c = yy_meta[(unsigned int) yy_c]; 1082 } 1083 yy_current_state = yy_nxt[yy_base[yy_current_state] + (unsigned int) yy_c]; 1084 ++yy_cp; 1085 } 1086 while ( yy_current_state != 100 ); 1087 yy_cp = (yy_last_accepting_cpos); 1088 yy_current_state = (yy_last_accepting_state); 1089 1090 yy_find_action: 1091 /* %% [10.0] code to find the action number goes here */ 1092 yy_act = yy_accept[yy_current_state]; 1093 1094 YY_DO_BEFORE_ACTION; 1095 1096 /* %% [11.0] code for code_lineno update goes here */ 1097 1098 do_action: /* This label is used only to access EOF actions. */ 1099 1100 /* %% [12.0] debug code goes here */ 1101 if ( code__flex_debug ) 1102 { 1103 if ( yy_act == 0 ) 1104 fprintf( stderr, "--scanner backing up\n" ); 1105 else if ( yy_act < 29 ) 1106 fprintf( stderr, "--accepting rule at line %ld (\"%s\")\n", 1107 (long)yy_rule_linenum[yy_act], code_text ); 1108 else if ( yy_act == 29 ) 1109 fprintf( stderr, "--accepting default rule (\"%s\")\n", 1110 code_text ); 1111 else if ( yy_act == 30 ) 1112 fprintf( stderr, "--(end of buffer or a NUL)\n" ); 1113 else 1114 fprintf( stderr, "--EOF (start condition %d)\n", YY_START ); 1115 } 1116 1117 switch ( yy_act ) 1118 { /* beginning of action switch */ 1119 /* %% [13.0] actions go here */ 1120 case 0: /* must back up */ 1121 /* undo the effects of YY_DO_BEFORE_ACTION */ 1122 *yy_cp = (yy_hold_char); 1123 yy_cp = (yy_last_accepting_cpos); 1124 yy_current_state = (yy_last_accepting_state); 1125 goto yy_find_action; 1126 1127 case 1: 1128 /* rule 1 can match eol */ 1129 YY_RULE_SETUP 1130 #line 132 "scan-code.l" 1131 STRING_GROW; BEGIN sc_context; 1132 YY_BREAK 1133 1134 /*--------------------------------------------------------------. 1135 | Scanning a line comment. The initial '//' is already eaten. | 1136 `--------------------------------------------------------------*/ 1137 1138 1139 case 2: 1140 /* rule 2 can match eol */ 1141 YY_RULE_SETUP 1142 #line 142 "scan-code.l" 1143 STRING_GROW; BEGIN sc_context; 1144 YY_BREAK 1145 case 3: 1146 /* rule 3 can match eol */ 1147 YY_RULE_SETUP 1148 #line 143 "scan-code.l" 1149 STRING_GROW; 1150 YY_BREAK 1151 1152 /*--------------------------------------------. 1153 | Scanning user-code characters and strings. | 1154 `--------------------------------------------*/ 1155 1156 1157 case 4: 1158 /* rule 4 can match eol */ 1159 YY_RULE_SETUP 1160 #line 153 "scan-code.l" 1161 STRING_GROW; 1162 YY_BREAK 1163 1164 1165 1166 case 5: 1167 YY_RULE_SETUP 1168 #line 158 "scan-code.l" 1169 STRING_GROW; BEGIN sc_context; 1170 YY_BREAK 1171 1172 1173 1174 case 6: 1175 YY_RULE_SETUP 1176 #line 163 "scan-code.l" 1177 STRING_GROW; BEGIN sc_context; 1178 YY_BREAK 1179 1180 1181 1182 case 7: 1183 YY_RULE_SETUP 1184 #line 169 "scan-code.l" 1185 { 1186 STRING_GROW; 1187 BEGIN SC_CHARACTER; 1188 need_semicolon = true; 1189 } 1190 YY_BREAK 1191 case 8: 1192 YY_RULE_SETUP 1193 #line 174 "scan-code.l" 1194 { 1195 STRING_GROW; 1196 BEGIN SC_STRING; 1197 need_semicolon = true; 1198 } 1199 YY_BREAK 1200 case 9: 1201 /* rule 9 can match eol */ 1202 YY_RULE_SETUP 1203 #line 179 "scan-code.l" 1204 { 1205 STRING_GROW; 1206 BEGIN SC_COMMENT; 1207 } 1208 YY_BREAK 1209 case 10: 1210 /* rule 10 can match eol */ 1211 YY_RULE_SETUP 1212 #line 183 "scan-code.l" 1213 { 1214 STRING_GROW; 1215 BEGIN SC_LINE_COMMENT; 1216 } 1217 YY_BREAK 1218 case 11: 1219 YY_RULE_SETUP 1220 #line 187 "scan-code.l" 1221 { 1222 warn_at (*loc, _("stray '%s'"), code_text); 1223 obstack_escape (&obstack_for_string, code_text); 1224 need_semicolon = true; 1225 } 1226 YY_BREAK 1227 case 12: 1228 YY_RULE_SETUP 1229 #line 192 "scan-code.l" 1230 { 1231 obstack_escape (&obstack_for_string, code_text); 1232 need_semicolon = true; 1233 } 1234 YY_BREAK 1235 1236 1237 1238 case 13: 1239 YY_RULE_SETUP 1240 #line 200 "scan-code.l" 1241 { 1242 ref_tail_fields = NULL; 1243 handle_action_dollar (self->rule, code_text, *loc); 1244 if (ref_tail_fields) 1245 obstack_sgrow (&obstack_for_string, ref_tail_fields); 1246 need_semicolon = true; 1247 } 1248 YY_BREAK 1249 case 14: 1250 YY_RULE_SETUP 1251 #line 207 "scan-code.l" 1252 { 1253 ref_tail_fields = NULL; 1254 handle_action_at (self->rule, code_text, *loc); 1255 if (ref_tail_fields) 1256 obstack_sgrow (&obstack_for_string, ref_tail_fields); 1257 need_semicolon = true; 1258 } 1259 YY_BREAK 1260 case 15: 1261 YY_RULE_SETUP 1262 #line 215 "scan-code.l" 1263 STRING_GROW; need_semicolon = false; 1264 YY_BREAK 1265 case 16: 1266 YY_RULE_SETUP 1267 #line 216 "scan-code.l" 1268 STRING_GROW; ++braces_level; need_semicolon = false; 1269 YY_BREAK 1270 case 17: 1271 YY_RULE_SETUP 1272 #line 217 "scan-code.l" 1273 { 1274 bool outer_brace = --braces_level == 0; 1275 1276 /* As an undocumented Bison extension, append ';' before the last 1277 brace in braced code, so that the user code can omit trailing 1278 ';'. But do not append ';' if emulating Yacc, since Yacc does 1279 not append one. This is deprecated since release 2.4.1. */ 1280 if (outer_brace && !yacc_flag && language_prio == default_prio 1281 && skeleton_prio == default_prio && need_semicolon && ! in_cpp) 1282 { 1283 unsigned int indent = 0; 1284 warn_at_indent (*loc, &indent, 1285 _("a ';' might be needed at the end of action code")); 1286 indent += SUB_INDENT; 1287 warn_at_indent (*loc, &indent, 1288 _("future versions of Bison will not add the ';'")); 1289 obstack_1grow (&obstack_for_string, ';'); 1290 } 1291 1292 STRING_GROW; 1293 need_semicolon = false; 1294 } 1295 YY_BREAK 1296 /* Preprocessing directives should only be recognized at the beginning 1297 of lines, allowing whitespace including comments, but in C/C++, 1298 '#' can only be the start of preprocessor directives or within 1299 '#define' directives anyway, so don't bother with begin of line. */ 1300 case 18: 1301 YY_RULE_SETUP 1302 #line 244 "scan-code.l" 1303 STRING_GROW; in_cpp = true; 1304 YY_BREAK 1305 case 19: 1306 /* rule 19 can match eol */ 1307 YY_RULE_SETUP 1308 #line 246 "scan-code.l" 1309 STRING_GROW; 1310 YY_BREAK 1311 case 20: 1312 /* rule 20 can match eol */ 1313 YY_RULE_SETUP 1314 #line 247 "scan-code.l" 1315 STRING_GROW; if (in_cpp) in_cpp = need_semicolon = false; 1316 YY_BREAK 1317 case 21: 1318 YY_RULE_SETUP 1319 #line 248 "scan-code.l" 1320 STRING_GROW; 1321 YY_BREAK 1322 /* YYFAIL is undocumented and was formally deprecated in Bison 1323 2.4.2. */ 1324 case 22: 1325 YY_RULE_SETUP 1326 #line 252 "scan-code.l" 1327 { 1328 STRING_GROW; need_semicolon = true; 1329 warn_at (*loc, _("use of YYFAIL, which is deprecated and will be" 1330 " removed")); 1331 } 1332 YY_BREAK 1333 /* The sole purpose of this is to make sure identifiers that merely 1334 contain YYFAIL don't produce the above warning. */ 1335 case 23: 1336 YY_RULE_SETUP 1337 #line 260 "scan-code.l" 1338 STRING_GROW; need_semicolon = true; 1339 YY_BREAK 1340 case 24: 1341 YY_RULE_SETUP 1342 #line 262 "scan-code.l" 1343 STRING_GROW; need_semicolon = true; 1344 YY_BREAK 1345 1346 1347 1348 case 25: 1349 YY_RULE_SETUP 1350 #line 267 "scan-code.l" 1351 { 1352 const char *type_name = NULL; 1353 fetch_type_name (code_text + 1, &type_name, *loc)[-1] = 0; 1354 obstack_sgrow (&obstack_for_string, "]b4_dollar_dollar("); 1355 obstack_quote (&obstack_for_string, type_name); 1356 obstack_sgrow (&obstack_for_string, ")["); 1357 self->is_value_used = true; 1358 } 1359 YY_BREAK 1360 case 26: 1361 YY_RULE_SETUP 1362 #line 275 "scan-code.l" 1363 { 1364 obstack_sgrow (&obstack_for_string, "]b4_at_dollar["); 1365 locations_flag = true; 1366 } 1367 YY_BREAK 1368 1369 1370 1371 /* Escape M4 quoting characters in C code. */ 1372 case 27: 1373 YY_RULE_SETUP 1374 #line 285 "scan-code.l" 1375 obstack_escape (&obstack_for_string, code_text); 1376 YY_BREAK 1377 /* By default, grow the string obstack with the input. */ 1378 case 28: 1379 /* rule 28 can match eol */ 1380 YY_RULE_SETUP 1381 #line 288 "scan-code.l" 1382 STRING_GROW; 1383 YY_BREAK 1384 /* End of processing. */ 1385 case YY_STATE_EOF(INITIAL): 1386 case YY_STATE_EOF(SC_COMMENT): 1387 case YY_STATE_EOF(SC_LINE_COMMENT): 1388 case YY_STATE_EOF(SC_STRING): 1389 case YY_STATE_EOF(SC_CHARACTER): 1390 case YY_STATE_EOF(SC_RULE_ACTION): 1391 case YY_STATE_EOF(SC_SYMBOL_ACTION): 1392 #line 291 "scan-code.l" 1393 STRING_FINISH; return last_string; 1394 YY_BREAK 1395 1396 case 29: 1397 YY_RULE_SETUP 1398 #line 294 "scan-code.l" 1399 YY_FATAL_ERROR( "flex scanner jammed" ); 1400 YY_BREAK 1401 #line 1402 "scan-code.c" 1402 1403 case YY_END_OF_BUFFER: 1404 { 1405 /* Amount of text matched not including the EOB char. */ 1406 int yy_amount_of_matched_text = (int) (yy_cp - (yytext_ptr)) - 1; 1407 1408 /* Undo the effects of YY_DO_BEFORE_ACTION. */ 1409 *yy_cp = (yy_hold_char); 1410 YY_RESTORE_YY_MORE_OFFSET 1411 1412 if ( YY_CURRENT_BUFFER_LVALUE->yy_buffer_status == YY_BUFFER_NEW ) 1413 { 1414 /* We're scanning a new file or input source. It's 1415 * possible that this happened because the user 1416 * just pointed code_in at a new source and called 1417 * code_lex(). If so, then we have to assure 1418 * consistency between YY_CURRENT_BUFFER and our 1419 * globals. Here is the right place to do so, because 1420 * this is the first action (other than possibly a 1421 * back-up) that will match for the new input source. 1422 */ 1423 (yy_n_chars) = YY_CURRENT_BUFFER_LVALUE->yy_n_chars; 1424 YY_CURRENT_BUFFER_LVALUE->yy_input_file = code_in; 1425 YY_CURRENT_BUFFER_LVALUE->yy_buffer_status = YY_BUFFER_NORMAL; 1426 } 1427 1428 /* Note that here we test for yy_c_buf_p "<=" to the position 1429 * of the first EOB in the buffer, since yy_c_buf_p will 1430 * already have been incremented past the NUL character 1431 * (since all states make transitions on EOB to the 1432 * end-of-buffer state). Contrast this with the test 1433 * in input(). 1434 */ 1435 if ( (yy_c_buf_p) <= &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[(yy_n_chars)] ) 1436 { /* This was really a NUL. */ 1437 yy_state_type yy_next_state; 1438 1439 (yy_c_buf_p) = (yytext_ptr) + yy_amount_of_matched_text; 1440 1441 yy_current_state = yy_get_previous_state( ); 1442 1443 /* Okay, we're now positioned to make the NUL 1444 * transition. We couldn't have 1445 * yy_get_previous_state() go ahead and do it 1446 * for us because it doesn't know how to deal 1447 * with the possibility of jamming (and we don't 1448 * want to build jamming into it because then it 1449 * will run more slowly). 1450 */ 1451 1452 yy_next_state = yy_try_NUL_trans( yy_current_state ); 1453 1454 yy_bp = (yytext_ptr) + YY_MORE_ADJ; 1455 1456 if ( yy_next_state ) 1457 { 1458 /* Consume the NUL. */ 1459 yy_cp = ++(yy_c_buf_p); 1460 yy_current_state = yy_next_state; 1461 goto yy_match; 1462 } 1463 1464 else 1465 { 1466 /* %% [14.0] code to do back-up for compressed tables and set up yy_cp goes here */ 1467 yy_cp = (yy_last_accepting_cpos); 1468 yy_current_state = (yy_last_accepting_state); 1469 goto yy_find_action; 1470 } 1471 } 1472 1473 else switch ( yy_get_next_buffer( ) ) 1474 { 1475 case EOB_ACT_END_OF_FILE: 1476 { 1477 (yy_did_buffer_switch_on_eof) = 0; 1478 1479 if ( code_wrap( ) ) 1480 { 1481 /* Note: because we've taken care in 1482 * yy_get_next_buffer() to have set up 1483 * code_text, we can now set up 1484 * yy_c_buf_p so that if some total 1485 * hoser (like flex itself) wants to 1486 * call the scanner after we return the 1487 * YY_NULL, it'll still work - another 1488 * YY_NULL will get returned. 1489 */ 1490 (yy_c_buf_p) = (yytext_ptr) + YY_MORE_ADJ; 1491 1492 yy_act = YY_STATE_EOF(YY_START); 1493 goto do_action; 1494 } 1495 1496 else 1497 { 1498 if ( ! (yy_did_buffer_switch_on_eof) ) 1499 YY_NEW_FILE; 1500 } 1501 break; 1502 } 1503 1504 case EOB_ACT_CONTINUE_SCAN: 1505 (yy_c_buf_p) = 1506 (yytext_ptr) + yy_amount_of_matched_text; 1507 1508 yy_current_state = yy_get_previous_state( ); 1509 1510 yy_cp = (yy_c_buf_p); 1511 yy_bp = (yytext_ptr) + YY_MORE_ADJ; 1512 goto yy_match; 1513 1514 case EOB_ACT_LAST_MATCH: 1515 (yy_c_buf_p) = 1516 &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[(yy_n_chars)]; 1517 1518 yy_current_state = yy_get_previous_state( ); 1519 1520 yy_cp = (yy_c_buf_p); 1521 yy_bp = (yytext_ptr) + YY_MORE_ADJ; 1522 goto yy_find_action; 1523 } 1524 break; 1525 } 1526 1527 default: 1528 YY_FATAL_ERROR( 1529 "fatal flex scanner internal error--no action found" ); 1530 } /* end of action switch */ 1531 } /* end of scanning one token */ 1532 } /* end of code_lex */ 1533 /* %ok-for-header */ 1534 1535 /* %if-c++-only */ 1536 /* %not-for-header */ 1537 1538 /* %ok-for-header */ 1539 1540 /* %endif */ 1541 1542 /* yy_get_next_buffer - try to read in a new buffer 1543 * 1544 * Returns a code representing an action: 1545 * EOB_ACT_LAST_MATCH - 1546 * EOB_ACT_CONTINUE_SCAN - continue scanning from current position 1547 * EOB_ACT_END_OF_FILE - end of file 1548 */ 1549 /* %if-c-only */ 1550 static int yy_get_next_buffer (void) 1551 /* %endif */ 1552 /* %if-c++-only */ 1553 /* %endif */ 1554 { 1555 register char *dest = YY_CURRENT_BUFFER_LVALUE->yy_ch_buf; 1556 register char *source = (yytext_ptr); 1557 register int number_to_move, i; 1558 int ret_val; 1559 1560 if ( (yy_c_buf_p) > &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[(yy_n_chars) + 1] ) 1561 YY_FATAL_ERROR( 1562 "fatal flex scanner internal error--end of buffer missed" ); 1563 1564 if ( YY_CURRENT_BUFFER_LVALUE->yy_fill_buffer == 0 ) 1565 { /* Don't try to fill the buffer, so this is an EOF. */ 1566 if ( (yy_c_buf_p) - (yytext_ptr) - YY_MORE_ADJ == 1 ) 1567 { 1568 /* We matched a single character, the EOB, so 1569 * treat this as a final EOF. 1570 */ 1571 return EOB_ACT_END_OF_FILE; 1572 } 1573 1574 else 1575 { 1576 /* We matched some text prior to the EOB, first 1577 * process it. 1578 */ 1579 return EOB_ACT_LAST_MATCH; 1580 } 1581 } 1582 1583 /* Try to read more data. */ 1584 1585 /* First move last chars to start of buffer. */ 1586 number_to_move = (int) ((yy_c_buf_p) - (yytext_ptr)) - 1; 1587 1588 for ( i = 0; i < number_to_move; ++i ) 1589 *(dest++) = *(source++); 1590 1591 if ( YY_CURRENT_BUFFER_LVALUE->yy_buffer_status == YY_BUFFER_EOF_PENDING ) 1592 /* don't do the read, it's not guaranteed to return an EOF, 1593 * just force an EOF 1594 */ 1595 YY_CURRENT_BUFFER_LVALUE->yy_n_chars = (yy_n_chars) = 0; 1596 1597 else 1598 { 1599 yy_size_t num_to_read = 1600 YY_CURRENT_BUFFER_LVALUE->yy_buf_size - number_to_move - 1; 1601 1602 while ( num_to_read <= 0 ) 1603 { /* Not enough room in the buffer - grow it. */ 1604 1605 /* just a shorter name for the current buffer */ 1606 YY_BUFFER_STATE b = YY_CURRENT_BUFFER_LVALUE; 1607 1608 int yy_c_buf_p_offset = 1609 (int) ((yy_c_buf_p) - b->yy_ch_buf); 1610 1611 if ( b->yy_is_our_buffer ) 1612 { 1613 yy_size_t new_size = b->yy_buf_size * 2; 1614 1615 if ( new_size <= 0 ) 1616 b->yy_buf_size += b->yy_buf_size / 8; 1617 else 1618 b->yy_buf_size *= 2; 1619 1620 b->yy_ch_buf = (char *) 1621 /* Include room in for 2 EOB chars. */ 1622 code_realloc((void *) b->yy_ch_buf,b->yy_buf_size + 2 ); 1623 } 1624 else 1625 /* Can't grow it, we don't own it. */ 1626 b->yy_ch_buf = 0; 1627 1628 if ( ! b->yy_ch_buf ) 1629 YY_FATAL_ERROR( 1630 "fatal error - scanner input buffer overflow" ); 1631 1632 (yy_c_buf_p) = &b->yy_ch_buf[yy_c_buf_p_offset]; 1633 1634 num_to_read = YY_CURRENT_BUFFER_LVALUE->yy_buf_size - 1635 number_to_move - 1; 1636 1637 } 1638 1639 if ( num_to_read > YY_READ_BUF_SIZE ) 1640 num_to_read = YY_READ_BUF_SIZE; 1641 1642 /* Read in more data. */ 1643 YY_INPUT( (&YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[number_to_move]), 1644 (yy_n_chars), num_to_read ); 1645 1646 YY_CURRENT_BUFFER_LVALUE->yy_n_chars = (yy_n_chars); 1647 } 1648 1649 if ( (yy_n_chars) == 0 ) 1650 { 1651 if ( number_to_move == YY_MORE_ADJ ) 1652 { 1653 ret_val = EOB_ACT_END_OF_FILE; 1654 code_restart(code_in ); 1655 } 1656 1657 else 1658 { 1659 ret_val = EOB_ACT_LAST_MATCH; 1660 YY_CURRENT_BUFFER_LVALUE->yy_buffer_status = 1661 YY_BUFFER_EOF_PENDING; 1662 } 1663 } 1664 1665 else 1666 ret_val = EOB_ACT_CONTINUE_SCAN; 1667 1668 if ((yy_size_t) ((yy_n_chars) + number_to_move) > YY_CURRENT_BUFFER_LVALUE->yy_buf_size) { 1669 /* Extend the array by 50%, plus the number we really need. */ 1670 yy_size_t new_size = (yy_n_chars) + number_to_move + ((yy_n_chars) >> 1); 1671 YY_CURRENT_BUFFER_LVALUE->yy_ch_buf = (char *) code_realloc((void *) YY_CURRENT_BUFFER_LVALUE->yy_ch_buf,new_size ); 1672 if ( ! YY_CURRENT_BUFFER_LVALUE->yy_ch_buf ) 1673 YY_FATAL_ERROR( "out of dynamic memory in yy_get_next_buffer()" ); 1674 } 1675 1676 (yy_n_chars) += number_to_move; 1677 YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[(yy_n_chars)] = YY_END_OF_BUFFER_CHAR; 1678 YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[(yy_n_chars) + 1] = YY_END_OF_BUFFER_CHAR; 1679 1680 (yytext_ptr) = &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[0]; 1681 1682 return ret_val; 1683 } 1684 1685 /* yy_get_previous_state - get the state just before the EOB char was reached */ 1686 1687 /* %if-c-only */ 1688 /* %not-for-header */ 1689 1690 static yy_state_type yy_get_previous_state (void) 1691 /* %endif */ 1692 /* %if-c++-only */ 1693 /* %endif */ 1694 { 1695 register yy_state_type yy_current_state; 1696 register char *yy_cp; 1697 1698 /* %% [15.0] code to get the start state into yy_current_state goes here */ 1699 yy_current_state = (yy_start); 1700 1701 for ( yy_cp = (yytext_ptr) + YY_MORE_ADJ; yy_cp < (yy_c_buf_p); ++yy_cp ) 1702 { 1703 /* %% [16.0] code to find the next state goes here */ 1704 register YY_CHAR yy_c = (*yy_cp ? yy_ec[YY_SC_TO_UI(*yy_cp)] : 30); 1705 if ( yy_accept[yy_current_state] ) 1706 { 1707 (yy_last_accepting_state) = yy_current_state; 1708 (yy_last_accepting_cpos) = yy_cp; 1709 } 1710 while ( yy_chk[yy_base[yy_current_state] + yy_c] != yy_current_state ) 1711 { 1712 yy_current_state = (int) yy_def[yy_current_state]; 1713 if ( yy_current_state >= 101 ) 1714 yy_c = yy_meta[(unsigned int) yy_c]; 1715 } 1716 yy_current_state = yy_nxt[yy_base[yy_current_state] + (unsigned int) yy_c]; 1717 } 1718 1719 return yy_current_state; 1720 } 1721 1722 /* yy_try_NUL_trans - try to make a transition on the NUL character 1723 * 1724 * synopsis 1725 * next_state = yy_try_NUL_trans( current_state ); 1726 */ 1727 /* %if-c-only */ 1728 static yy_state_type yy_try_NUL_trans (yy_state_type yy_current_state ) 1729 /* %endif */ 1730 /* %if-c++-only */ 1731 /* %endif */ 1732 { 1733 register int yy_is_jam; 1734 /* %% [17.0] code to find the next state, and perhaps do backing up, goes here */ 1735 register char *yy_cp = (yy_c_buf_p); 1736 1737 register YY_CHAR yy_c = 30; 1738 if ( yy_accept[yy_current_state] ) 1739 { 1740 (yy_last_accepting_state) = yy_current_state; 1741 (yy_last_accepting_cpos) = yy_cp; 1742 } 1743 while ( yy_chk[yy_base[yy_current_state] + yy_c] != yy_current_state ) 1744 { 1745 yy_current_state = (int) yy_def[yy_current_state]; 1746 if ( yy_current_state >= 101 ) 1747 yy_c = yy_meta[(unsigned int) yy_c]; 1748 } 1749 yy_current_state = yy_nxt[yy_base[yy_current_state] + (unsigned int) yy_c]; 1750 yy_is_jam = (yy_current_state == 100); 1751 1752 return yy_is_jam ? 0 : yy_current_state; 1753 } 1754 1755 /* %if-c-only */ 1756 1757 /* %endif */ 1758 1759 /* %if-c-only */ 1760 #ifndef YY_NO_INPUT 1761 #ifdef __cplusplus 1762 static int yyinput (void) 1763 #else 1764 static int input (void) 1765 #endif 1766 1767 /* %endif */ 1768 /* %if-c++-only */ 1769 /* %endif */ 1770 { 1771 int c; 1772 1773 *(yy_c_buf_p) = (yy_hold_char); 1774 1775 if ( *(yy_c_buf_p) == YY_END_OF_BUFFER_CHAR ) 1776 { 1777 /* yy_c_buf_p now points to the character we want to return. 1778 * If this occurs *before* the EOB characters, then it's a 1779 * valid NUL; if not, then we've hit the end of the buffer. 1780 */ 1781 if ( (yy_c_buf_p) < &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[(yy_n_chars)] ) 1782 /* This was really a NUL. */ 1783 *(yy_c_buf_p) = '\0'; 1784 1785 else 1786 { /* need more input */ 1787 yy_size_t offset = (yy_c_buf_p) - (yytext_ptr); 1788 ++(yy_c_buf_p); 1789 1790 switch ( yy_get_next_buffer( ) ) 1791 { 1792 case EOB_ACT_LAST_MATCH: 1793 /* This happens because yy_g_n_b() 1794 * sees that we've accumulated a 1795 * token and flags that we need to 1796 * try matching the token before 1797 * proceeding. But for input(), 1798 * there's no matching to consider. 1799 * So convert the EOB_ACT_LAST_MATCH 1800 * to EOB_ACT_END_OF_FILE. 1801 */ 1802 1803 /* Reset buffer status. */ 1804 code_restart(code_in ); 1805 1806 /*FALLTHROUGH*/ 1807 1808 case EOB_ACT_END_OF_FILE: 1809 { 1810 if ( code_wrap( ) ) 1811 return EOF; 1812 1813 if ( ! (yy_did_buffer_switch_on_eof) ) 1814 YY_NEW_FILE; 1815 #ifdef __cplusplus 1816 return yyinput(); 1817 #else 1818 return input(); 1819 #endif 1820 } 1821 1822 case EOB_ACT_CONTINUE_SCAN: 1823 (yy_c_buf_p) = (yytext_ptr) + offset; 1824 break; 1825 } 1826 } 1827 } 1828 1829 c = *(unsigned char *) (yy_c_buf_p); /* cast for 8-bit char's */ 1830 *(yy_c_buf_p) = '\0'; /* preserve code_text */ 1831 (yy_hold_char) = *++(yy_c_buf_p); 1832 1833 /* %% [19.0] update BOL and code_lineno */ 1834 1835 return c; 1836 } 1837 /* %if-c-only */ 1838 #endif /* ifndef YY_NO_INPUT */ 1839 /* %endif */ 1840 1841 /** Immediately switch to a different input stream. 1842 * @param input_file A readable stream. 1843 * 1844 * @note This function does not reset the start condition to @c INITIAL . 1845 */ 1846 /* %if-c-only */ 1847 void code_restart (FILE * input_file ) 1848 /* %endif */ 1849 /* %if-c++-only */ 1850 /* %endif */ 1851 { 1852 1853 if ( ! YY_CURRENT_BUFFER ){ 1854 code_ensure_buffer_stack (); 1855 YY_CURRENT_BUFFER_LVALUE = 1856 code__create_buffer(code_in,YY_BUF_SIZE ); 1857 } 1858 1859 code__init_buffer(YY_CURRENT_BUFFER,input_file ); 1860 code__load_buffer_state( ); 1861 } 1862 1863 /** Switch to a different input buffer. 1864 * @param new_buffer The new input buffer. 1865 * 1866 */ 1867 /* %if-c-only */ 1868 void code__switch_to_buffer (YY_BUFFER_STATE new_buffer ) 1869 /* %endif */ 1870 /* %if-c++-only */ 1871 /* %endif */ 1872 { 1873 1874 /* TODO. We should be able to replace this entire function body 1875 * with 1876 * code_pop_buffer_state(); 1877 * code_push_buffer_state(new_buffer); 1878 */ 1879 code_ensure_buffer_stack (); 1880 if ( YY_CURRENT_BUFFER == new_buffer ) 1881 return; 1882 1883 if ( YY_CURRENT_BUFFER ) 1884 { 1885 /* Flush out information for old buffer. */ 1886 *(yy_c_buf_p) = (yy_hold_char); 1887 YY_CURRENT_BUFFER_LVALUE->yy_buf_pos = (yy_c_buf_p); 1888 YY_CURRENT_BUFFER_LVALUE->yy_n_chars = (yy_n_chars); 1889 } 1890 1891 YY_CURRENT_BUFFER_LVALUE = new_buffer; 1892 code__load_buffer_state( ); 1893 1894 /* We don't actually know whether we did this switch during 1895 * EOF (code_wrap()) processing, but the only time this flag 1896 * is looked at is after code_wrap() is called, so it's safe 1897 * to go ahead and always set it. 1898 */ 1899 (yy_did_buffer_switch_on_eof) = 1; 1900 } 1901 1902 /* %if-c-only */ 1903 static void code__load_buffer_state (void) 1904 /* %endif */ 1905 /* %if-c++-only */ 1906 /* %endif */ 1907 { 1908 (yy_n_chars) = YY_CURRENT_BUFFER_LVALUE->yy_n_chars; 1909 (yytext_ptr) = (yy_c_buf_p) = YY_CURRENT_BUFFER_LVALUE->yy_buf_pos; 1910 code_in = YY_CURRENT_BUFFER_LVALUE->yy_input_file; 1911 (yy_hold_char) = *(yy_c_buf_p); 1912 } 1913 1914 /** Allocate and initialize an input buffer state. 1915 * @param file A readable stream. 1916 * @param size The character buffer size in bytes. When in doubt, use @c YY_BUF_SIZE. 1917 * 1918 * @return the allocated buffer state. 1919 */ 1920 /* %if-c-only */ 1921 YY_BUFFER_STATE code__create_buffer (FILE * file, int size ) 1922 /* %endif */ 1923 /* %if-c++-only */ 1924 /* %endif */ 1925 { 1926 YY_BUFFER_STATE b; 1927 1928 b = (YY_BUFFER_STATE) code_alloc(sizeof( struct yy_buffer_state ) ); 1929 if ( ! b ) 1930 YY_FATAL_ERROR( "out of dynamic memory in code__create_buffer()" ); 1931 1932 b->yy_buf_size = size; 1933 1934 /* yy_ch_buf has to be 2 characters longer than the size given because 1935 * we need to put in 2 end-of-buffer characters. 1936 */ 1937 b->yy_ch_buf = (char *) code_alloc(b->yy_buf_size + 2 ); 1938 if ( ! b->yy_ch_buf ) 1939 YY_FATAL_ERROR( "out of dynamic memory in code__create_buffer()" ); 1940 1941 b->yy_is_our_buffer = 1; 1942 1943 code__init_buffer(b,file ); 1944 1945 return b; 1946 } 1947 1948 /** Destroy the buffer. 1949 * @param b a buffer created with code__create_buffer() 1950 * 1951 */ 1952 /* %if-c-only */ 1953 void code__delete_buffer (YY_BUFFER_STATE b ) 1954 /* %endif */ 1955 /* %if-c++-only */ 1956 /* %endif */ 1957 { 1958 1959 if ( ! b ) 1960 return; 1961 1962 if ( b == YY_CURRENT_BUFFER ) /* Not sure if we should pop here. */ 1963 YY_CURRENT_BUFFER_LVALUE = (YY_BUFFER_STATE) 0; 1964 1965 if ( b->yy_is_our_buffer ) 1966 code_free((void *) b->yy_ch_buf ); 1967 1968 code_free((void *) b ); 1969 } 1970 1971 /* Initializes or reinitializes a buffer. 1972 * This function is sometimes called more than once on the same buffer, 1973 * such as during a code_restart() or at EOF. 1974 */ 1975 /* %if-c-only */ 1976 static void code__init_buffer (YY_BUFFER_STATE b, FILE * file ) 1977 /* %endif */ 1978 /* %if-c++-only */ 1979 /* %endif */ 1980 1981 { 1982 int oerrno = errno; 1983 1984 code__flush_buffer(b ); 1985 1986 b->yy_input_file = file; 1987 b->yy_fill_buffer = 1; 1988 1989 /* If b is the current buffer, then code__init_buffer was _probably_ 1990 * called from code_restart() or through yy_get_next_buffer. 1991 * In that case, we don't want to reset the lineno or column. 1992 */ 1993 if (b != YY_CURRENT_BUFFER){ 1994 b->yy_bs_lineno = 1; 1995 b->yy_bs_column = 0; 1996 } 1997 1998 /* %if-c-only */ 1999 2000 b->yy_is_interactive = 0; 2001 2002 /* %endif */ 2003 /* %if-c++-only */ 2004 /* %endif */ 2005 errno = oerrno; 2006 } 2007 2008 /** Discard all buffered characters. On the next scan, YY_INPUT will be called. 2009 * @param b the buffer state to be flushed, usually @c YY_CURRENT_BUFFER. 2010 * 2011 */ 2012 /* %if-c-only */ 2013 void code__flush_buffer (YY_BUFFER_STATE b ) 2014 /* %endif */ 2015 /* %if-c++-only */ 2016 /* %endif */ 2017 { 2018 if ( ! b ) 2019 return; 2020 2021 b->yy_n_chars = 0; 2022 2023 /* We always need two end-of-buffer characters. The first causes 2024 * a transition to the end-of-buffer state. The second causes 2025 * a jam in that state. 2026 */ 2027 b->yy_ch_buf[0] = YY_END_OF_BUFFER_CHAR; 2028 b->yy_ch_buf[1] = YY_END_OF_BUFFER_CHAR; 2029 2030 b->yy_buf_pos = &b->yy_ch_buf[0]; 2031 2032 b->yy_at_bol = 1; 2033 b->yy_buffer_status = YY_BUFFER_NEW; 2034 2035 if ( b == YY_CURRENT_BUFFER ) 2036 code__load_buffer_state( ); 2037 } 2038 2039 /* %if-c-or-c++ */ 2040 /** Pushes the new state onto the stack. The new state becomes 2041 * the current state. This function will allocate the stack 2042 * if necessary. 2043 * @param new_buffer The new state. 2044 * 2045 */ 2046 /* %if-c-only */ 2047 void code_push_buffer_state (YY_BUFFER_STATE new_buffer ) 2048 /* %endif */ 2049 /* %if-c++-only */ 2050 /* %endif */ 2051 { 2052 if (new_buffer == NULL) 2053 return; 2054 2055 code_ensure_buffer_stack(); 2056 2057 /* This block is copied from code__switch_to_buffer. */ 2058 if ( YY_CURRENT_BUFFER ) 2059 { 2060 /* Flush out information for old buffer. */ 2061 *(yy_c_buf_p) = (yy_hold_char); 2062 YY_CURRENT_BUFFER_LVALUE->yy_buf_pos = (yy_c_buf_p); 2063 YY_CURRENT_BUFFER_LVALUE->yy_n_chars = (yy_n_chars); 2064 } 2065 2066 /* Only push if top exists. Otherwise, replace top. */ 2067 if (YY_CURRENT_BUFFER) 2068 (yy_buffer_stack_top)++; 2069 YY_CURRENT_BUFFER_LVALUE = new_buffer; 2070 2071 /* copied from code__switch_to_buffer. */ 2072 code__load_buffer_state( ); 2073 (yy_did_buffer_switch_on_eof) = 1; 2074 } 2075 /* %endif */ 2076 2077 /* %if-c-or-c++ */ 2078 /** Removes and deletes the top of the stack, if present. 2079 * The next element becomes the new top. 2080 * 2081 */ 2082 /* %if-c-only */ 2083 void code_pop_buffer_state (void) 2084 /* %endif */ 2085 /* %if-c++-only */ 2086 /* %endif */ 2087 { 2088 if (!YY_CURRENT_BUFFER) 2089 return; 2090 2091 code__delete_buffer(YY_CURRENT_BUFFER ); 2092 YY_CURRENT_BUFFER_LVALUE = NULL; 2093 if ((yy_buffer_stack_top) > 0) 2094 --(yy_buffer_stack_top); 2095 2096 if (YY_CURRENT_BUFFER) { 2097 code__load_buffer_state( ); 2098 (yy_did_buffer_switch_on_eof) = 1; 2099 } 2100 } 2101 /* %endif */ 2102 2103 /* %if-c-or-c++ */ 2104 /* Allocates the stack if it does not exist. 2105 * Guarantees space for at least one push. 2106 */ 2107 /* %if-c-only */ 2108 static void code_ensure_buffer_stack (void) 2109 /* %endif */ 2110 /* %if-c++-only */ 2111 /* %endif */ 2112 { 2113 yy_size_t num_to_alloc; 2114 2115 if (!(yy_buffer_stack)) { 2116 2117 /* First allocation is just for 2 elements, since we don't know if this 2118 * scanner will even need a stack. We use 2 instead of 1 to avoid an 2119 * immediate realloc on the next call. 2120 */ 2121 num_to_alloc = 1; 2122 (yy_buffer_stack) = (struct yy_buffer_state**)code_alloc 2123 (num_to_alloc * sizeof(struct yy_buffer_state*) 2124 ); 2125 if ( ! (yy_buffer_stack) ) 2126 YY_FATAL_ERROR( "out of dynamic memory in code_ensure_buffer_stack()" ); 2127 2128 memset((yy_buffer_stack), 0, num_to_alloc * sizeof(struct yy_buffer_state*)); 2129 2130 (yy_buffer_stack_max) = num_to_alloc; 2131 (yy_buffer_stack_top) = 0; 2132 return; 2133 } 2134 2135 if ((yy_buffer_stack_top) >= ((yy_buffer_stack_max)) - 1){ 2136 2137 /* Increase the buffer to prepare for a possible push. */ 2138 int grow_size = 8 /* arbitrary grow size */; 2139 2140 num_to_alloc = (yy_buffer_stack_max) + grow_size; 2141 (yy_buffer_stack) = (struct yy_buffer_state**)code_realloc 2142 ((yy_buffer_stack), 2143 num_to_alloc * sizeof(struct yy_buffer_state*) 2144 ); 2145 if ( ! (yy_buffer_stack) ) 2146 YY_FATAL_ERROR( "out of dynamic memory in code_ensure_buffer_stack()" ); 2147 2148 /* zero only the new slots.*/ 2149 memset((yy_buffer_stack) + (yy_buffer_stack_max), 0, grow_size * sizeof(struct yy_buffer_state*)); 2150 (yy_buffer_stack_max) = num_to_alloc; 2151 } 2152 } 2153 /* %endif */ 2154 2155 /* %if-c-only */ 2156 /** Setup the input buffer state to scan directly from a user-specified character buffer. 2157 * @param base the character buffer 2158 * @param size the size in bytes of the character buffer 2159 * 2160 * @return the newly allocated buffer state object. 2161 */ 2162 YY_BUFFER_STATE code__scan_buffer (char * base, yy_size_t size ) 2163 { 2164 YY_BUFFER_STATE b; 2165 2166 if ( size < 2 || 2167 base[size-2] != YY_END_OF_BUFFER_CHAR || 2168 base[size-1] != YY_END_OF_BUFFER_CHAR ) 2169 /* They forgot to leave room for the EOB's. */ 2170 return 0; 2171 2172 b = (YY_BUFFER_STATE) code_alloc(sizeof( struct yy_buffer_state ) ); 2173 if ( ! b ) 2174 YY_FATAL_ERROR( "out of dynamic memory in code__scan_buffer()" ); 2175 2176 b->yy_buf_size = size - 2; /* "- 2" to take care of EOB's */ 2177 b->yy_buf_pos = b->yy_ch_buf = base; 2178 b->yy_is_our_buffer = 0; 2179 b->yy_input_file = 0; 2180 b->yy_n_chars = b->yy_buf_size; 2181 b->yy_is_interactive = 0; 2182 b->yy_at_bol = 1; 2183 b->yy_fill_buffer = 0; 2184 b->yy_buffer_status = YY_BUFFER_NEW; 2185 2186 code__switch_to_buffer(b ); 2187 2188 return b; 2189 } 2190 /* %endif */ 2191 2192 /* %if-c-only */ 2193 /** Setup the input buffer state to scan a string. The next call to code_lex() will 2194 * scan from a @e copy of @a str. 2195 * @param yystr a NUL-terminated string to scan 2196 * 2197 * @return the newly allocated buffer state object. 2198 * @note If you want to scan bytes that may contain NUL values, then use 2199 * code__scan_bytes() instead. 2200 */ 2201 YY_BUFFER_STATE code__scan_string (yyconst char * yystr ) 2202 { 2203 2204 return code__scan_bytes(yystr,strlen(yystr) ); 2205 } 2206 /* %endif */ 2207 2208 /* %if-c-only */ 2209 /** Setup the input buffer state to scan the given bytes. The next call to code_lex() will 2210 * scan from a @e copy of @a bytes. 2211 * @param yybytes the byte buffer to scan 2212 * @param _yybytes_len the number of bytes in the buffer pointed to by @a bytes. 2213 * 2214 * @return the newly allocated buffer state object. 2215 */ 2216 YY_BUFFER_STATE code__scan_bytes (yyconst char * yybytes, yy_size_t _yybytes_len ) 2217 { 2218 YY_BUFFER_STATE b; 2219 char *buf; 2220 yy_size_t n; 2221 int i; 2222 2223 /* Get memory for full buffer, including space for trailing EOB's. */ 2224 n = _yybytes_len + 2; 2225 buf = (char *) code_alloc(n ); 2226 if ( ! buf ) 2227 YY_FATAL_ERROR( "out of dynamic memory in code__scan_bytes()" ); 2228 2229 for ( i = 0; i < _yybytes_len; ++i ) 2230 buf[i] = yybytes[i]; 2231 2232 buf[_yybytes_len] = buf[_yybytes_len+1] = YY_END_OF_BUFFER_CHAR; 2233 2234 b = code__scan_buffer(buf,n ); 2235 if ( ! b ) 2236 YY_FATAL_ERROR( "bad buffer in code__scan_bytes()" ); 2237 2238 /* It's okay to grow etc. this buffer, and we should throw it 2239 * away when we're done. 2240 */ 2241 b->yy_is_our_buffer = 1; 2242 2243 return b; 2244 } 2245 /* %endif */ 2246 2247 #ifndef YY_EXIT_FAILURE 2248 #define YY_EXIT_FAILURE 2 2249 #endif 2250 2251 /* %if-c-only */ 2252 static void yy_fatal_error (yyconst char* msg ) 2253 { 2254 (void) fprintf( stderr, "%s\n", msg ); 2255 exit( YY_EXIT_FAILURE ); 2256 } 2257 /* %endif */ 2258 /* %if-c++-only */ 2259 /* %endif */ 2260 2261 /* Redefine yyless() so it works in section 3 code. */ 2262 2263 #undef yyless 2264 #define yyless(n) \ 2265 do \ 2266 { \ 2267 /* Undo effects of setting up code_text. */ \ 2268 int yyless_macro_arg = (n); \ 2269 YY_LESS_LINENO(yyless_macro_arg);\ 2270 code_text[code_leng] = (yy_hold_char); \ 2271 (yy_c_buf_p) = code_text + yyless_macro_arg; \ 2272 (yy_hold_char) = *(yy_c_buf_p); \ 2273 *(yy_c_buf_p) = '\0'; \ 2274 code_leng = yyless_macro_arg; \ 2275 } \ 2276 while ( 0 ) 2277 2278 /* Accessor methods (get/set functions) to struct members. */ 2279 2280 /* %if-c-only */ 2281 /* %if-reentrant */ 2282 /* %endif */ 2283 2284 /** Get the current line number. 2285 * 2286 */ 2287 int code_get_lineno (void) 2288 { 2289 2290 return code_lineno; 2291 } 2292 2293 /** Get the input stream. 2294 * 2295 */ 2296 FILE *code_get_in (void) 2297 { 2298 return code_in; 2299 } 2300 2301 /** Get the output stream. 2302 * 2303 */ 2304 FILE *code_get_out (void) 2305 { 2306 return code_out; 2307 } 2308 2309 /** Get the length of the current token. 2310 * 2311 */ 2312 yy_size_t code_get_leng (void) 2313 { 2314 return code_leng; 2315 } 2316 2317 /** Get the current token. 2318 * 2319 */ 2320 2321 char *code_get_text (void) 2322 { 2323 return code_text; 2324 } 2325 2326 /* %if-reentrant */ 2327 /* %endif */ 2328 2329 /** Set the current line number. 2330 * @param line_number 2331 * 2332 */ 2333 void code_set_lineno (int line_number ) 2334 { 2335 2336 code_lineno = line_number; 2337 } 2338 2339 /** Set the input stream. This does not discard the current 2340 * input buffer. 2341 * @param in_str A readable stream. 2342 * 2343 * @see code__switch_to_buffer 2344 */ 2345 void code_set_in (FILE * in_str ) 2346 { 2347 code_in = in_str ; 2348 } 2349 2350 void code_set_out (FILE * out_str ) 2351 { 2352 code_out = out_str ; 2353 } 2354 2355 int code_get_debug (void) 2356 { 2357 return code__flex_debug; 2358 } 2359 2360 void code_set_debug (int bdebug ) 2361 { 2362 code__flex_debug = bdebug ; 2363 } 2364 2365 /* %endif */ 2366 2367 /* %if-reentrant */ 2368 /* %if-bison-bridge */ 2369 /* %endif */ 2370 /* %endif if-c-only */ 2371 2372 /* %if-c-only */ 2373 static int yy_init_globals (void) 2374 { 2375 /* Initialization is the same as for the non-reentrant scanner. 2376 * This function is called from code_lex_destroy(), so don't allocate here. 2377 */ 2378 2379 (yy_buffer_stack) = 0; 2380 (yy_buffer_stack_top) = 0; 2381 (yy_buffer_stack_max) = 0; 2382 (yy_c_buf_p) = (char *) 0; 2383 (yy_init) = 0; 2384 (yy_start) = 0; 2385 2386 /* Defined in main.c */ 2387 #ifdef YY_STDINIT 2388 code_in = stdin; 2389 code_out = stdout; 2390 #else 2391 code_in = (FILE *) 0; 2392 code_out = (FILE *) 0; 2393 #endif 2394 2395 /* For future reference: Set errno on error, since we are called by 2396 * code_lex_init() 2397 */ 2398 return 0; 2399 } 2400 /* %endif */ 2401 2402 /* %if-c-only SNIP! this currently causes conflicts with the c++ scanner */ 2403 /* code_lex_destroy is for both reentrant and non-reentrant scanners. */ 2404 int code_lex_destroy (void) 2405 { 2406 2407 /* Pop the buffer stack, destroying each element. */ 2408 while(YY_CURRENT_BUFFER){ 2409 code__delete_buffer(YY_CURRENT_BUFFER ); 2410 YY_CURRENT_BUFFER_LVALUE = NULL; 2411 code_pop_buffer_state(); 2412 } 2413 2414 /* Destroy the stack itself. */ 2415 code_free((yy_buffer_stack) ); 2416 (yy_buffer_stack) = NULL; 2417 2418 /* Reset the globals. This is important in a non-reentrant scanner so the next time 2419 * code_lex() is called, initialization will occur. */ 2420 yy_init_globals( ); 2421 2422 /* %if-reentrant */ 2423 /* %endif */ 2424 return 0; 2425 } 2426 /* %endif */ 2427 2428 /* 2429 * Internal utility routines. 2430 */ 2431 2432 #ifndef yytext_ptr 2433 static void yy_flex_strncpy (char* s1, yyconst char * s2, int n ) 2434 { 2435 register int i; 2436 for ( i = 0; i < n; ++i ) 2437 s1[i] = s2[i]; 2438 } 2439 #endif 2440 2441 #ifdef YY_NEED_STRLEN 2442 static int yy_flex_strlen (yyconst char * s ) 2443 { 2444 register int n; 2445 for ( n = 0; s[n]; ++n ) 2446 ; 2447 2448 return n; 2449 } 2450 #endif 2451 2452 void *code_alloc (yy_size_t size ) 2453 { 2454 return (void *) malloc( size ); 2455 } 2456 2457 void *code_realloc (void * ptr, yy_size_t size ) 2458 { 2459 /* The cast to (char *) in the following accommodates both 2460 * implementations that use char* generic pointers, and those 2461 * that use void* generic pointers. It works with the latter 2462 * because both ANSI C and C++ allow castless assignment from 2463 * any pointer type to void*, and deal with argument conversions 2464 * as though doing an assignment. 2465 */ 2466 return (void *) realloc( (char *) ptr, size ); 2467 } 2468 2469 void code_free (void * ptr ) 2470 { 2471 free( (char *) ptr ); /* see code_realloc() for (char *) cast */ 2472 } 2473 2474 /* %if-tables-serialization definitions */ 2475 /* %define-yytables The name for this specific scanner's tables. */ 2476 #define YYTABLES_NAME "yytables" 2477 /* %endif */ 2478 2479 /* %ok-for-header */ 2480 2481 #line 294 "scan-code.l" 2482 2483 2484 2485 static inline bool 2486 is_dot_or_dash (char ch) 2487 { 2488 return ch == '.' || ch == '-'; 2489 } 2490 2491 static inline bool 2492 contains_dot_or_dash (const char* p) 2493 { 2494 for (; *p; ++p) 2495 if (is_dot_or_dash (*p)) 2496 return true; 2497 return false; 2498 } 2499 2500 /* Defines a variant of a symbolic name resolution. */ 2501 typedef struct 2502 { 2503 /* Index in symbol list. */ 2504 unsigned symbol_index; 2505 2506 /* Matched symbol id and loc. */ 2507 uniqstr id; 2508 location loc; 2509 2510 /* Hiding named reference. */ 2511 named_ref* hidden_by; 2512 2513 /* Error flags. May contain zero (no errors) or 2514 a combination of VARIANT_* values. */ 2515 unsigned err; 2516 } variant; 2517 2518 /* Set when the variant refers to a symbol hidden 2519 by an explicit symbol reference. */ 2520 #define VARIANT_HIDDEN (1 << 0) 2521 2522 /* Set when the variant refers to a symbol containing 2523 dots or dashes. Will require explicit bracketing. */ 2524 #define VARIANT_BAD_BRACKETING (1 << 1) 2525 2526 /* Set when the variant refers to a symbol which is 2527 not visible from current midrule. */ 2528 #define VARIANT_NOT_VISIBLE_FROM_MIDRULE (1 << 2) 2529 2530 static variant *variant_table = NULL; 2531 static unsigned variant_table_size = 0; 2532 static unsigned variant_count = 0; 2533 2534 static variant * 2535 variant_table_grow (void) 2536 { 2537 ++variant_count; 2538 if (variant_count > variant_table_size) 2539 { 2540 while (variant_count > variant_table_size) 2541 variant_table_size = 2 * variant_table_size + 3; 2542 variant_table = xnrealloc (variant_table, variant_table_size, 2543 sizeof *variant_table); 2544 } 2545 return &variant_table[variant_count - 1]; 2546 } 2547 2548 static void 2549 variant_table_free (void) 2550 { 2551 free (variant_table); 2552 variant_table = NULL; 2553 variant_table_size = variant_count = 0; 2554 } 2555 2556 static char * 2557 find_prefix_end (const char *prefix, char *begin, char *end) 2558 { 2559 char *ptr = begin; 2560 2561 for (; *prefix && ptr != end; ++prefix, ++ptr) 2562 if (*prefix != *ptr) 2563 return 0; 2564 2565 if (*prefix) 2566 return 0; 2567 2568 return ptr; 2569 } 2570 2571 static variant * 2572 variant_add (uniqstr id, location id_loc, unsigned symbol_index, 2573 char *cp, char *cp_end, bool explicit_bracketing) 2574 { 2575 char *prefix_end; 2576 2577 prefix_end = find_prefix_end (id, cp, cp_end); 2578 if (prefix_end && 2579 (prefix_end == cp_end || 2580 (!explicit_bracketing && is_dot_or_dash (*prefix_end)))) 2581 { 2582 variant *r = variant_table_grow (); 2583 r->symbol_index = symbol_index; 2584 r->id = id; 2585 r->loc = id_loc; 2586 r->hidden_by = NULL; 2587 r->err = 0; 2588 return r; 2589 } 2590 else 2591 return NULL; 2592 } 2593 2594 static const char * 2595 get_at_spec (unsigned symbol_index) 2596 { 2597 static char at_buf[20]; 2598 if (symbol_index == 0) 2599 strcpy (at_buf, "$$"); 2600 else 2601 snprintf (at_buf, sizeof at_buf, "$%u", symbol_index); 2602 return at_buf; 2603 } 2604 2605 static void 2606 show_sub_messages (const char* cp, bool explicit_bracketing, 2607 int midrule_rhs_index, char dollar_or_at, 2608 bool is_warning, unsigned indent) 2609 { 2610 unsigned i; 2611 2612 for (i = 0; i < variant_count; ++i) 2613 { 2614 const variant *var = &variant_table[i]; 2615 const char *at_spec = get_at_spec (var->symbol_index); 2616 2617 if (var->err == 0) 2618 { 2619 if (is_warning) 2620 warn_at_indent (var->loc, &indent, _("refers to: %c%s at %s"), 2621 dollar_or_at, var->id, at_spec); 2622 else 2623 complain_at_indent (var->loc, &indent, _("refers to: %c%s at %s"), 2624 dollar_or_at, var->id, at_spec); 2625 } 2626 else 2627 { 2628 static struct obstack msg_buf; 2629 const char *tail = explicit_bracketing ? "" : 2630 cp + strlen (var->id); 2631 const char *id = var->hidden_by ? var->hidden_by->id : 2632 var->id; 2633 location id_loc = var->hidden_by ? var->hidden_by->loc : 2634 var->loc; 2635 2636 /* Create the explanation message. */ 2637 obstack_init (&msg_buf); 2638 2639 obstack_printf (&msg_buf, _("possibly meant: %c"), dollar_or_at); 2640 if (contains_dot_or_dash (id)) 2641 obstack_printf (&msg_buf, "[%s]", id); 2642 else 2643 obstack_sgrow (&msg_buf, id); 2644 obstack_sgrow (&msg_buf, tail); 2645 2646 if (var->err & VARIANT_HIDDEN) 2647 { 2648 obstack_printf (&msg_buf, _(", hiding %c"), dollar_or_at); 2649 if (contains_dot_or_dash (var->id)) 2650 obstack_printf (&msg_buf, "[%s]", var->id); 2651 else 2652 obstack_sgrow (&msg_buf, var->id); 2653 obstack_sgrow (&msg_buf, tail); 2654 } 2655 2656 obstack_printf (&msg_buf, _(" at %s"), at_spec); 2657 2658 if (var->err & VARIANT_NOT_VISIBLE_FROM_MIDRULE) 2659 { 2660 const char *format = 2661 _(", cannot be accessed from mid-rule action at $%d"); 2662 obstack_printf (&msg_buf, format, midrule_rhs_index); 2663 } 2664 2665 obstack_1grow (&msg_buf, '\0'); 2666 if (is_warning) 2667 warn_at_indent (id_loc, &indent, "%s", 2668 (char *) obstack_finish (&msg_buf)); 2669 else 2670 complain_at_indent (id_loc, &indent, "%s", 2671 (char *) obstack_finish (&msg_buf)); 2672 obstack_free (&msg_buf, 0); 2673 } 2674 } 2675 } 2676 2677 /* Returned from "parse_ref" when the reference 2678 is inappropriate. */ 2679 #define INVALID_REF (INT_MIN) 2680 2681 /* Returned from "parse_ref" when the reference 2682 points to LHS ($$) of the current rule or midrule. */ 2683 #define LHS_REF (INT_MIN + 1) 2684 2685 /* Parse named or positional reference. In case of positional 2686 references, can return negative values for $-n "deep" stack 2687 accesses. */ 2688 static long int 2689 parse_ref (char *cp, symbol_list *rule, int rule_length, 2690 int midrule_rhs_index, char *text, location text_loc, 2691 char dollar_or_at) 2692 { 2693 symbol_list *l; 2694 char *cp_end; 2695 bool explicit_bracketing; 2696 unsigned i; 2697 unsigned valid_variants = 0; 2698 unsigned valid_variant_index = 0; 2699 2700 if ('$' == *cp) 2701 return LHS_REF; 2702 2703 if (c_isdigit (*cp) || (*cp == '-' && c_isdigit (* (cp + 1)))) 2704 { 2705 long int num = strtol (cp, &cp, 10); 2706 if (1 - INT_MAX + rule_length <= num && num <= rule_length) 2707 return num; 2708 else 2709 { 2710 complain_at (text_loc, _("integer out of range: %s"), 2711 quote (text)); 2712 return INVALID_REF; 2713 } 2714 } 2715 2716 if ('[' == *cp) 2717 { 2718 /* Ignore the brackets. */ 2719 char *p; 2720 for (p = ++cp; *p != ']'; ++p) 2721 continue; 2722 cp_end = p; 2723 2724 explicit_bracketing = true; 2725 } 2726 else 2727 { 2728 /* Take all characters of the name. */ 2729 char* p; 2730 for (p = cp; *p; ++p) 2731 if (is_dot_or_dash (*p)) 2732 { 2733 ref_tail_fields = p; 2734 break; 2735 } 2736 for (p = cp; *p; ++p) 2737 continue; 2738 cp_end = p; 2739 2740 explicit_bracketing = false; 2741 } 2742 2743 /* Add all relevant variants. */ 2744 { 2745 unsigned symbol_index; 2746 variant_count = 0; 2747 for (symbol_index = 0, l = rule; !symbol_list_null (l); 2748 ++symbol_index, l = l->next) 2749 { 2750 variant *var; 2751 if (l->content_type != SYMLIST_SYMBOL) 2752 continue; 2753 2754 var = variant_add (l->content.sym->tag, l->sym_loc, 2755 symbol_index, cp, cp_end, explicit_bracketing); 2756 if (var && l->named_ref) 2757 var->hidden_by = l->named_ref; 2758 2759 if (l->named_ref) 2760 variant_add (l->named_ref->id, l->named_ref->loc, 2761 symbol_index, cp, cp_end, explicit_bracketing); 2762 } 2763 } 2764 2765 /* Check errors. */ 2766 for (i = 0; i < variant_count; ++i) 2767 { 2768 variant *var = &variant_table[i]; 2769 unsigned symbol_index = var->symbol_index; 2770 2771 /* Check visibility from mid-rule actions. */ 2772 if (midrule_rhs_index != 0 2773 && (symbol_index == 0 || midrule_rhs_index < symbol_index)) 2774 var->err |= VARIANT_NOT_VISIBLE_FROM_MIDRULE; 2775 2776 /* Check correct bracketing. */ 2777 if (!explicit_bracketing && contains_dot_or_dash (var->id)) 2778 var->err |= VARIANT_BAD_BRACKETING; 2779 2780 /* Check using of hidden symbols. */ 2781 if (var->hidden_by) 2782 var->err |= VARIANT_HIDDEN; 2783 2784 if (!var->err) 2785 { 2786 valid_variant_index = i; 2787 ++valid_variants; 2788 } 2789 } 2790 2791 switch (valid_variants) 2792 { 2793 case 0: 2794 { 2795 unsigned len = (explicit_bracketing || !ref_tail_fields) ? 2796 cp_end - cp : ref_tail_fields - cp; 2797 unsigned indent = 0; 2798 2799 complain_at_indent (text_loc, &indent, _("invalid reference: %s"), 2800 quote (text)); 2801 indent += SUB_INDENT; 2802 if (len == 0) 2803 { 2804 location sym_loc = text_loc; 2805 sym_loc.start.column += 1; 2806 sym_loc.end = sym_loc.start; 2807 const char *format = 2808 _("syntax error after '%c', expecting integer, letter," 2809 " '_', '[', or '$'"); 2810 complain_at_indent (sym_loc, &indent, format, dollar_or_at); 2811 } 2812 else if (midrule_rhs_index) 2813 { 2814 const char *format = 2815 _("symbol not found in production before $%d: %.*s"); 2816 complain_at_indent (rule->location, &indent, format, 2817 midrule_rhs_index, len, cp); 2818 } 2819 else 2820 { 2821 const char *format = 2822 _("symbol not found in production: %.*s"); 2823 complain_at_indent (rule->location, &indent, format, 2824 len, cp); 2825 } 2826 2827 if (variant_count > 0) 2828 show_sub_messages (cp, explicit_bracketing, midrule_rhs_index, 2829 dollar_or_at, false, indent); 2830 return INVALID_REF; 2831 } 2832 case 1: 2833 { 2834 unsigned indent = 0; 2835 if (variant_count > 1) 2836 { 2837 warn_at_indent (text_loc, &indent, _("misleading reference: %s"), 2838 quote (text)); 2839 show_sub_messages (cp, explicit_bracketing, midrule_rhs_index, 2840 dollar_or_at, true, indent + SUB_INDENT); 2841 } 2842 { 2843 unsigned symbol_index = 2844 variant_table[valid_variant_index].symbol_index; 2845 return (symbol_index == midrule_rhs_index) ? LHS_REF : symbol_index; 2846 } 2847 } 2848 case 2: 2849 default: 2850 { 2851 unsigned indent = 0; 2852 complain_at_indent (text_loc, &indent, _("ambiguous reference: %s"), 2853 quote (text)); 2854 show_sub_messages (cp, explicit_bracketing, midrule_rhs_index, 2855 dollar_or_at, false, indent + SUB_INDENT); 2856 return INVALID_REF; 2857 } 2858 } 2859 2860 /* Not reachable. */ 2861 return INVALID_REF; 2862 } 2863 2864 /* Keeps track of the maximum number of semantic values to the left of 2865 a handle (those referenced by $0, $-1, etc.) are required by the 2866 semantic actions of this grammar. */ 2867 int max_left_semantic_context = 0; 2868 2869 2870 /* If CP points to a typename (i.e., <.*?>), set TYPE_NAME to its 2871 beginning (i.e., after the opening "<", and return the pointer 2872 immediately after it. */ 2873 2874 static 2875 char * 2876 fetch_type_name (char *cp, char const **type_name, 2877 location dollar_loc) 2878 { 2879 if (*cp == '<') 2880 { 2881 *type_name = ++cp; 2882 while (*cp != '>') 2883 ++cp; 2884 2885 /* The '>' symbol will be later replaced by '\0'. Original 2886 'text' is needed for error messages. */ 2887 ++cp; 2888 if (untyped_var_seen) 2889 complain_at (dollar_loc, _("explicit type given in untyped grammar")); 2890 tag_seen = true; 2891 } 2892 return cp; 2893 } 2894 2895 /*------------------------------------------------------------------. 2896 | TEXT is pointing to a wannabee semantic value (i.e., a '$'). | 2897 | | 2898 | Possible inputs: $[<TYPENAME>]($|integer) | 2899 | | 2900 | Output to OBSTACK_FOR_STRING a reference to this semantic value. | 2901 `------------------------------------------------------------------*/ 2902 2903 static void 2904 handle_action_dollar (symbol_list *rule, char *text, location dollar_loc) 2905 { 2906 char const *type_name = NULL; 2907 char *cp = text + 1; 2908 symbol_list *effective_rule; 2909 int effective_rule_length; 2910 int n; 2911 2912 if (rule->midrule_parent_rule) 2913 { 2914 effective_rule = rule->midrule_parent_rule; 2915 effective_rule_length = rule->midrule_parent_rhs_index - 1; 2916 } 2917 else 2918 { 2919 effective_rule = rule; 2920 effective_rule_length = symbol_list_length (rule->next); 2921 } 2922 2923 /* Get the type name if explicit. */ 2924 cp = fetch_type_name (cp, &type_name, dollar_loc); 2925 2926 n = parse_ref (cp, effective_rule, effective_rule_length, 2927 rule->midrule_parent_rhs_index, text, dollar_loc, '$'); 2928 2929 /* End type_name. */ 2930 if (type_name) 2931 cp[-1] = '\0'; 2932 2933 switch (n) 2934 { 2935 case INVALID_REF: 2936 break; 2937 2938 case LHS_REF: 2939 if (!type_name) 2940 type_name = symbol_list_n_type_name_get (rule, dollar_loc, 0); 2941 2942 if (!type_name) 2943 { 2944 if (union_seen | tag_seen) 2945 { 2946 if (rule->midrule_parent_rule) 2947 complain_at (dollar_loc, 2948 _("$$ for the midrule at $%d of %s" 2949 " has no declared type"), 2950 rule->midrule_parent_rhs_index, 2951 quote (effective_rule->content.sym->tag)); 2952 else 2953 complain_at (dollar_loc, _("$$ of %s has no declared type"), 2954 quote (rule->content.sym->tag)); 2955 } 2956 else 2957 untyped_var_seen = true; 2958 } 2959 2960 obstack_sgrow (&obstack_for_string, "]b4_lhs_value("); 2961 obstack_quote (&obstack_for_string, type_name); 2962 obstack_sgrow (&obstack_for_string, ")["); 2963 rule->action_props.is_value_used = true; 2964 break; 2965 2966 default: 2967 if (max_left_semantic_context < 1 - n) 2968 max_left_semantic_context = 1 - n; 2969 if (!type_name && 0 < n) 2970 type_name = 2971 symbol_list_n_type_name_get (effective_rule, dollar_loc, n); 2972 if (!type_name) 2973 { 2974 if (union_seen | tag_seen) 2975 complain_at (dollar_loc, _("$%s of %s has no declared type"), 2976 cp, quote (effective_rule->content.sym->tag)); 2977 else 2978 untyped_var_seen = true; 2979 } 2980 2981 obstack_printf (&obstack_for_string, 2982 "]b4_rhs_value(%d, %d, ", effective_rule_length, n); 2983 obstack_quote (&obstack_for_string, type_name); 2984 obstack_sgrow (&obstack_for_string, ")["); 2985 if (n > 0) 2986 symbol_list_n_get (effective_rule, n)->action_props.is_value_used = 2987 true; 2988 break; 2989 } 2990 } 2991 2992 2993 /*------------------------------------------------------. 2994 | TEXT is a location token (i.e., a '@...'). Output to | 2995 | OBSTACK_FOR_STRING a reference to this location. | 2996 `------------------------------------------------------*/ 2997 2998 static void 2999 handle_action_at (symbol_list *rule, char *text, location at_loc) 3000 { 3001 char *cp = text + 1; 3002 symbol_list *effective_rule; 3003 int effective_rule_length; 3004 int n; 3005 3006 if (rule->midrule_parent_rule) 3007 { 3008 effective_rule = rule->midrule_parent_rule; 3009 effective_rule_length = rule->midrule_parent_rhs_index - 1; 3010 } 3011 else 3012 { 3013 effective_rule = rule; 3014 effective_rule_length = symbol_list_length (rule->next); 3015 } 3016 3017 locations_flag = true; 3018 3019 n = parse_ref (cp, effective_rule, effective_rule_length, 3020 rule->midrule_parent_rhs_index, text, at_loc, '@'); 3021 switch (n) 3022 { 3023 case INVALID_REF: 3024 break; 3025 3026 case LHS_REF: 3027 obstack_sgrow (&obstack_for_string, "]b4_lhs_location["); 3028 break; 3029 3030 default: 3031 obstack_printf (&obstack_for_string, "]b4_rhs_location(%d, %d)[", 3032 effective_rule_length, n); 3033 break; 3034 } 3035 } 3036 3037 3038 /*-------------------------. 3039 | Initialize the scanner. | 3040 `-------------------------*/ 3041 3042 /* Translate the dollars and ats in \a self, in the context \a sc_context 3043 (SC_RULE_ACTION, SC_SYMBOL_ACTION, INITIAL). */ 3044 3045 static char const * 3046 translate_action (code_props *self, int sc_context) 3047 { 3048 char *res; 3049 static bool initialized = false; 3050 if (!initialized) 3051 { 3052 obstack_init (&obstack_for_string); 3053 code__flex_debug = 0; 3054 initialized = true; 3055 } 3056 3057 loc->start = loc->end = self->location.start; 3058 code__switch_to_buffer (code__scan_string (self->code)); 3059 res = code_lex (self, sc_context); 3060 code__delete_buffer (YY_CURRENT_BUFFER); 3061 3062 return res; 3063 } 3064 3065 /*------------------------------------------------------------------------. 3066 | Implementation of the public interface as documented in "scan-code.h". | 3067 `------------------------------------------------------------------------*/ 3068 3069 void 3070 code_props_none_init (code_props *self) 3071 { 3072 *self = code_props_none; 3073 } 3074 3075 code_props const code_props_none = CODE_PROPS_NONE_INIT; 3076 3077 void 3078 code_props_plain_init (code_props *self, char const *code, 3079 location code_loc) 3080 { 3081 self->kind = CODE_PROPS_PLAIN; 3082 self->code = code; 3083 self->location = code_loc; 3084 self->is_value_used = false; 3085 self->rule = NULL; 3086 self->named_ref = NULL; 3087 } 3088 3089 void 3090 code_props_symbol_action_init (code_props *self, char const *code, 3091 location code_loc) 3092 { 3093 self->kind = CODE_PROPS_SYMBOL_ACTION; 3094 self->code = code; 3095 self->location = code_loc; 3096 self->is_value_used = false; 3097 self->rule = NULL; 3098 self->named_ref = NULL; 3099 } 3100 3101 void 3102 code_props_rule_action_init (code_props *self, char const *code, 3103 location code_loc, symbol_list *rule, 3104 named_ref *name) 3105 { 3106 self->kind = CODE_PROPS_RULE_ACTION; 3107 self->code = code; 3108 self->location = code_loc; 3109 self->is_value_used = false; 3110 self->rule = rule; 3111 self->named_ref = name; 3112 } 3113 3114 void 3115 code_props_translate_code (code_props *self) 3116 { 3117 switch (self->kind) 3118 { 3119 case CODE_PROPS_NONE: 3120 break; 3121 case CODE_PROPS_PLAIN: 3122 self->code = translate_action (self, INITIAL); 3123 break; 3124 case CODE_PROPS_SYMBOL_ACTION: 3125 self->code = translate_action (self, SC_SYMBOL_ACTION); 3126 break; 3127 case CODE_PROPS_RULE_ACTION: 3128 self->code = translate_action (self, SC_RULE_ACTION); 3129 break; 3130 } 3131 } 3132 3133 void 3134 code_scanner_last_string_free (void) 3135 { 3136 STRING_FREE; 3137 } 3138 3139 void 3140 code_scanner_free (void) 3141 { 3142 obstack_free (&obstack_for_string, 0); 3143 variant_table_free (); 3144 3145 /* Reclaim Flex's buffers. */ 3146 code_lex_destroy (); 3147 } 3148 3149