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