flex.skl revision 1.2
1%# -*-C-*- vi: set ft=c: 2%# This file is processed in several stages. 3%# Here are the stages, as best as I can describe: 4%# 5%# 1. flex.skl is processed through GNU m4 during the 6%# pre-compilation stage of flex. Only macros starting 7%# with `m4preproc_' are processed, and quoting is normal. 8%# 9%# 2. The preprocessed skeleton is translated verbatim into a 10%# C array, saved as "skel.c" and compiled into the flex binary. 11%# 12%# 3. At runtime, the skeleton is generated and filtered (again) 13%# through m4. Macros beginning with `m4_' will be processed. 14%# The quoting is "[[" and "]]" so we don't interfere with 15%# user code. 16%# 17%# All generate macros for the m4 stage contain the text "m4" or "M4" 18%# in them. This is to distinguish them from CPP macros. 19%# The exception to this rule is YY_G, which is an m4 macro, 20%# but it needs to be remain short because it is used everywhere. 21%# 22/* A lexical scanner generated by flex */ 23 24%# Macros for preproc stage. 25m4preproc_changecom 26 27%# Macros for runtime processing stage. 28m4_changecom 29m4_changequote 30m4_changequote([[, ]]) 31 32%# 33%# Lines in this skeleton starting with a "%" character are "control lines" 34%# and affect the generation of the scanner. The possible control codes are 35%# listed and processed in misc.c. 36%# 37%# %# - A comment. The current line is omitted from the generated scanner. 38%# %if-c++-only - The following lines are printed for C++ scanners ONLY. 39%# %if-c-only - The following lines are NOT printed for C++ scanners. 40%# %if-c-or-c++ - The following lines are printed in BOTH C and C++ scanners. 41%# %if-reentrant - Print for reentrant scanners.(push) 42%# %if-not-reentrant - Print for non-reentrant scanners. (push) 43%# %if-bison-bridge - Print for bison-bridge. (push) 44%# %if-not-bison-bridge - Print for non-bison-bridge. (push) 45%# %endif - pop from the previous if code. 46%# %% - A stop-point, where code is inserted by flex. 47%# Each stop-point is numbered here and also in the code generator. 48%# (See gen.c, etc. for details.) 49%# %not-for-header - Begin code that should NOT appear in a ".h" file. 50%# %ok-for-header - %c and %e are used for building a header file. 51%# %if-tables-serialization 52%# 53%# All control-lines EXCEPT comment lines ("%#") will be inserted into 54%# the generated scanner as a C-style comment. This is to aid those who 55%# edit the skeleton. 56%# 57 58%not-for-header 59%if-c-only 60%if-not-reentrant 61m4_ifelse(M4_YY_PREFIX,yy,, 62#define yy_create_buffer M4_YY_PREFIX[[_create_buffer]] 63#define yy_delete_buffer M4_YY_PREFIX[[_delete_buffer]] 64#define yy_flex_debug M4_YY_PREFIX[[_flex_debug]] 65#define yy_init_buffer M4_YY_PREFIX[[_init_buffer]] 66#define yy_flush_buffer M4_YY_PREFIX[[_flush_buffer]] 67#define yy_load_buffer_state M4_YY_PREFIX[[_load_buffer_state]] 68#define yy_switch_to_buffer M4_YY_PREFIX[[_switch_to_buffer]] 69#define yyin M4_YY_PREFIX[[in]] 70#define yyleng M4_YY_PREFIX[[leng]] 71#define yylex M4_YY_PREFIX[[lex]] 72#define yylineno M4_YY_PREFIX[[lineno]] 73#define yyout M4_YY_PREFIX[[out]] 74#define yyrestart M4_YY_PREFIX[[restart]] 75#define yytext M4_YY_PREFIX[[text]] 76#define yywrap M4_YY_PREFIX[[wrap]] 77#define yyalloc M4_YY_PREFIX[[alloc]] 78#define yyrealloc M4_YY_PREFIX[[realloc]] 79#define yyfree M4_YY_PREFIX[[free]] 80) 81%endif 82%endif 83%ok-for-header 84 85#define FLEX_SCANNER 86#define YY_FLEX_MAJOR_VERSION FLEX_MAJOR_VERSION 87#define YY_FLEX_MINOR_VERSION FLEX_MINOR_VERSION 88#define YY_FLEX_SUBMINOR_VERSION FLEX_SUBMINOR_VERSION 89#if YY_FLEX_SUBMINOR_VERSION > 0 90#define FLEX_BETA 91#endif 92 93%# Some negated symbols 94m4_ifdef( [[M4_YY_IN_HEADER]], , [[m4_define([[M4_YY_NOT_IN_HEADER]], [[]])]]) 95m4_ifdef( [[M4_YY_REENTRANT]], , [[m4_define([[M4_YY_NOT_REENTRANT]], [[]])]]) 96 97%# This is the m4 way to say "(stack_used || is_reentrant) 98m4_ifdef( [[M4_YY_STACK_USED]], [[m4_define([[M4_YY_HAS_START_STACK_VARS]])]]) 99m4_ifdef( [[M4_YY_REENTRANT]], [[m4_define([[M4_YY_HAS_START_STACK_VARS]])]]) 100 101%# Prefixes. 102%# The complexity here is necessary so that m4 preserves 103%# the argument lists to each C function. 104 105 106m4_ifdef( [[M4_YY_PREFIX]],, [[m4_define([[M4_YY_PREFIX]], [[yy]])]]) 107 108m4preproc_define(`M4_GEN_PREFIX', 109 ``m4_define(yy[[$1]], [[M4_YY_PREFIX[[$1]]m4_ifelse($'`#,0,,[[($'`@)]])]])'') 110 111%if-c++-only 112 /* The c++ scanner is a mess. The FlexLexer.h header file relies on the 113 * following macro. This is required in order to pass the c++-multiple-scanners 114 * test in the regression suite. We get reports that it breaks inheritance. 115 * We will address this in a future release of flex, or omit the C++ scanner 116 * altogether. 117 */ 118 #define yyFlexLexer M4_YY_PREFIX[[FlexLexer]] 119%endif 120 121%if-c-only 122 M4_GEN_PREFIX(`_create_buffer') 123 M4_GEN_PREFIX(`_delete_buffer') 124 M4_GEN_PREFIX(`_scan_buffer') 125 M4_GEN_PREFIX(`_scan_string') 126 M4_GEN_PREFIX(`_scan_bytes') 127 M4_GEN_PREFIX(`_init_buffer') 128 M4_GEN_PREFIX(`_flush_buffer') 129 M4_GEN_PREFIX(`_load_buffer_state') 130 M4_GEN_PREFIX(`_switch_to_buffer') 131 M4_GEN_PREFIX(`push_buffer_state') 132 M4_GEN_PREFIX(`pop_buffer_state') 133 M4_GEN_PREFIX(`ensure_buffer_stack') 134 M4_GEN_PREFIX(`lex') 135 M4_GEN_PREFIX(`restart') 136 M4_GEN_PREFIX(`lex_init') 137 M4_GEN_PREFIX(`lex_init_extra') 138 M4_GEN_PREFIX(`lex_destroy') 139 M4_GEN_PREFIX(`get_debug') 140 M4_GEN_PREFIX(`set_debug') 141 M4_GEN_PREFIX(`get_extra') 142 M4_GEN_PREFIX(`set_extra') 143 M4_GEN_PREFIX(`get_in') 144 M4_GEN_PREFIX(`set_in') 145 M4_GEN_PREFIX(`get_out') 146 M4_GEN_PREFIX(`set_out') 147 M4_GEN_PREFIX(`get_leng') 148 M4_GEN_PREFIX(`get_text') 149 M4_GEN_PREFIX(`get_lineno') 150 M4_GEN_PREFIX(`set_lineno') 151 m4_ifdef( [[M4_YY_REENTRANT]], 152 [[ 153 M4_GEN_PREFIX(`get_column') 154 M4_GEN_PREFIX(`set_column') 155 ]]) 156 M4_GEN_PREFIX(`wrap') 157%endif 158 159m4_ifdef( [[M4_YY_BISON_LVAL]], 160[[ 161 M4_GEN_PREFIX(`get_lval') 162 M4_GEN_PREFIX(`set_lval') 163]]) 164 165m4_ifdef( [[<M4_YY_BISON_LLOC>]], 166[[ 167 M4_GEN_PREFIX(`get_lloc') 168 M4_GEN_PREFIX(`set_lloc') 169]]) 170 171 172 M4_GEN_PREFIX(`alloc') 173 M4_GEN_PREFIX(`realloc') 174 M4_GEN_PREFIX(`free') 175 176%if-c-only 177m4_ifdef( [[M4_YY_NOT_REENTRANT]], 178[[ 179 M4_GEN_PREFIX(`text') 180 M4_GEN_PREFIX(`leng') 181 M4_GEN_PREFIX(`in') 182 M4_GEN_PREFIX(`out') 183 M4_GEN_PREFIX(`_flex_debug') 184 M4_GEN_PREFIX(`lineno') 185]]) 186%endif 187 188 189m4_ifdef( [[M4_YY_TABLES_EXTERNAL]], 190[[ 191 M4_GEN_PREFIX(`tables_fload') 192 M4_GEN_PREFIX(`tables_destroy') 193 M4_GEN_PREFIX(`TABLES_NAME') 194]]) 195 196/* First, we deal with platform-specific or compiler-specific issues. */ 197 198/* begin standard C headers. */ 199%if-c-only 200#ifdef _LIBC 201#include "namespace.h" 202#endif 203#include <stdio.h> 204#include <string.h> 205#include <errno.h> 206#include <stdlib.h> 207%endif 208 209%if-tables-serialization 210#include <sys/types.h> 211#include <netinet/in.h> 212%endif 213/* end standard C headers. */ 214 215%if-c-or-c++ 216m4preproc_include(`flexint.h') 217%endif 218 219%if-c++-only 220/* begin standard C++ headers. */ 221#ifdef _LIBC 222#include "namespace.h" 223#endif 224#include <iostream> 225#include <errno.h> 226#include <cstdlib> 227#include <cstdio> 228#include <cstring> 229/* end standard C++ headers. */ 230%endif 231 232#ifdef __cplusplus 233 234/* The "const" storage-class-modifier is valid. */ 235#define YY_USE_CONST 236 237#else /* ! __cplusplus */ 238 239/* C99 requires __STDC__ to be defined as 1. */ 240#if defined (__STDC__) 241 242#define YY_USE_CONST 243 244#endif /* defined (__STDC__) */ 245#endif /* ! __cplusplus */ 246 247#ifdef YY_USE_CONST 248#define yyconst const 249#else 250#define yyconst 251#endif 252 253%# For compilers that can not handle prototypes. 254%# e.g., 255%# The function prototype 256%# int foo(int x, char* y); 257%# 258%# ...should be written as 259%# int foo M4_YY_PARAMS(int x, char* y); 260%# 261%# ...which could possibly generate 262%# int foo (); 263%# 264m4_ifdef( [[M4_YY_NO_ANSI_FUNC_PROTOS]], 265[[ 266 m4_define( [[M4_YY_PARAMS]], [[()]]) 267]], 268[[ 269 m4_define( [[M4_YY_PARAMS]], [[($*)]]) 270]]) 271 272%not-for-header 273/* Returned upon end-of-file. */ 274#define YY_NULL 0 275%ok-for-header 276 277%not-for-header 278/* Promotes a possibly negative, possibly signed char to an unsigned 279 * integer for use as an array index. If the signed char is negative, 280 * we want to instead treat it as an 8-bit unsigned char, hence the 281 * double cast. 282 */ 283#define YY_SC_TO_UI(c) ((unsigned int) (unsigned char) c) 284%ok-for-header 285 286 287 288%if-reentrant 289 290/* An opaque pointer. */ 291#ifndef YY_TYPEDEF_YY_SCANNER_T 292#define YY_TYPEDEF_YY_SCANNER_T 293typedef void* yyscan_t; 294#endif 295 296%# Declare yyguts variable 297m4_define( [[M4_YY_DECL_GUTS_VAR]], [[struct yyguts_t * yyg = (struct yyguts_t*)yyscanner]]) 298%# Perform a noop access on yyguts to prevent unused variable complains 299m4_define( [[M4_YY_NOOP_GUTS_VAR]], [[(void)yyg]]) 300%# For use wherever a Global is accessed or assigned. 301m4_define( [[YY_G]], [[yyg->$1]]) 302 303%# For use in function prototypes to append the additional argument. 304m4_define( [[M4_YY_PROTO_LAST_ARG]], [[, yyscan_t yyscanner]]) 305m4_define( [[M4_YY_PROTO_ONLY_ARG]], [[yyscan_t yyscanner]]) 306 307%# For use in function definitions to append the additional argument. 308m4_ifdef( [[M4_YY_NO_ANSI_FUNC_DEFS]], 309[[ 310 m4_define( [[M4_YY_DEF_LAST_ARG]], [[, yyscanner]]) 311 m4_define( [[M4_YY_DEF_ONLY_ARG]], [[yyscanner]]) 312]], 313[[ 314 m4_define( [[M4_YY_DEF_LAST_ARG]], [[, yyscan_t yyscanner]]) 315 m4_define( [[M4_YY_DEF_ONLY_ARG]], [[yyscan_t yyscanner]]) 316]]) 317m4_define( [[M4_YY_DECL_LAST_ARG]], [[yyscan_t yyscanner;]]) 318 319%# For use in function calls to pass the additional argument. 320m4_define( [[M4_YY_CALL_LAST_ARG]], [[, yyscanner]]) 321m4_define( [[M4_YY_CALL_ONLY_ARG]], [[yyscanner]]) 322 323%# For use in function documentation to adjust for additional argument. 324m4_define( [[M4_YY_DOC_PARAM]], [[@param yyscanner The scanner object.]]) 325 326/* For convenience, these vars (plus the bison vars far below) 327 are macros in the reentrant scanner. */ 328#define yyin YY_G(yyin_r) 329#define yyout YY_G(yyout_r) 330#define yyextra YY_G(yyextra_r) 331#define yyleng YY_G(yyleng_r) 332#define yytext YY_G(yytext_r) 333#define yylineno (YY_CURRENT_BUFFER_LVALUE->yy_bs_lineno) 334#define yycolumn (YY_CURRENT_BUFFER_LVALUE->yy_bs_column) 335#define yy_flex_debug YY_G(yy_flex_debug_r) 336 337m4_define( [[M4_YY_INCR_LINENO]], 338[[ 339 do{ yylineno++; 340 yycolumn=0; 341 }while(0) 342]]) 343 344%endif 345 346 347 348%if-not-reentrant 349 350m4_define( [[M4_YY_INCR_LINENO]], 351[[ 352 yylineno++; 353]]) 354 355%# Define these macros to be no-ops. 356m4_define( [[M4_YY_DECL_GUTS_VAR]], [[m4_dnl]]) 357m4_define( [[M4_YY_NOOP_GUTS_VAR]], [[m4_dnl]]) 358m4_define( [[YY_G]], [[($1)]]) 359m4_define( [[M4_YY_PROTO_LAST_ARG]]) 360m4_define( [[M4_YY_PROTO_ONLY_ARG]], [[void]]) 361m4_define( [[M4_YY_DEF_LAST_ARG]]) 362 363m4_ifdef( [[M4_YY_NO_ANSI_FUNC_DEFS]], 364[[ 365 m4_define( [[M4_YY_DEF_ONLY_ARG]]) 366]], 367[[ 368 m4_define( [[M4_YY_DEF_ONLY_ARG]], [[void]]) 369]]) 370m4_define([[M4_YY_DECL_LAST_ARG]]) 371m4_define([[M4_YY_CALL_LAST_ARG]]) 372m4_define([[M4_YY_CALL_ONLY_ARG]]) 373m4_define( [[M4_YY_DOC_PARAM]], [[]]) 374 375%endif 376 377 378m4_ifdef( [[M4_YY_NO_ANSI_FUNC_DEFS]], 379[[ 380%# For compilers that need traditional function definitions. 381%# e.g., 382%# The function prototype taking 2 arguments 383%# int foo (int x, char* y) 384%# 385%# ...should be written as 386%# int foo YYFARGS2(int,x, char*,y) 387%# 388%# ...which could possibly generate 389%# int foo (x,y,yyscanner) 390%# int x; 391%# char * y; 392%# yyscan_t yyscanner; 393%# 394%# Generate traditional function defs 395 m4_define( [[YYFARGS0]], [[(M4_YY_DEF_ONLY_ARG) [[\]] 396 M4_YY_DECL_LAST_ARG]]) 397 m4_define( [[YYFARGS1]], [[($2 M4_YY_DEF_LAST_ARG) [[\]] 398 $1 $2; [[\]] 399 M4_YY_DECL_LAST_ARG]]) 400 m4_define( [[YYFARGS2]], [[($2,$4 M4_YY_DEF_LAST_ARG) [[\]] 401 $1 $2; [[\]] 402 $3 $4; [[\]] 403 M4_YY_DECL_LAST_ARG]]) 404 m4_define( [[YYFARGS3]], [[($2,$4,$6 M4_YY_DEF_LAST_ARG) [[\]] 405 $1 $2; [[\]] 406 $3 $4; [[\]] 407 $5 $6; [[\]] 408 M4_YY_DECL_LAST_ARG]]) 409]], 410[[ 411%# Generate C99 function defs. 412 m4_define( [[YYFARGS0]], [[(M4_YY_DEF_ONLY_ARG)]]) 413 m4_define( [[YYFARGS1]], [[($1 $2 M4_YY_DEF_LAST_ARG)]]) 414 m4_define( [[YYFARGS2]], [[($1 $2, $3 $4 M4_YY_DEF_LAST_ARG)]]) 415 m4_define( [[YYFARGS3]], [[($1 $2, $3 $4, $5 $6 M4_YY_DEF_LAST_ARG)]]) 416]]) 417 418m4_ifdef( [[M4_YY_NOT_IN_HEADER]], 419[[ 420/* Enter a start condition. This macro really ought to take a parameter, 421 * but we do it the disgusting crufty way forced on us by the ()-less 422 * definition of BEGIN. 423 */ 424#define BEGIN YY_G(yy_start) = 1 + 2 * 425]]) 426 427m4_ifdef( [[M4_YY_NOT_IN_HEADER]], 428[[ 429/* Translate the current start state into a value that can be later handed 430 * to BEGIN to return to the state. The YYSTATE alias is for lex 431 * compatibility. 432 */ 433#define YY_START ((YY_G(yy_start) - 1) / 2) 434#define YYSTATE YY_START 435]]) 436 437m4_ifdef( [[M4_YY_NOT_IN_HEADER]], 438[[ 439/* Action number for EOF rule of a given start state. */ 440#define YY_STATE_EOF(state) (YY_END_OF_BUFFER + state + 1) 441]]) 442 443m4_ifdef( [[M4_YY_NOT_IN_HEADER]], 444[[ 445/* Special action meaning "start processing a new file". */ 446#define YY_NEW_FILE yyrestart( yyin M4_YY_CALL_LAST_ARG ) 447]]) 448 449m4_ifdef( [[M4_YY_NOT_IN_HEADER]], 450[[ 451#define YY_END_OF_BUFFER_CHAR 0 452]]) 453 454/* Size of default input buffer. */ 455#ifndef YY_BUF_SIZE 456#ifdef __ia64__ 457/* On IA-64, the buffer size is 16k, not 8k. 458 * Moreover, YY_BUF_SIZE is 2*YY_READ_BUF_SIZE in the general case. 459 * Ditto for the __ia64__ case accordingly. 460 */ 461#define YY_BUF_SIZE 32768 462#else 463#define YY_BUF_SIZE 16384 464#endif /* __ia64__ */ 465#endif 466 467m4_ifdef( [[M4_YY_NOT_IN_HEADER]], 468[[ 469/* The state buf must be large enough to hold one state per character in the main buffer. 470 */ 471#define YY_STATE_BUF_SIZE ((YY_BUF_SIZE + 2) * sizeof(yy_state_type)) 472]]) 473 474 475#ifndef YY_TYPEDEF_YY_BUFFER_STATE 476#define YY_TYPEDEF_YY_BUFFER_STATE 477typedef struct yy_buffer_state *YY_BUFFER_STATE; 478#endif 479 480#ifndef YY_TYPEDEF_YY_SIZE_T 481#define YY_TYPEDEF_YY_SIZE_T 482typedef size_t yy_size_t; 483#endif 484 485%if-not-reentrant 486extern yy_size_t yyleng; 487%endif 488 489%if-c-only 490%if-not-reentrant 491extern FILE *yyin, *yyout; 492%endif 493%endif 494 495m4_ifdef( [[M4_YY_NOT_IN_HEADER]], 496[[ 497#define EOB_ACT_CONTINUE_SCAN 0 498#define EOB_ACT_END_OF_FILE 1 499#define EOB_ACT_LAST_MATCH 2 500]]) 501 502m4_ifdef( [[M4_YY_NOT_IN_HEADER]], 503[[ 504 m4_ifdef( [[M4_YY_USE_LINENO]], 505 [[ 506 /* Note: We specifically omit the test for yy_rule_can_match_eol because it requires 507 * access to the local variable yy_act. Since yyless() is a macro, it would break 508 * existing scanners that call yyless() from OUTSIDE yylex. 509 * One obvious solution it to make yy_act a global. I tried that, and saw 510 * a 5% performance hit in a non-yylineno scanner, because yy_act is 511 * normally declared as a register variable-- so it is not worth it. 512 */ 513 #define YY_LESS_LINENO(n) \ 514 do { \ 515 int yyl;\ 516 for ( yyl = n; yyl < yyleng; ++yyl )\ 517 if ( yytext[yyl] == '\n' )\ 518 --yylineno;\ 519 }while(0) 520 #define YY_LINENO_REWIND_TO(dst) \ 521 do {\ 522 const char *p;\ 523 for ( p = yy_cp-1; p >= (dst); --p)\ 524 if ( *p == '\n' )\ 525 --yylineno;\ 526 }while(0) 527 ]], 528 [[ 529 #define YY_LESS_LINENO(n) 530 #define YY_LINENO_REWIND_TO(ptr) 531 ]]) 532]]) 533 534m4_ifdef( [[M4_YY_NOT_IN_HEADER]], 535[[ 536/* Return all but the first "n" matched characters back to the input stream. */ 537#define yyless(n) \ 538 do \ 539 { \ 540 /* Undo effects of setting up yytext. */ \ 541 int yyless_macro_arg = (n); \ 542 YY_LESS_LINENO(yyless_macro_arg);\ 543 *yy_cp = YY_G(yy_hold_char); \ 544 YY_RESTORE_YY_MORE_OFFSET \ 545 YY_G(yy_c_buf_p) = yy_cp = yy_bp + yyless_macro_arg - YY_MORE_ADJ; \ 546 YY_DO_BEFORE_ACTION; /* set up yytext again */ \ 547 } \ 548 while ( 0 ) 549]]) 550 551m4_ifdef( [[M4_YY_NOT_IN_HEADER]], 552[[ 553#define unput(c) yyunput( c, YY_G(yytext_ptr) M4_YY_CALL_LAST_ARG ) 554]]) 555 556#ifndef YY_STRUCT_YY_BUFFER_STATE 557#define YY_STRUCT_YY_BUFFER_STATE 558struct yy_buffer_state 559 { 560%if-c-only 561 FILE *yy_input_file; 562%endif 563 564%if-c++-only 565 std::streambuf* yy_input_file; 566%endif 567 568 569 char *yy_ch_buf; /* input buffer */ 570 char *yy_buf_pos; /* current position in input buffer */ 571 572 /* Size of input buffer in bytes, not including room for EOB 573 * characters. 574 */ 575 yy_size_t yy_buf_size; 576 577 /* Number of characters read into yy_ch_buf, not including EOB 578 * characters. 579 */ 580 yy_size_t yy_n_chars; 581 582 /* Whether we "own" the buffer - i.e., we know we created it, 583 * and can realloc() it to grow it, and should free() it to 584 * delete it. 585 */ 586 int yy_is_our_buffer; 587 588 /* Whether this is an "interactive" input source; if so, and 589 * if we're using stdio for input, then we want to use getc() 590 * instead of fread(), to make sure we stop fetching input after 591 * each newline. 592 */ 593 int yy_is_interactive; 594 595 /* Whether we're considered to be at the beginning of a line. 596 * If so, '^' rules will be active on the next match, otherwise 597 * not. 598 */ 599 int yy_at_bol; 600 601 int yy_bs_lineno; /**< The line count. */ 602 int yy_bs_column; /**< The column count. */ 603 604 605 /* Whether to try to fill the input buffer when we reach the 606 * end of it. 607 */ 608 int yy_fill_buffer; 609 610 int yy_buffer_status; 611m4_ifdef( [[M4_YY_NOT_IN_HEADER]], 612[[ 613#define YY_BUFFER_NEW 0 614#define YY_BUFFER_NORMAL 1 615 /* When an EOF's been seen but there's still some text to process 616 * then we mark the buffer as YY_EOF_PENDING, to indicate that we 617 * shouldn't try reading from the input source any more. We might 618 * still have a bunch of tokens to match, though, because of 619 * possible backing-up. 620 * 621 * When we actually see the EOF, we change the status to "new" 622 * (via yyrestart()), so that the user can continue scanning by 623 * just pointing yyin at a new input file. 624 */ 625#define YY_BUFFER_EOF_PENDING 2 626]]) 627 }; 628#endif /* !YY_STRUCT_YY_BUFFER_STATE */ 629 630%if-c-only Standard (non-C++) definition 631%not-for-header 632%if-not-reentrant 633 634/* Stack of input buffers. */ 635static size_t yy_buffer_stack_top = 0; /**< index of top of stack. */ 636static size_t yy_buffer_stack_max = 0; /**< capacity of stack. */ 637static YY_BUFFER_STATE * yy_buffer_stack = 0; /**< Stack as an array. */ 638%endif 639%ok-for-header 640%endif 641 642m4_ifdef( [[M4_YY_NOT_IN_HEADER]], 643[[ 644/* We provide macros for accessing buffer states in case in the 645 * future we want to put the buffer states in a more general 646 * "scanner state". 647 * 648 * Returns the top of the stack, or NULL. 649 */ 650#define YY_CURRENT_BUFFER ( YY_G(yy_buffer_stack) \ 651 ? YY_G(yy_buffer_stack)[YY_G(yy_buffer_stack_top)] \ 652 : NULL) 653]]) 654 655m4_ifdef( [[M4_YY_NOT_IN_HEADER]], 656[[ 657/* Same as previous macro, but useful when we know that the buffer stack is not 658 * NULL or when we need an lvalue. For internal use only. 659 */ 660#define YY_CURRENT_BUFFER_LVALUE YY_G(yy_buffer_stack)[YY_G(yy_buffer_stack_top)] 661]]) 662 663%if-c-only Standard (non-C++) definition 664 665%if-not-reentrant 666%not-for-header 667/* yy_hold_char holds the character lost when yytext is formed. */ 668static char yy_hold_char; 669static yy_size_t yy_n_chars; /* number of characters read into yy_ch_buf */ 670yy_size_t yyleng; 671 672/* Points to current character in buffer. */ 673static char *yy_c_buf_p = (char *) 0; 674static int yy_init = 0; /* whether we need to initialize */ 675static int yy_start = 0; /* start state number */ 676 677/* Flag which is used to allow yywrap()'s to do buffer switches 678 * instead of setting up a fresh yyin. A bit of a hack ... 679 */ 680static int yy_did_buffer_switch_on_eof; 681%ok-for-header 682%endif 683 684void yyrestart M4_YY_PARAMS( FILE *input_file M4_YY_PROTO_LAST_ARG ); 685void yy_switch_to_buffer M4_YY_PARAMS( YY_BUFFER_STATE new_buffer M4_YY_PROTO_LAST_ARG ); 686YY_BUFFER_STATE yy_create_buffer M4_YY_PARAMS( FILE *file, int size M4_YY_PROTO_LAST_ARG ); 687void yy_delete_buffer M4_YY_PARAMS( YY_BUFFER_STATE b M4_YY_PROTO_LAST_ARG ); 688void yy_flush_buffer M4_YY_PARAMS( YY_BUFFER_STATE b M4_YY_PROTO_LAST_ARG ); 689void yypush_buffer_state M4_YY_PARAMS( YY_BUFFER_STATE new_buffer M4_YY_PROTO_LAST_ARG ); 690void yypop_buffer_state M4_YY_PARAMS( M4_YY_PROTO_ONLY_ARG ); 691 692m4_ifdef( [[M4_YY_NOT_IN_HEADER]], 693[[ 694static void yyensure_buffer_stack M4_YY_PARAMS( M4_YY_PROTO_ONLY_ARG ); 695static void yy_load_buffer_state M4_YY_PARAMS( M4_YY_PROTO_ONLY_ARG ); 696static void yy_init_buffer M4_YY_PARAMS( YY_BUFFER_STATE b, FILE *file M4_YY_PROTO_LAST_ARG ); 697]]) 698 699m4_ifdef( [[M4_YY_NOT_IN_HEADER]], 700[[ 701#define YY_FLUSH_BUFFER yy_flush_buffer( YY_CURRENT_BUFFER M4_YY_CALL_LAST_ARG) 702]]) 703 704YY_BUFFER_STATE yy_scan_buffer M4_YY_PARAMS( char *base, yy_size_t size M4_YY_PROTO_LAST_ARG ); 705YY_BUFFER_STATE yy_scan_string M4_YY_PARAMS( yyconst char *yy_str M4_YY_PROTO_LAST_ARG ); 706YY_BUFFER_STATE yy_scan_bytes M4_YY_PARAMS( yyconst char *bytes, yy_size_t len M4_YY_PROTO_LAST_ARG ); 707 708%endif 709 710void *yyalloc M4_YY_PARAMS( yy_size_t M4_YY_PROTO_LAST_ARG ); 711void *yyrealloc M4_YY_PARAMS( void *, yy_size_t M4_YY_PROTO_LAST_ARG ); 712void yyfree M4_YY_PARAMS( void * M4_YY_PROTO_LAST_ARG ); 713 714m4_ifdef( [[M4_YY_NOT_IN_HEADER]], 715[[ 716#define yy_new_buffer yy_create_buffer 717]]) 718 719m4_ifdef( [[M4_YY_NOT_IN_HEADER]], 720[[ 721#define yy_set_interactive(is_interactive) \ 722 { \ 723 if ( ! YY_CURRENT_BUFFER ){ \ 724 yyensure_buffer_stack (M4_YY_CALL_ONLY_ARG); \ 725 YY_CURRENT_BUFFER_LVALUE = \ 726 yy_create_buffer( yyin, YY_BUF_SIZE M4_YY_CALL_LAST_ARG); \ 727 } \ 728 YY_CURRENT_BUFFER_LVALUE->yy_is_interactive = is_interactive; \ 729 } 730]]) 731 732m4_ifdef( [[M4_YY_NOT_IN_HEADER]], 733[[ 734#define yy_set_bol(at_bol) \ 735 { \ 736 if ( ! YY_CURRENT_BUFFER ){\ 737 yyensure_buffer_stack (M4_YY_CALL_ONLY_ARG); \ 738 YY_CURRENT_BUFFER_LVALUE = \ 739 yy_create_buffer( yyin, YY_BUF_SIZE M4_YY_CALL_LAST_ARG); \ 740 } \ 741 YY_CURRENT_BUFFER_LVALUE->yy_at_bol = at_bol; \ 742 } 743]]) 744 745m4_ifdef( [[M4_YY_NOT_IN_HEADER]], 746[[ 747#define YY_AT_BOL() (YY_CURRENT_BUFFER_LVALUE->yy_at_bol) 748]]) 749 750%% [1.0] yytext/yyin/yyout/yy_state_type/yylineno etc. def's & init go here 751 752m4_ifdef( [[M4_YY_NOT_IN_HEADER]], 753[[ 754%% [1.5] DFA 755]]) 756 757%if-c-only Standard (non-C++) definition 758 759m4_ifdef( [[M4_YY_NOT_IN_HEADER]], 760[[ 761static yy_state_type yy_get_previous_state M4_YY_PARAMS( M4_YY_PROTO_ONLY_ARG ); 762static yy_state_type yy_try_NUL_trans M4_YY_PARAMS( yy_state_type current_state M4_YY_PROTO_LAST_ARG); 763static int yy_get_next_buffer M4_YY_PARAMS( M4_YY_PROTO_ONLY_ARG ); 764#if defined(__GNUC__) && __GNUC__ >= 3 765__attribute__((__noreturn__)) 766#endif 767static void yy_fatal_error M4_YY_PARAMS( yyconst char msg[] M4_YY_PROTO_LAST_ARG ); 768]]) 769 770%endif 771 772m4_ifdef( [[M4_YY_NOT_IN_HEADER]], 773[[ 774/* Done after the current pattern has been matched and before the 775 * corresponding action - sets up yytext. 776 */ 777#define YY_DO_BEFORE_ACTION \ 778 YY_G(yytext_ptr) = yy_bp; \ 779%% [2.0] code to fiddle yytext and yyleng for yymore() goes here \ 780 YY_G(yy_hold_char) = *yy_cp; \ 781 *yy_cp = '\0'; \ 782%% [3.0] code to copy yytext_ptr to yytext[] goes here, if %array \ 783 YY_G(yy_c_buf_p) = yy_cp; 784]]) 785 786m4_ifdef( [[M4_YY_NOT_IN_HEADER]], 787[[ 788%% [4.0] data tables for the DFA and the user's section 1 definitions go here 789]]) 790 791m4_ifdef( [[M4_YY_IN_HEADER]], [[#ifdef YY_HEADER_EXPORT_START_CONDITIONS]]) 792M4_YY_SC_DEFS 793m4_ifdef( [[M4_YY_IN_HEADER]], [[#endif]]) 794 795m4_ifdef( [[M4_YY_NO_UNISTD_H]],, 796[[ 797#ifndef YY_NO_UNISTD_H 798/* Special case for "unistd.h", since it is non-ANSI. We include it way 799 * down here because we want the user's section 1 to have been scanned first. 800 * The user has a chance to override it with an option. 801 */ 802%if-c-only 803#include <unistd.h> 804%endif 805%if-c++-only 806#include <unistd.h> 807%endif 808#endif 809]]) 810 811m4_ifdef( [[M4_EXTRA_TYPE_DEFS]], 812[[ 813#define YY_EXTRA_TYPE M4_EXTRA_TYPE_DEFS 814]], 815[[ 816#ifndef YY_EXTRA_TYPE 817#define YY_EXTRA_TYPE void * 818#endif 819]] 820) 821 822%if-c-only Reentrant structure and macros (non-C++). 823%if-reentrant 824 825m4_ifdef( [[M4_YY_NOT_IN_HEADER]], 826[[ 827/* Holds the entire state of the reentrant scanner. */ 828struct yyguts_t 829 { 830 831 /* User-defined. Not touched by flex. */ 832 YY_EXTRA_TYPE yyextra_r; 833 834 /* The rest are the same as the globals declared in the non-reentrant scanner. */ 835 FILE *yyin_r, *yyout_r; 836 size_t yy_buffer_stack_top; /**< index of top of stack. */ 837 size_t yy_buffer_stack_max; /**< capacity of stack. */ 838 YY_BUFFER_STATE * yy_buffer_stack; /**< Stack as an array. */ 839 char yy_hold_char; 840 yy_size_t yy_n_chars; 841 yy_size_t yyleng_r; 842 char *yy_c_buf_p; 843 int yy_init; 844 int yy_start; 845 int yy_did_buffer_switch_on_eof; 846 int yy_start_stack_ptr; 847 int yy_start_stack_depth; 848 int *yy_start_stack; 849 yy_state_type yy_last_accepting_state; 850 char* yy_last_accepting_cpos; 851 852 int yylineno_r; 853 int yy_flex_debug_r; 854 855m4_ifdef( [[M4_YY_USES_REJECT]], 856[[ 857 yy_state_type *yy_state_buf; 858 yy_state_type *yy_state_ptr; 859 char *yy_full_match; 860 int yy_lp; 861 862 /* These are only needed for trailing context rules, 863 * but there's no conditional variable for that yet. */ 864 int yy_looking_for_trail_begin; 865 int yy_full_lp; 866 int *yy_full_state; 867]]) 868 869m4_ifdef( [[M4_YY_TEXT_IS_ARRAY]], 870[[ 871 char yytext_r[YYLMAX]; 872 char *yytext_ptr; 873 int yy_more_offset; 874 int yy_prev_more_offset; 875]], 876[[ 877 char *yytext_r; 878 int yy_more_flag; 879 int yy_more_len; 880]]) 881 882m4_ifdef( [[M4_YY_BISON_LVAL]], 883[[ 884 YYSTYPE * yylval_r; 885]]) 886 887m4_ifdef( [[<M4_YY_BISON_LLOC>]], 888[[ 889 YYLTYPE * yylloc_r; 890]]) 891 892 }; /* end struct yyguts_t */ 893]]) 894 895 896%if-c-only 897m4_ifdef( [[M4_YY_NOT_IN_HEADER]], 898[[ 899static int yy_init_globals M4_YY_PARAMS( M4_YY_PROTO_ONLY_ARG ); 900]]) 901%endif 902 903%if-reentrant 904 905m4_ifdef( [[M4_YY_NOT_IN_HEADER]], 906[[ 907 m4_ifdef( [[M4_YY_BISON_LVAL]], 908 [[ 909 /* This must go here because YYSTYPE and YYLTYPE are included 910 * from bison output in section 1.*/ 911 # define yylval YY_G(yylval_r) 912 ]]) 913 914 m4_ifdef( [[<M4_YY_BISON_LLOC>]], 915 [[ 916 # define yylloc YY_G(yylloc_r) 917 ]]) 918]]) 919 920int yylex_init M4_YY_PARAMS(yyscan_t* scanner); 921 922int yylex_init_extra M4_YY_PARAMS( YY_EXTRA_TYPE user_defined, yyscan_t* scanner); 923 924%endif 925 926%endif End reentrant structures and macros. 927 928/* Accessor methods to globals. 929 These are made visible to non-reentrant scanners for convenience. */ 930 931m4_ifdef( [[M4_YY_NO_DESTROY]],, 932[[ 933int yylex_destroy M4_YY_PARAMS( M4_YY_PROTO_ONLY_ARG ); 934]]) 935 936m4_ifdef( [[M4_YY_NO_GET_DEBUG]],, 937[[ 938int yyget_debug M4_YY_PARAMS( M4_YY_PROTO_ONLY_ARG ); 939]]) 940 941m4_ifdef( [[M4_YY_NO_SET_DEBUG]],, 942[[ 943void yyset_debug M4_YY_PARAMS( int debug_flag M4_YY_PROTO_LAST_ARG ); 944]]) 945 946m4_ifdef( [[M4_YY_NO_GET_EXTRA]],, 947[[ 948YY_EXTRA_TYPE yyget_extra M4_YY_PARAMS( M4_YY_PROTO_ONLY_ARG ); 949]]) 950 951m4_ifdef( [[M4_YY_NO_SET_EXTRA]],, 952[[ 953void yyset_extra M4_YY_PARAMS( YY_EXTRA_TYPE user_defined M4_YY_PROTO_LAST_ARG ); 954]]) 955 956m4_ifdef( [[M4_YY_NO_GET_IN]],, 957[[ 958FILE *yyget_in M4_YY_PARAMS( M4_YY_PROTO_ONLY_ARG ); 959]]) 960 961m4_ifdef( [[M4_YY_NO_SET_IN]],, 962[[ 963void yyset_in M4_YY_PARAMS( FILE * _in_str M4_YY_PROTO_LAST_ARG ); 964]]) 965 966m4_ifdef( [[M4_YY_NO_GET_OUT]],, 967[[ 968FILE *yyget_out M4_YY_PARAMS( M4_YY_PROTO_ONLY_ARG ); 969]]) 970 971m4_ifdef( [[M4_YY_NO_SET_OUT]],, 972[[ 973void yyset_out M4_YY_PARAMS( FILE * _out_str M4_YY_PROTO_LAST_ARG ); 974]]) 975 976m4_ifdef( [[M4_YY_NO_GET_LENG]],, 977[[ 978yy_size_t yyget_leng M4_YY_PARAMS( M4_YY_PROTO_ONLY_ARG ); 979]]) 980 981m4_ifdef( [[M4_YY_NO_GET_TEXT]],, 982[[ 983char *yyget_text M4_YY_PARAMS( M4_YY_PROTO_ONLY_ARG ); 984]]) 985 986m4_ifdef( [[M4_YY_NO_GET_LINENO]],, 987[[ 988int yyget_lineno M4_YY_PARAMS( M4_YY_PROTO_ONLY_ARG ); 989]]) 990 991m4_ifdef( [[M4_YY_NO_SET_LINENO]],, 992[[ 993void yyset_lineno M4_YY_PARAMS( int _line_number M4_YY_PROTO_LAST_ARG ); 994]]) 995 996m4_ifdef( [[M4_YY_REENTRANT]], 997[[ 998m4_ifdef( [[M4_YY_NO_GET_COLUMN]],, 999[[ 1000int yyget_column M4_YY_PARAMS( M4_YY_PROTO_ONLY_ARG ); 1001]]) 1002]]) 1003 1004m4_ifdef( [[M4_YY_REENTRANT]], 1005[[ 1006m4_ifdef( [[M4_YY_NO_SET_COLUMN]],, 1007[[ 1008void yyset_column M4_YY_PARAMS( int _column_no M4_YY_PROTO_LAST_ARG ); 1009]]) 1010]]) 1011 1012%if-bison-bridge 1013m4_ifdef( [[M4_YY_NO_GET_LVAL]],, 1014[[ 1015YYSTYPE * yyget_lval M4_YY_PARAMS( M4_YY_PROTO_ONLY_ARG ); 1016]]) 1017 1018void yyset_lval M4_YY_PARAMS( YYSTYPE * yylval_param M4_YY_PROTO_LAST_ARG ); 1019 1020m4_ifdef( [[<M4_YY_BISON_LLOC>]], 1021[[ 1022 m4_ifdef( [[M4_YY_NO_GET_LLOC]],, 1023 [[ 1024 YYLTYPE *yyget_lloc M4_YY_PARAMS( M4_YY_PROTO_ONLY_ARG ); 1025 ]]) 1026 1027 m4_ifdef( [[M4_YY_NO_SET_LLOC]],, 1028 [[ 1029 void yyset_lloc M4_YY_PARAMS( YYLTYPE * yylloc_param M4_YY_PROTO_LAST_ARG ); 1030 ]]) 1031]]) 1032%endif 1033 1034/* Macros after this point can all be overridden by user definitions in 1035 * section 1. 1036 */ 1037 1038#ifndef YY_SKIP_YYWRAP 1039#ifdef __cplusplus 1040extern "C" int yywrap M4_YY_PARAMS( M4_YY_PROTO_ONLY_ARG ); 1041#else 1042extern int yywrap M4_YY_PARAMS( M4_YY_PROTO_ONLY_ARG ); 1043#endif 1044#endif 1045 1046%not-for-header 1047#ifndef YY_NO_UNPUT 1048 m4_ifdef( [[M4_YY_NO_UNPUT]],, 1049 [[ 1050 static void yyunput M4_YY_PARAMS( int c, char *buf_ptr M4_YY_PROTO_LAST_ARG); 1051 ]]) 1052#endif 1053%ok-for-header 1054%endif 1055 1056#ifndef yytext_ptr 1057static void yy_flex_strncpy M4_YY_PARAMS( char *, yyconst char *, int M4_YY_PROTO_LAST_ARG); 1058#endif 1059 1060#ifdef YY_NEED_STRLEN 1061static int yy_flex_strlen M4_YY_PARAMS( yyconst char * M4_YY_PROTO_LAST_ARG); 1062#endif 1063 1064#ifndef YY_NO_INPUT 1065%if-c-only Standard (non-C++) definition 1066%not-for-header 1067#ifdef __cplusplus 1068static int yyinput M4_YY_PARAMS( M4_YY_PROTO_ONLY_ARG ); 1069#else 1070static int input M4_YY_PARAMS( M4_YY_PROTO_ONLY_ARG ); 1071#endif 1072%ok-for-header 1073%endif 1074#endif 1075 1076 1077%if-c-only 1078%# TODO: This is messy. 1079m4_ifdef( [[M4_YY_STACK_USED]], 1080[[ 1081 1082m4_ifdef( [[M4_YY_NOT_REENTRANT]], 1083[[ 1084 m4_ifdef( [[M4_YY_NOT_IN_HEADER]], 1085 [[ 1086 static int yy_start_stack_ptr = 0; 1087 static int yy_start_stack_depth = 0; 1088 static int *yy_start_stack = NULL; 1089 ]]) 1090]]) 1091 1092m4_ifdef( [[M4_YY_NOT_IN_HEADER]], 1093[[ 1094 m4_ifdef( [[M4_YY_NO_PUSH_STATE]],, 1095 [[ 1096 static void yy_push_state M4_YY_PARAMS( int _new_state M4_YY_PROTO_LAST_ARG); 1097 ]]) 1098 m4_ifdef( [[M4_YY_NO_POP_STATE]],, 1099 [[ 1100 static void yy_pop_state M4_YY_PARAMS( M4_YY_PROTO_ONLY_ARG ); 1101 ]]) 1102 m4_ifdef( [[M4_YY_NO_TOP_STATE]],, 1103 [[ 1104 static int yy_top_state M4_YY_PARAMS( M4_YY_PROTO_ONLY_ARG ); 1105 ]]) 1106]]) 1107 1108]], 1109[[ 1110m4_define( [[M4_YY_NO_PUSH_STATE]]) 1111m4_define( [[M4_YY_NO_POP_STATE]]) 1112m4_define( [[M4_YY_NO_TOP_STATE]]) 1113]]) 1114%endif 1115 1116/* Amount of stuff to slurp up with each read. */ 1117#ifndef YY_READ_BUF_SIZE 1118#ifdef __ia64__ 1119/* On IA-64, the buffer size is 16k, not 8k */ 1120#define YY_READ_BUF_SIZE 16384 1121#else 1122#define YY_READ_BUF_SIZE 8192 1123#endif /* __ia64__ */ 1124#endif 1125 1126m4_ifdef( [[M4_YY_NOT_IN_HEADER]], 1127[[ 1128/* Copy whatever the last rule matched to the standard output. */ 1129#ifndef ECHO 1130%if-c-only Standard (non-C++) definition 1131/* This used to be an fputs(), but since the string might contain NUL's, 1132 * we now use fwrite(). 1133 */ 1134#define ECHO do { if (fwrite( yytext, yyleng, 1, yyout )) {} } while (0) 1135%endif 1136%if-c++-only C++ definition 1137#define ECHO LexerOutput( yytext, yyleng ) 1138%endif 1139#endif 1140]]) 1141 1142m4_ifdef( [[M4_YY_NOT_IN_HEADER]], 1143[[ 1144/* Gets input and stuffs it into "buf". number of characters read, or YY_NULL, 1145 * is returned in "result". 1146 */ 1147#ifndef YY_INPUT 1148#define YY_INPUT(buf,result,max_size) \ 1149%% [5.0] fread()/read() definition of YY_INPUT goes here unless we're doing C++ \ 1150\ 1151%if-c++-only C++ definition \ 1152 if ( (int)(result = LexerInput( (char *) buf, max_size )) < 0 ) \ 1153 YY_FATAL_ERROR( "input in flex scanner failed" ); 1154%endif 1155 1156#endif 1157]]) 1158 1159m4_ifdef( [[M4_YY_NOT_IN_HEADER]], 1160[[ 1161/* No semi-colon after return; correct usage is to write "yyterminate();" - 1162 * we don't want an extra ';' after the "return" because that will cause 1163 * some compilers to complain about unreachable statements. 1164 */ 1165#ifndef yyterminate 1166#define yyterminate() return YY_NULL 1167#endif 1168]]) 1169 1170/* Number of entries by which start-condition stack grows. */ 1171#ifndef YY_START_STACK_INCR 1172#define YY_START_STACK_INCR 25 1173#endif 1174 1175m4_ifdef( [[M4_YY_NOT_IN_HEADER]], 1176[[ 1177/* Report a fatal error. */ 1178#ifndef YY_FATAL_ERROR 1179%if-c-only 1180#define YY_FATAL_ERROR(msg) yy_fatal_error( msg M4_YY_CALL_LAST_ARG) 1181%endif 1182%if-c++-only 1183#define YY_FATAL_ERROR(msg) LexerError( msg ) 1184%endif 1185#endif 1186]]) 1187 1188%if-tables-serialization structures and prototypes 1189m4preproc_include(`tables_shared.h') 1190 1191/* Load the DFA tables from the given stream. */ 1192int yytables_fload M4_YY_PARAMS(FILE * fp M4_YY_PROTO_LAST_ARG); 1193 1194/* Unload the tables from memory. */ 1195int yytables_destroy M4_YY_PARAMS(M4_YY_PROTO_ONLY_ARG); 1196%not-for-header 1197 1198/** Describes a mapping from a serialized table id to its deserialized state in 1199 * this scanner. This is the bridge between our "generic" deserialization code 1200 * and the specifics of this scanner. 1201 */ 1202struct yytbl_dmap { 1203 enum yytbl_id dm_id;/**< table identifier */ 1204 void **dm_arr; /**< address of pointer to store the deserialized table. */ 1205 size_t dm_sz; /**< local sizeof() each element in table. */ 1206}; 1207 1208/** A {0,0,0}-terminated list of structs, forming the map */ 1209static struct yytbl_dmap yydmap[] = 1210{ 1211%tables-yydmap generated elements 1212 {0,0,0} 1213}; 1214 1215/** A tables-reader object to maintain some state in the read. */ 1216struct yytbl_reader { 1217 FILE * fp; /**< input stream */ 1218 flex_uint32_t bread; /**< bytes read since beginning of current tableset */ 1219}; 1220 1221%endif 1222/* end tables serialization structures and prototypes */ 1223 1224%ok-for-header 1225 1226/* Default declaration of generated scanner - a define so the user can 1227 * easily add parameters. 1228 */ 1229#ifndef YY_DECL 1230#define YY_DECL_IS_OURS 1 1231%if-c-only Standard (non-C++) definition 1232 1233 1234m4_define( [[M4_YY_LEX_PROTO]], [[M4_YY_PARAMS(M4_YY_PROTO_ONLY_ARG)]]) 1235m4_define( [[M4_YY_LEX_DECLARATION]], [[YYFARGS0(void)]]) 1236 1237m4_ifdef( [[M4_YY_BISON_LVAL]], 1238[[ 1239 m4_dnl The bison pure parser is used. Redefine yylex to 1240 m4_dnl accept the lval parameter. 1241 1242 m4_define( [[M4_YY_LEX_PROTO]], [[\]] 1243 [[M4_YY_PARAMS(YYSTYPE * yylval_param M4_YY_PROTO_LAST_ARG)]]) 1244 m4_define( [[M4_YY_LEX_DECLARATION]], [[\]] 1245 [[YYFARGS1(YYSTYPE *,yylval_param)]]) 1246]]) 1247 1248m4_ifdef( [[<M4_YY_BISON_LLOC>]], 1249[[ 1250 m4_dnl Locations are used. yylex should also accept the ylloc parameter. 1251 1252 m4_define( [[M4_YY_LEX_PROTO]], [[\]] 1253 [[M4_YY_PARAMS(YYSTYPE * yylval_param, YYLTYPE * yylloc_param M4_YY_PROTO_LAST_ARG)]]) 1254 m4_define( [[M4_YY_LEX_DECLARATION]], [[\]] 1255 [[YYFARGS2(YYSTYPE *,yylval_param, YYLTYPE *,yylloc_param)]]) 1256]]) 1257 1258extern int yylex M4_YY_LEX_PROTO; 1259 1260#define YY_DECL int yylex M4_YY_LEX_DECLARATION 1261%endif 1262%if-c++-only C++ definition 1263#define YY_DECL int yyFlexLexer::yylex() 1264%endif 1265#endif /* !YY_DECL */ 1266 1267m4_ifdef( [[M4_YY_NOT_IN_HEADER]], 1268[[ 1269/* Code executed at the beginning of each rule, after yytext and yyleng 1270 * have been set up. 1271 */ 1272#ifndef YY_USER_ACTION 1273#define YY_USER_ACTION 1274#endif 1275]]) 1276 1277m4_ifdef( [[M4_YY_NOT_IN_HEADER]], 1278[[ 1279/* Code executed at the end of each rule. */ 1280#ifndef YY_BREAK 1281#define YY_BREAK /*LINTED*/break; 1282#endif 1283]]) 1284 1285m4_ifdef( [[M4_YY_NOT_IN_HEADER]], 1286[[ 1287%% [6.0] YY_RULE_SETUP definition goes here 1288]]) 1289 1290%not-for-header 1291/** The main scanner function which does all the work. 1292 */ 1293YY_DECL 1294{ 1295 yy_state_type yy_current_state; 1296 char *yy_cp, *yy_bp; 1297 int yy_act; 1298 M4_YY_DECL_GUTS_VAR(); 1299 1300m4_ifdef( [[M4_YY_NOT_REENTRANT]], 1301[[ 1302 m4_ifdef( [[M4_YY_BISON_LVAL]], 1303 [[ 1304 YYSTYPE * yylval; 1305 ]]) 1306 m4_ifdef( [[<M4_YY_BISON_LLOC>]], 1307 [[ 1308 YYLTYPE * yylloc; 1309 ]]) 1310]]) 1311 1312m4_ifdef( [[M4_YY_BISON_LVAL]], 1313[[ 1314 yylval = yylval_param; 1315]]) 1316 1317m4_ifdef( [[<M4_YY_BISON_LLOC>]], 1318[[ 1319 yylloc = yylloc_param; 1320]]) 1321 1322 if ( !YY_G(yy_init) ) 1323 { 1324 YY_G(yy_init) = 1; 1325 1326#ifdef YY_USER_INIT 1327 YY_USER_INIT; 1328#endif 1329 1330m4_ifdef( [[M4_YY_USES_REJECT]], 1331[[ 1332 /* Create the reject buffer large enough to save one state per allowed character. */ 1333 if ( ! YY_G(yy_state_buf) ) 1334 YY_G(yy_state_buf) = (yy_state_type *)yyalloc(YY_STATE_BUF_SIZE M4_YY_CALL_LAST_ARG); 1335 if ( ! YY_G(yy_state_buf) ) 1336 YY_FATAL_ERROR( "out of dynamic memory in yylex()" ); 1337]]) 1338 1339 if ( ! YY_G(yy_start) ) 1340 YY_G(yy_start) = 1; /* first start state */ 1341 1342 if ( ! yyin ) 1343%if-c-only 1344 yyin = stdin; 1345%endif 1346%if-c++-only 1347 yyin.rdbuf(std::cin.rdbuf()); 1348%endif 1349 1350 if ( ! yyout ) 1351%if-c-only 1352 yyout = stdout; 1353%endif 1354%if-c++-only 1355 yyout.rdbuf(std::cout.rdbuf()); 1356%endif 1357 1358 if ( ! YY_CURRENT_BUFFER ) { 1359 yyensure_buffer_stack (M4_YY_CALL_ONLY_ARG); 1360 YY_CURRENT_BUFFER_LVALUE = 1361 yy_create_buffer( yyin, YY_BUF_SIZE M4_YY_CALL_LAST_ARG); 1362 } 1363 1364 yy_load_buffer_state( M4_YY_CALL_ONLY_ARG ); 1365 } 1366 1367 { 1368%% [7.0] user's declarations go here 1369 1370 while ( /*CONSTCOND*/1 ) /* loops until end-of-file is reached */ 1371 { 1372%% [8.0] yymore()-related code goes here 1373 yy_cp = YY_G(yy_c_buf_p); 1374 1375 /* Support of yytext. */ 1376 *yy_cp = YY_G(yy_hold_char); 1377 1378 /* yy_bp points to the position in yy_ch_buf of the start of 1379 * the current run. 1380 */ 1381 yy_bp = yy_cp; 1382 1383%% [9.0] code to set up and find next match goes here 1384 1385yy_find_action: 1386%% [10.0] code to find the action number goes here 1387 1388 YY_DO_BEFORE_ACTION; 1389 1390%% [11.0] code for yylineno update goes here 1391 1392do_action: /* This label is used only to access EOF actions. */ 1393 1394%% [12.0] debug code goes here 1395 1396 switch ( yy_act ) 1397 { /* beginning of action switch */ 1398%% [13.0] actions go here 1399 1400 case YY_END_OF_BUFFER: 1401 { 1402 /* Amount of text matched not including the EOB char. */ 1403 int yy_amount_of_matched_text = (int) (yy_cp - YY_G(yytext_ptr)) - 1; 1404 1405 /* Undo the effects of YY_DO_BEFORE_ACTION. */ 1406 *yy_cp = YY_G(yy_hold_char); 1407 YY_RESTORE_YY_MORE_OFFSET 1408 1409 if ( YY_CURRENT_BUFFER_LVALUE->yy_buffer_status == YY_BUFFER_NEW ) 1410 { 1411 /* We're scanning a new file or input source. It's 1412 * possible that this happened because the user 1413 * just pointed yyin at a new source and called 1414 * yylex(). If so, then we have to assure 1415 * consistency between YY_CURRENT_BUFFER and our 1416 * globals. Here is the right place to do so, because 1417 * this is the first action (other than possibly a 1418 * back-up) that will match for the new input source. 1419 */ 1420 YY_G(yy_n_chars) = YY_CURRENT_BUFFER_LVALUE->yy_n_chars; 1421%if-c-only 1422 YY_CURRENT_BUFFER_LVALUE->yy_input_file = yyin; 1423%endif 1424%if-c++-only 1425 YY_CURRENT_BUFFER_LVALUE->yy_input_file = yyin.rdbuf(); 1426%endif 1427 YY_CURRENT_BUFFER_LVALUE->yy_buffer_status = YY_BUFFER_NORMAL; 1428 } 1429 1430 /* Note that here we test for yy_c_buf_p "<=" to the position 1431 * of the first EOB in the buffer, since yy_c_buf_p will 1432 * already have been incremented past the NUL character 1433 * (since all states make transitions on EOB to the 1434 * end-of-buffer state). Contrast this with the test 1435 * in input(). 1436 */ 1437 if ( YY_G(yy_c_buf_p) <= &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[YY_G(yy_n_chars)] ) 1438 { /* This was really a NUL. */ 1439 yy_state_type yy_next_state; 1440 1441 YY_G(yy_c_buf_p) = YY_G(yytext_ptr) + yy_amount_of_matched_text; 1442 1443 yy_current_state = yy_get_previous_state( M4_YY_CALL_ONLY_ARG ); 1444 1445 /* Okay, we're now positioned to make the NUL 1446 * transition. We couldn't have 1447 * yy_get_previous_state() go ahead and do it 1448 * for us because it doesn't know how to deal 1449 * with the possibility of jamming (and we don't 1450 * want to build jamming into it because then it 1451 * will run more slowly). 1452 */ 1453 1454 yy_next_state = yy_try_NUL_trans( yy_current_state M4_YY_CALL_LAST_ARG); 1455 1456 yy_bp = YY_G(yytext_ptr) + YY_MORE_ADJ; 1457 1458 if ( yy_next_state ) 1459 { 1460 /* Consume the NUL. */ 1461 yy_cp = ++YY_G(yy_c_buf_p); 1462 yy_current_state = yy_next_state; 1463 goto yy_match; 1464 } 1465 1466 else 1467 { 1468%% [14.0] code to do back-up for compressed tables and set up yy_cp goes here 1469 goto yy_find_action; 1470 } 1471 } 1472 1473 else switch ( yy_get_next_buffer( M4_YY_CALL_ONLY_ARG ) ) 1474 { 1475 case EOB_ACT_END_OF_FILE: 1476 { 1477 YY_G(yy_did_buffer_switch_on_eof) = 0; 1478 1479 if ( yywrap( M4_YY_CALL_ONLY_ARG ) ) 1480 { 1481 /* Note: because we've taken care in 1482 * yy_get_next_buffer() to have set up 1483 * yytext, 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_G(yy_c_buf_p) = YY_G(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_G(yy_did_buffer_switch_on_eof) ) 1499 YY_NEW_FILE; 1500 } 1501 break; 1502 } 1503 1504 case EOB_ACT_CONTINUE_SCAN: 1505 YY_G(yy_c_buf_p) = 1506 YY_G(yytext_ptr) + yy_amount_of_matched_text; 1507 1508 yy_current_state = yy_get_previous_state( M4_YY_CALL_ONLY_ARG ); 1509 1510 yy_cp = YY_G(yy_c_buf_p); 1511 yy_bp = YY_G(yytext_ptr) + YY_MORE_ADJ; 1512 goto yy_match; 1513 1514 case EOB_ACT_LAST_MATCH: 1515 YY_G(yy_c_buf_p) = 1516 &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[YY_G(yy_n_chars)]; 1517 1518 yy_current_state = yy_get_previous_state( M4_YY_CALL_ONLY_ARG ); 1519 1520 yy_cp = YY_G(yy_c_buf_p); 1521 yy_bp = YY_G(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 user's declarations */ 1533} /* end of yylex */ 1534%ok-for-header 1535 1536%if-c++-only 1537%not-for-header 1538/* The contents of this function are C++ specific, so the YY_G macro is not used. 1539 * This constructor simply maintains backward compatibility. 1540 * DEPRECATED 1541 */ 1542yyFlexLexer::yyFlexLexer( FLEX_STD istream* arg_yyin, FLEX_STD ostream* arg_yyout ): 1543 yyin(arg_yyin ? arg_yyin->rdbuf() : std::cin.rdbuf()), 1544 yyout(arg_yyout ? arg_yyout->rdbuf() : std::cout.rdbuf()) 1545{ 1546 ctor_common(); 1547} 1548 1549/* The contents of this function are C++ specific, so the YY_G macro is not used. 1550 */ 1551yyFlexLexer::yyFlexLexer( std::istream& arg_yyin, std::ostream& arg_yyout ): 1552 yyin(arg_yyin.rdbuf()), 1553 yyout(arg_yyout.rdbuf()) 1554{ 1555 ctor_common(); 1556} 1557 1558/* The contents of this function are C++ specific, so the YY_G macro is not used. 1559 */ 1560void yyFlexLexer::ctor_common() 1561{ 1562 yy_c_buf_p = 0; 1563 yy_init = 0; 1564 yy_start = 0; 1565 yy_flex_debug = 0; 1566 yylineno = 1; // this will only get updated if %option yylineno 1567 1568 yy_did_buffer_switch_on_eof = 0; 1569 1570 yy_looking_for_trail_begin = 0; 1571 yy_more_flag = 0; 1572 yy_more_len = 0; 1573 yy_more_offset = yy_prev_more_offset = 0; 1574 1575 yy_start_stack_ptr = yy_start_stack_depth = 0; 1576 yy_start_stack = NULL; 1577 1578 yy_buffer_stack = 0; 1579 yy_buffer_stack_top = 0; 1580 yy_buffer_stack_max = 0; 1581 1582 1583m4_ifdef( [[M4_YY_USES_REJECT]], 1584[[ 1585 yy_state_buf = new yy_state_type[YY_STATE_BUF_SIZE]; 1586]], 1587[[ 1588 yy_state_buf = 0; 1589]]) 1590} 1591 1592/* The contents of this function are C++ specific, so the YY_G macro is not used. 1593 */ 1594yyFlexLexer::~yyFlexLexer() 1595{ 1596 delete [] yy_state_buf; 1597 yyfree( yy_start_stack M4_YY_CALL_LAST_ARG ); 1598 yy_delete_buffer( YY_CURRENT_BUFFER M4_YY_CALL_LAST_ARG); 1599 yyfree( yy_buffer_stack M4_YY_CALL_LAST_ARG ); 1600} 1601 1602/* The contents of this function are C++ specific, so the YY_G macro is not used. 1603 */ 1604void yyFlexLexer::switch_streams( std::istream& new_in, std::ostream& new_out ) 1605{ 1606 // was if( new_in ) 1607 yy_delete_buffer( YY_CURRENT_BUFFER M4_YY_CALL_LAST_ARG); 1608 yy_switch_to_buffer( yy_create_buffer( new_in, YY_BUF_SIZE M4_YY_CALL_LAST_ARG) M4_YY_CALL_LAST_ARG); 1609 1610 // was if( new_out ) 1611 yyout.rdbuf(new_out.rdbuf()); 1612} 1613 1614/* The contents of this function are C++ specific, so the YY_G macro is not used. 1615 */ 1616void yyFlexLexer::switch_streams( std::istream* new_in, std::ostream* new_out ) 1617{ 1618 if( ! new_in ) { 1619 new_in = &yyin; 1620 } 1621 1622 if ( ! new_out ) { 1623 new_out = &yyout; 1624 } 1625 1626 switch_streams(*new_in, *new_out); 1627} 1628 1629#ifdef YY_INTERACTIVE 1630int yyFlexLexer::LexerInput( char* buf, int /* max_size */ ) 1631#else 1632int yyFlexLexer::LexerInput( char* buf, int max_size ) 1633#endif 1634{ 1635 if ( yyin.eof() || yyin.fail() ) 1636 return 0; 1637 1638#ifdef YY_INTERACTIVE 1639 yyin.get( buf[0] ); 1640 1641 if ( yyin.eof() ) 1642 return 0; 1643 1644 if ( yyin.bad() ) 1645 return -1; 1646 1647 return 1; 1648 1649#else 1650 (void) yyin.read( buf, max_size ); 1651 1652 if ( yyin.bad() ) 1653 return -1; 1654 else 1655 return yyin.gcount(); 1656#endif 1657} 1658 1659void yyFlexLexer::LexerOutput( const char* buf, int size ) 1660{ 1661 (void) yyout.write( buf, size ); 1662} 1663%ok-for-header 1664%endif 1665 1666m4_ifdef( [[M4_YY_NOT_IN_HEADER]], 1667[[ 1668/* yy_get_next_buffer - try to read in a new buffer 1669 * 1670 * Returns a code representing an action: 1671 * EOB_ACT_LAST_MATCH - 1672 * EOB_ACT_CONTINUE_SCAN - continue scanning from current position 1673 * EOB_ACT_END_OF_FILE - end of file 1674 */ 1675%if-c-only 1676static int yy_get_next_buffer YYFARGS0(void) 1677%endif 1678%if-c++-only 1679int yyFlexLexer::yy_get_next_buffer() 1680%endif 1681{ 1682 M4_YY_DECL_GUTS_VAR(); 1683 char *dest = YY_CURRENT_BUFFER_LVALUE->yy_ch_buf; 1684 char *source = YY_G(yytext_ptr); 1685 yy_size_t number_to_move, i; 1686 int ret_val; 1687 1688 if ( YY_G(yy_c_buf_p) > &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[YY_G(yy_n_chars) + 1] ) 1689 YY_FATAL_ERROR( 1690 "fatal flex scanner internal error--end of buffer missed" ); 1691 1692 if ( YY_CURRENT_BUFFER_LVALUE->yy_fill_buffer == 0 ) 1693 { /* Don't try to fill the buffer, so this is an EOF. */ 1694 if ( YY_G(yy_c_buf_p) - YY_G(yytext_ptr) - YY_MORE_ADJ == 1 ) 1695 { 1696 /* We matched a single character, the EOB, so 1697 * treat this as a final EOF. 1698 */ 1699 return EOB_ACT_END_OF_FILE; 1700 } 1701 1702 else 1703 { 1704 /* We matched some text prior to the EOB, first 1705 * process it. 1706 */ 1707 return EOB_ACT_LAST_MATCH; 1708 } 1709 } 1710 1711 /* Try to read more data. */ 1712 1713 /* First move last chars to start of buffer. */ 1714 number_to_move = (yy_size_t) (YY_G(yy_c_buf_p) - YY_G(yytext_ptr)) - 1; 1715 1716 for ( i = 0; i < number_to_move; ++i ) 1717 *(dest++) = *(source++); 1718 1719 if ( YY_CURRENT_BUFFER_LVALUE->yy_buffer_status == YY_BUFFER_EOF_PENDING ) 1720 /* don't do the read, it's not guaranteed to return an EOF, 1721 * just force an EOF 1722 */ 1723 YY_CURRENT_BUFFER_LVALUE->yy_n_chars = YY_G(yy_n_chars) = 0; 1724 1725 else 1726 { 1727 yy_size_t num_to_read = 1728 YY_CURRENT_BUFFER_LVALUE->yy_buf_size - number_to_move - 1; 1729 1730 while ( num_to_read <= 0 ) 1731 { /* Not enough room in the buffer - grow it. */ 1732m4_ifdef( [[M4_YY_USES_REJECT]], 1733[[ 1734 YY_FATAL_ERROR( 1735"input buffer overflow, can't enlarge buffer because scanner uses REJECT" ); 1736]], 1737[[ 1738 /* just a shorter name for the current buffer */ 1739 YY_BUFFER_STATE b = YY_CURRENT_BUFFER_LVALUE; 1740 1741 int yy_c_buf_p_offset = 1742 (int) (YY_G(yy_c_buf_p) - b->yy_ch_buf); 1743 1744 if ( b->yy_is_our_buffer ) 1745 { 1746 yy_size_t new_size = b->yy_buf_size * 2; 1747 1748 if ( new_size <= 0 ) 1749 b->yy_buf_size += b->yy_buf_size / 8; 1750 else 1751 b->yy_buf_size *= 2; 1752 1753 b->yy_ch_buf = (char *) 1754 /* Include room in for 2 EOB chars. */ 1755 yyrealloc( (void *) b->yy_ch_buf, 1756 b->yy_buf_size + 2 M4_YY_CALL_LAST_ARG ); 1757 } 1758 else 1759 /* Can't grow it, we don't own it. */ 1760 b->yy_ch_buf = 0; 1761 1762 if ( ! b->yy_ch_buf ) 1763 YY_FATAL_ERROR( 1764 "fatal error - scanner input buffer overflow" ); 1765 1766 YY_G(yy_c_buf_p) = &b->yy_ch_buf[yy_c_buf_p_offset]; 1767 1768 num_to_read = YY_CURRENT_BUFFER_LVALUE->yy_buf_size - 1769 number_to_move - 1; 1770]]) 1771 } 1772 1773 if ( num_to_read > YY_READ_BUF_SIZE ) 1774 num_to_read = YY_READ_BUF_SIZE; 1775 1776 /* Read in more data. */ 1777 YY_INPUT( (&YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[number_to_move]), 1778 YY_G(yy_n_chars), num_to_read ); 1779 1780 YY_CURRENT_BUFFER_LVALUE->yy_n_chars = YY_G(yy_n_chars); 1781 } 1782 1783 if ( YY_G(yy_n_chars) == 0 ) 1784 { 1785 if ( number_to_move == YY_MORE_ADJ ) 1786 { 1787 ret_val = EOB_ACT_END_OF_FILE; 1788 yyrestart( yyin M4_YY_CALL_LAST_ARG); 1789 } 1790 1791 else 1792 { 1793 ret_val = EOB_ACT_LAST_MATCH; 1794 YY_CURRENT_BUFFER_LVALUE->yy_buffer_status = 1795 YY_BUFFER_EOF_PENDING; 1796 } 1797 } 1798 1799 else 1800 ret_val = EOB_ACT_CONTINUE_SCAN; 1801 1802 if ((yy_size_t) (YY_G(yy_n_chars) + number_to_move) > YY_CURRENT_BUFFER_LVALUE->yy_buf_size) { 1803 /* Extend the array by 50%, plus the number we really need. */ 1804 yy_size_t new_size = YY_G(yy_n_chars) + number_to_move + (YY_G(yy_n_chars) >> 1); 1805 YY_CURRENT_BUFFER_LVALUE->yy_ch_buf = (char *) yyrealloc( 1806 (void *) YY_CURRENT_BUFFER_LVALUE->yy_ch_buf, new_size M4_YY_CALL_LAST_ARG ); 1807 if ( ! YY_CURRENT_BUFFER_LVALUE->yy_ch_buf ) 1808 YY_FATAL_ERROR( "out of dynamic memory in yy_get_next_buffer()" ); 1809 } 1810 1811 YY_G(yy_n_chars) += number_to_move; 1812 YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[YY_G(yy_n_chars)] = YY_END_OF_BUFFER_CHAR; 1813 YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[YY_G(yy_n_chars) + 1] = YY_END_OF_BUFFER_CHAR; 1814 1815 YY_G(yytext_ptr) = &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[0]; 1816 1817 return ret_val; 1818} 1819]]) 1820 1821/* yy_get_previous_state - get the state just before the EOB char was reached */ 1822 1823%if-c-only 1824%not-for-header 1825 static yy_state_type yy_get_previous_state YYFARGS0(void) 1826%endif 1827%if-c++-only 1828 yy_state_type yyFlexLexer::yy_get_previous_state() 1829%endif 1830{ 1831 yy_state_type yy_current_state; 1832 char *yy_cp; 1833 M4_YY_DECL_GUTS_VAR(); 1834 1835%% [15.0] code to get the start state into yy_current_state goes here 1836 1837 for ( yy_cp = YY_G(yytext_ptr) + YY_MORE_ADJ; yy_cp < YY_G(yy_c_buf_p); ++yy_cp ) 1838 { 1839%% [16.0] code to find the next state goes here 1840 } 1841 1842 return yy_current_state; 1843} 1844 1845 1846/* yy_try_NUL_trans - try to make a transition on the NUL character 1847 * 1848 * synopsis 1849 * next_state = yy_try_NUL_trans( current_state ); 1850 */ 1851%if-c-only 1852 static yy_state_type yy_try_NUL_trans YYFARGS1( yy_state_type, yy_current_state) 1853%endif 1854%if-c++-only 1855 yy_state_type yyFlexLexer::yy_try_NUL_trans( yy_state_type yy_current_state ) 1856%endif 1857{ 1858 int yy_is_jam; 1859 M4_YY_DECL_GUTS_VAR(); /* This var may be unused depending upon options. */ 1860%% [17.0] code to find the next state, and perhaps do backing up, goes here 1861 1862 M4_YY_NOOP_GUTS_VAR(); 1863 return yy_is_jam ? 0 : yy_current_state; 1864} 1865 1866 1867#ifndef YY_NO_UNPUT 1868%if-c-only 1869m4_ifdef( [[M4_YY_NO_UNPUT]],, 1870[[ 1871 static void yyunput YYFARGS2( int,c, char *,yy_bp) 1872%endif 1873%if-c++-only 1874 void yyFlexLexer::yyunput( int c, char* yy_bp) 1875%endif 1876{ 1877 char *yy_cp; 1878 M4_YY_DECL_GUTS_VAR(); 1879 1880 yy_cp = YY_G(yy_c_buf_p); 1881 1882 /* undo effects of setting up yytext */ 1883 *yy_cp = YY_G(yy_hold_char); 1884 1885 if ( yy_cp < YY_CURRENT_BUFFER_LVALUE->yy_ch_buf + 2 ) 1886 { /* need to shift things up to make room */ 1887 /* +2 for EOB chars. */ 1888 yy_size_t number_to_move = YY_G(yy_n_chars) + 2; 1889 char *dest = &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[ 1890 YY_CURRENT_BUFFER_LVALUE->yy_buf_size + 2]; 1891 char *source = 1892 &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[number_to_move]; 1893 1894 while ( source > YY_CURRENT_BUFFER_LVALUE->yy_ch_buf ) 1895 *--dest = *--source; 1896 1897 yy_cp += (int) (dest - source); 1898 yy_bp += (int) (dest - source); 1899 YY_CURRENT_BUFFER_LVALUE->yy_n_chars = 1900 YY_G(yy_n_chars) = YY_CURRENT_BUFFER_LVALUE->yy_buf_size; 1901 1902 if ( yy_cp < YY_CURRENT_BUFFER_LVALUE->yy_ch_buf + 2 ) 1903 YY_FATAL_ERROR( "flex scanner push-back overflow" ); 1904 } 1905 1906 *--yy_cp = (char) c; 1907 1908%% [18.0] update yylineno here 1909m4_ifdef( [[M4_YY_USE_LINENO]], 1910[[ 1911 if ( c == '\n' ){ 1912 --yylineno; 1913 } 1914]]) 1915 1916 YY_G(yytext_ptr) = yy_bp; 1917 YY_G(yy_hold_char) = *yy_cp; 1918 YY_G(yy_c_buf_p) = yy_cp; 1919} 1920%if-c-only 1921]]) 1922%endif 1923#endif 1924 1925%if-c-only 1926#ifndef YY_NO_INPUT 1927#ifdef __cplusplus 1928 static int yyinput YYFARGS0(void) 1929#else 1930 static int input YYFARGS0(void) 1931#endif 1932 1933%endif 1934%if-c++-only 1935 int yyFlexLexer::yyinput() 1936%endif 1937{ 1938 int c; 1939 M4_YY_DECL_GUTS_VAR(); 1940 1941 *YY_G(yy_c_buf_p) = YY_G(yy_hold_char); 1942 1943 if ( *YY_G(yy_c_buf_p) == YY_END_OF_BUFFER_CHAR ) 1944 { 1945 /* yy_c_buf_p now points to the character we want to return. 1946 * If this occurs *before* the EOB characters, then it's a 1947 * valid NUL; if not, then we've hit the end of the buffer. 1948 */ 1949 if ( YY_G(yy_c_buf_p) < &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[YY_G(yy_n_chars)] ) 1950 /* This was really a NUL. */ 1951 *YY_G(yy_c_buf_p) = '\0'; 1952 1953 else 1954 { /* need more input */ 1955 yy_size_t offset = YY_G(yy_c_buf_p) - YY_G(yytext_ptr); 1956 ++YY_G(yy_c_buf_p); 1957 1958 switch ( yy_get_next_buffer( M4_YY_CALL_ONLY_ARG ) ) 1959 { 1960 case EOB_ACT_LAST_MATCH: 1961 /* This happens because yy_g_n_b() 1962 * sees that we've accumulated a 1963 * token and flags that we need to 1964 * try matching the token before 1965 * proceeding. But for input(), 1966 * there's no matching to consider. 1967 * So convert the EOB_ACT_LAST_MATCH 1968 * to EOB_ACT_END_OF_FILE. 1969 */ 1970 1971 /* Reset buffer status. */ 1972 yyrestart( yyin M4_YY_CALL_LAST_ARG); 1973 1974 /*FALLTHROUGH*/ 1975 1976 case EOB_ACT_END_OF_FILE: 1977 { 1978 if ( yywrap( M4_YY_CALL_ONLY_ARG ) ) 1979 return EOF; 1980 1981 if ( ! YY_G(yy_did_buffer_switch_on_eof) ) 1982 YY_NEW_FILE; 1983#ifdef __cplusplus 1984 return yyinput(M4_YY_CALL_ONLY_ARG); 1985#else 1986 return input(M4_YY_CALL_ONLY_ARG); 1987#endif 1988 } 1989 1990 case EOB_ACT_CONTINUE_SCAN: 1991 YY_G(yy_c_buf_p) = YY_G(yytext_ptr) + offset; 1992 break; 1993 } 1994 } 1995 } 1996 1997 c = *(unsigned char *) YY_G(yy_c_buf_p); /* cast for 8-bit char's */ 1998 *YY_G(yy_c_buf_p) = '\0'; /* preserve yytext */ 1999 YY_G(yy_hold_char) = *++YY_G(yy_c_buf_p); 2000 2001%% [19.0] update BOL and yylineno 2002 2003 return c; 2004} 2005%if-c-only 2006#endif /* ifndef YY_NO_INPUT */ 2007%endif 2008 2009/** Immediately switch to a different input stream. 2010 * @param input_file A readable stream. 2011 * M4_YY_DOC_PARAM 2012 * @note This function does not reset the start condition to @c INITIAL . 2013 */ 2014%if-c-only 2015 void yyrestart YYFARGS1( FILE *,input_file) 2016%endif 2017%if-c++-only 2018 void yyFlexLexer::yyrestart( std::istream& input_file ) 2019%endif 2020{ 2021 M4_YY_DECL_GUTS_VAR(); 2022 2023 if ( ! YY_CURRENT_BUFFER ){ 2024 yyensure_buffer_stack (M4_YY_CALL_ONLY_ARG); 2025 YY_CURRENT_BUFFER_LVALUE = 2026 yy_create_buffer( yyin, YY_BUF_SIZE M4_YY_CALL_LAST_ARG); 2027 } 2028 2029 yy_init_buffer( YY_CURRENT_BUFFER, input_file M4_YY_CALL_LAST_ARG); 2030 yy_load_buffer_state( M4_YY_CALL_ONLY_ARG ); 2031} 2032 2033%if-c++-only 2034/** Delegate to the new version that takes an istream reference. 2035 * @param input_file A readable stream. 2036 * M4_YY_DOC_PARAM 2037 * @note This function does not reset the start condition to @c INITIAL . 2038 */ 2039void yyFlexLexer::yyrestart( std::istream* input_file ) 2040{ 2041 yyrestart( *input_file ); 2042} 2043%endif 2044 2045/** Switch to a different input buffer. 2046 * @param new_buffer The new input buffer. 2047 * M4_YY_DOC_PARAM 2048 */ 2049%if-c-only 2050 void yy_switch_to_buffer YYFARGS1( YY_BUFFER_STATE ,new_buffer) 2051%endif 2052%if-c++-only 2053 void yyFlexLexer::yy_switch_to_buffer( YY_BUFFER_STATE new_buffer ) 2054%endif 2055{ 2056 M4_YY_DECL_GUTS_VAR(); 2057 2058 /* TODO. We should be able to replace this entire function body 2059 * with 2060 * yypop_buffer_state(); 2061 * yypush_buffer_state(new_buffer); 2062 */ 2063 yyensure_buffer_stack (M4_YY_CALL_ONLY_ARG); 2064 if ( YY_CURRENT_BUFFER == new_buffer ) 2065 return; 2066 2067 if ( YY_CURRENT_BUFFER ) 2068 { 2069 /* Flush out information for old buffer. */ 2070 *YY_G(yy_c_buf_p) = YY_G(yy_hold_char); 2071 YY_CURRENT_BUFFER_LVALUE->yy_buf_pos = YY_G(yy_c_buf_p); 2072 YY_CURRENT_BUFFER_LVALUE->yy_n_chars = YY_G(yy_n_chars); 2073 } 2074 2075 YY_CURRENT_BUFFER_LVALUE = new_buffer; 2076 yy_load_buffer_state( M4_YY_CALL_ONLY_ARG ); 2077 2078 /* We don't actually know whether we did this switch during 2079 * EOF (yywrap()) processing, but the only time this flag 2080 * is looked at is after yywrap() is called, so it's safe 2081 * to go ahead and always set it. 2082 */ 2083 YY_G(yy_did_buffer_switch_on_eof) = 1; 2084} 2085 2086 2087%if-c-only 2088static void yy_load_buffer_state YYFARGS0(void) 2089%endif 2090%if-c++-only 2091 void yyFlexLexer::yy_load_buffer_state() 2092%endif 2093{ 2094 M4_YY_DECL_GUTS_VAR(); 2095 YY_G(yy_n_chars) = YY_CURRENT_BUFFER_LVALUE->yy_n_chars; 2096 YY_G(yytext_ptr) = YY_G(yy_c_buf_p) = YY_CURRENT_BUFFER_LVALUE->yy_buf_pos; 2097%if-c-only 2098 yyin = YY_CURRENT_BUFFER_LVALUE->yy_input_file; 2099%endif 2100%if-c++-only 2101 yyin.rdbuf(YY_CURRENT_BUFFER_LVALUE->yy_input_file); 2102%endif 2103 YY_G(yy_hold_char) = *YY_G(yy_c_buf_p); 2104} 2105 2106/** Allocate and initialize an input buffer state. 2107 * @param file A readable stream. 2108 * @param size The character buffer size in bytes. When in doubt, use @c YY_BUF_SIZE. 2109 * M4_YY_DOC_PARAM 2110 * @return the allocated buffer state. 2111 */ 2112%if-c-only 2113 YY_BUFFER_STATE yy_create_buffer YYFARGS2( FILE *,file, int ,size) 2114%endif 2115%if-c++-only 2116 YY_BUFFER_STATE yyFlexLexer::yy_create_buffer( std::istream& file, int size ) 2117%endif 2118{ 2119 YY_BUFFER_STATE b; 2120 m4_dnl M4_YY_DECL_GUTS_VAR(); 2121 2122 b = (YY_BUFFER_STATE) yyalloc( sizeof( struct yy_buffer_state ) M4_YY_CALL_LAST_ARG ); 2123 if ( ! b ) 2124 YY_FATAL_ERROR( "out of dynamic memory in yy_create_buffer()" ); 2125 2126 b->yy_buf_size = (yy_size_t)size; 2127 2128 /* yy_ch_buf has to be 2 characters longer than the size given because 2129 * we need to put in 2 end-of-buffer characters. 2130 */ 2131 b->yy_ch_buf = (char *) yyalloc( b->yy_buf_size + 2 M4_YY_CALL_LAST_ARG ); 2132 if ( ! b->yy_ch_buf ) 2133 YY_FATAL_ERROR( "out of dynamic memory in yy_create_buffer()" ); 2134 2135 b->yy_is_our_buffer = 1; 2136 2137 yy_init_buffer( b, file M4_YY_CALL_LAST_ARG); 2138 2139 return b; 2140} 2141 2142%if-c++-only 2143/** Delegate creation of buffers to the new version that takes an istream reference. 2144 * @param file A readable stream. 2145 * @param size The character buffer size in bytes. When in doubt, use @c YY_BUF_SIZE. 2146 * M4_YY_DOC_PARAM 2147 * @return the allocated buffer state. 2148 */ 2149 YY_BUFFER_STATE yyFlexLexer::yy_create_buffer( std::istream* file, int size ) 2150{ 2151 return yy_create_buffer( *file, size ); 2152} 2153%endif 2154 2155/** Destroy the buffer. 2156 * @param b a buffer created with yy_create_buffer() 2157 * M4_YY_DOC_PARAM 2158 */ 2159%if-c-only 2160 void yy_delete_buffer YYFARGS1( YY_BUFFER_STATE ,b) 2161%endif 2162%if-c++-only 2163 void yyFlexLexer::yy_delete_buffer( YY_BUFFER_STATE b ) 2164%endif 2165{ 2166 M4_YY_DECL_GUTS_VAR(); 2167 2168 if ( ! b ) 2169 return; 2170 2171 if ( b == YY_CURRENT_BUFFER ) /* Not sure if we should pop here. */ 2172 YY_CURRENT_BUFFER_LVALUE = (YY_BUFFER_STATE) 0; 2173 2174 if ( b->yy_is_our_buffer ) 2175 yyfree( (void *) b->yy_ch_buf M4_YY_CALL_LAST_ARG ); 2176 2177 yyfree( (void *) b M4_YY_CALL_LAST_ARG ); 2178} 2179 2180 2181/* Initializes or reinitializes a buffer. 2182 * This function is sometimes called more than once on the same buffer, 2183 * such as during a yyrestart() or at EOF. 2184 */ 2185%if-c-only 2186 static void yy_init_buffer YYFARGS2( YY_BUFFER_STATE ,b, FILE *,file) 2187%endif 2188%if-c++-only 2189 void yyFlexLexer::yy_init_buffer( YY_BUFFER_STATE b, std::istream& file ) 2190%endif 2191 2192{ 2193 int oerrno = errno; 2194 M4_YY_DECL_GUTS_VAR(); 2195 2196 yy_flush_buffer( b M4_YY_CALL_LAST_ARG); 2197 2198%if-c-only 2199 b->yy_input_file = file; 2200%endif 2201%if-c++-only 2202 b->yy_input_file = file.rdbuf(); 2203%endif 2204 b->yy_fill_buffer = 1; 2205 2206 /* If b is the current buffer, then yy_init_buffer was _probably_ 2207 * called from yyrestart() or through yy_get_next_buffer. 2208 * In that case, we don't want to reset the lineno or column. 2209 */ 2210 if (b != YY_CURRENT_BUFFER){ 2211 b->yy_bs_lineno = 1; 2212 b->yy_bs_column = 0; 2213 } 2214 2215%if-c-only 2216m4_ifdef( [[M4_YY_ALWAYS_INTERACTIVE]], 2217[[ 2218 b->yy_is_interactive = 1; 2219]], 2220[[ 2221 m4_ifdef( [[M4_YY_NEVER_INTERACTIVE]], 2222 [[ 2223 b->yy_is_interactive = 0; 2224 ]], 2225 [[ 2226 b->yy_is_interactive = file ? (isatty( fileno(file) ) > 0) : 0; 2227 ]]) 2228]]) 2229%endif 2230%if-c++-only 2231 b->yy_is_interactive = 0; 2232%endif 2233 errno = oerrno; 2234} 2235 2236/** Discard all buffered characters. On the next scan, YY_INPUT will be called. 2237 * @param b the buffer state to be flushed, usually @c YY_CURRENT_BUFFER. 2238 * M4_YY_DOC_PARAM 2239 */ 2240%if-c-only 2241 void yy_flush_buffer YYFARGS1( YY_BUFFER_STATE ,b) 2242%endif 2243%if-c++-only 2244 void yyFlexLexer::yy_flush_buffer( YY_BUFFER_STATE b ) 2245%endif 2246{ 2247 M4_YY_DECL_GUTS_VAR(); 2248 if ( ! b ) 2249 return; 2250 2251 b->yy_n_chars = 0; 2252 2253 /* We always need two end-of-buffer characters. The first causes 2254 * a transition to the end-of-buffer state. The second causes 2255 * a jam in that state. 2256 */ 2257 b->yy_ch_buf[0] = YY_END_OF_BUFFER_CHAR; 2258 b->yy_ch_buf[1] = YY_END_OF_BUFFER_CHAR; 2259 2260 b->yy_buf_pos = &b->yy_ch_buf[0]; 2261 2262 b->yy_at_bol = 1; 2263 b->yy_buffer_status = YY_BUFFER_NEW; 2264 2265 if ( b == YY_CURRENT_BUFFER ) 2266 yy_load_buffer_state( M4_YY_CALL_ONLY_ARG ); 2267} 2268 2269%if-c-or-c++ 2270/** Pushes the new state onto the stack. The new state becomes 2271 * the current state. This function will allocate the stack 2272 * if necessary. 2273 * @param new_buffer The new state. 2274 * M4_YY_DOC_PARAM 2275 */ 2276%if-c-only 2277void yypush_buffer_state YYFARGS1(YY_BUFFER_STATE,new_buffer) 2278%endif 2279%if-c++-only 2280void yyFlexLexer::yypush_buffer_state (YY_BUFFER_STATE new_buffer) 2281%endif 2282{ 2283 M4_YY_DECL_GUTS_VAR(); 2284 if (new_buffer == NULL) 2285 return; 2286 2287 yyensure_buffer_stack(M4_YY_CALL_ONLY_ARG); 2288 2289 /* This block is copied from yy_switch_to_buffer. */ 2290 if ( YY_CURRENT_BUFFER ) 2291 { 2292 /* Flush out information for old buffer. */ 2293 *YY_G(yy_c_buf_p) = YY_G(yy_hold_char); 2294 YY_CURRENT_BUFFER_LVALUE->yy_buf_pos = YY_G(yy_c_buf_p); 2295 YY_CURRENT_BUFFER_LVALUE->yy_n_chars = YY_G(yy_n_chars); 2296 } 2297 2298 /* Only push if top exists. Otherwise, replace top. */ 2299 if (YY_CURRENT_BUFFER) 2300 YY_G(yy_buffer_stack_top)++; 2301 YY_CURRENT_BUFFER_LVALUE = new_buffer; 2302 2303 /* copied from yy_switch_to_buffer. */ 2304 yy_load_buffer_state( M4_YY_CALL_ONLY_ARG ); 2305 YY_G(yy_did_buffer_switch_on_eof) = 1; 2306} 2307%endif 2308 2309 2310%if-c-or-c++ 2311/** Removes and deletes the top of the stack, if present. 2312 * The next element becomes the new top. 2313 * M4_YY_DOC_PARAM 2314 */ 2315%if-c-only 2316void yypop_buffer_state YYFARGS0(void) 2317%endif 2318%if-c++-only 2319void yyFlexLexer::yypop_buffer_state (void) 2320%endif 2321{ 2322 M4_YY_DECL_GUTS_VAR(); 2323 if (!YY_CURRENT_BUFFER) 2324 return; 2325 2326 yy_delete_buffer(YY_CURRENT_BUFFER M4_YY_CALL_LAST_ARG); 2327 YY_CURRENT_BUFFER_LVALUE = NULL; 2328 if (YY_G(yy_buffer_stack_top) > 0) 2329 --YY_G(yy_buffer_stack_top); 2330 2331 if (YY_CURRENT_BUFFER) { 2332 yy_load_buffer_state( M4_YY_CALL_ONLY_ARG ); 2333 YY_G(yy_did_buffer_switch_on_eof) = 1; 2334 } 2335} 2336%endif 2337 2338 2339%if-c-or-c++ 2340/* Allocates the stack if it does not exist. 2341 * Guarantees space for at least one push. 2342 */ 2343%if-c-only 2344static void yyensure_buffer_stack YYFARGS0(void) 2345%endif 2346%if-c++-only 2347void yyFlexLexer::yyensure_buffer_stack(void) 2348%endif 2349{ 2350 yy_size_t num_to_alloc; 2351 M4_YY_DECL_GUTS_VAR(); 2352 2353 if (!YY_G(yy_buffer_stack)) { 2354 2355 /* First allocation is just for 2 elements, since we don't know if this 2356 * scanner will even need a stack. We use 2 instead of 1 to avoid an 2357 * immediate realloc on the next call. 2358 */ 2359 num_to_alloc = 1; // After all that talk, this was set to 1 anyways... 2360 YY_G(yy_buffer_stack) = (struct yy_buffer_state**)yyalloc 2361 (num_to_alloc * sizeof(struct yy_buffer_state*) 2362 M4_YY_CALL_LAST_ARG); 2363 if ( ! YY_G(yy_buffer_stack) ) 2364 YY_FATAL_ERROR( "out of dynamic memory in yyensure_buffer_stack()" ); 2365 2366 2367 memset(YY_G(yy_buffer_stack), 0, num_to_alloc * sizeof(struct yy_buffer_state*)); 2368 2369 YY_G(yy_buffer_stack_max) = num_to_alloc; 2370 YY_G(yy_buffer_stack_top) = 0; 2371 return; 2372 } 2373 2374 if (YY_G(yy_buffer_stack_top) >= (YY_G(yy_buffer_stack_max)) - 1){ 2375 2376 /* Increase the buffer to prepare for a possible push. */ 2377 yy_size_t grow_size = 8 /* arbitrary grow size */; 2378 2379 num_to_alloc = YY_G(yy_buffer_stack_max) + grow_size; 2380 YY_G(yy_buffer_stack) = (struct yy_buffer_state**)yyrealloc 2381 (YY_G(yy_buffer_stack), 2382 num_to_alloc * sizeof(struct yy_buffer_state*) 2383 M4_YY_CALL_LAST_ARG); 2384 if ( ! YY_G(yy_buffer_stack) ) 2385 YY_FATAL_ERROR( "out of dynamic memory in yyensure_buffer_stack()" ); 2386 2387 /* zero only the new slots.*/ 2388 memset(YY_G(yy_buffer_stack) + YY_G(yy_buffer_stack_max), 0, grow_size * sizeof(struct yy_buffer_state*)); 2389 YY_G(yy_buffer_stack_max) = num_to_alloc; 2390 } 2391} 2392%endif 2393 2394 2395 2396 2397m4_ifdef( [[M4_YY_NO_SCAN_BUFFER]],, 2398[[ 2399%if-c-only 2400/** Setup the input buffer state to scan directly from a user-specified character buffer. 2401 * @param base the character buffer 2402 * @param size the size in bytes of the character buffer 2403 * M4_YY_DOC_PARAM 2404 * @return the newly allocated buffer state object. 2405 */ 2406YY_BUFFER_STATE yy_scan_buffer YYFARGS2( char *,base, yy_size_t ,size) 2407{ 2408 YY_BUFFER_STATE b; 2409 m4_dnl M4_YY_DECL_GUTS_VAR(); 2410 2411 if ( size < 2 || 2412 base[size-2] != YY_END_OF_BUFFER_CHAR || 2413 base[size-1] != YY_END_OF_BUFFER_CHAR ) 2414 /* They forgot to leave room for the EOB's. */ 2415 return 0; 2416 2417 b = (YY_BUFFER_STATE) yyalloc( sizeof( struct yy_buffer_state ) M4_YY_CALL_LAST_ARG ); 2418 if ( ! b ) 2419 YY_FATAL_ERROR( "out of dynamic memory in yy_scan_buffer()" ); 2420 2421 b->yy_buf_size = size - 2; /* "- 2" to take care of EOB's */ 2422 b->yy_buf_pos = b->yy_ch_buf = base; 2423 b->yy_is_our_buffer = 0; 2424 b->yy_input_file = 0; 2425 b->yy_n_chars = b->yy_buf_size; 2426 b->yy_is_interactive = 0; 2427 b->yy_at_bol = 1; 2428 b->yy_fill_buffer = 0; 2429 b->yy_buffer_status = YY_BUFFER_NEW; 2430 2431 yy_switch_to_buffer( b M4_YY_CALL_LAST_ARG ); 2432 2433 return b; 2434} 2435%endif 2436]]) 2437 2438 2439m4_ifdef( [[M4_YY_NO_SCAN_STRING]],, 2440[[ 2441%if-c-only 2442/** Setup the input buffer state to scan a string. The next call to yylex() will 2443 * scan from a @e copy of @a str. 2444 * @param yystr a NUL-terminated string to scan 2445 * M4_YY_DOC_PARAM 2446 * @return the newly allocated buffer state object. 2447 * @note If you want to scan bytes that may contain NUL values, then use 2448 * yy_scan_bytes() instead. 2449 */ 2450YY_BUFFER_STATE yy_scan_string YYFARGS1( yyconst char *, yystr) 2451{ 2452 m4_dnl M4_YY_DECL_GUTS_VAR(); 2453 2454 return yy_scan_bytes( yystr, strlen(yystr) M4_YY_CALL_LAST_ARG); 2455} 2456%endif 2457]]) 2458 2459 2460m4_ifdef( [[M4_YY_NO_SCAN_BYTES]],, 2461[[ 2462%if-c-only 2463/** Setup the input buffer state to scan the given bytes. The next call to yylex() will 2464 * scan from a @e copy of @a bytes. 2465 * @param yybytes the byte buffer to scan 2466 * @param _yybytes_len the number of bytes in the buffer pointed to by @a bytes. 2467 * M4_YY_DOC_PARAM 2468 * @return the newly allocated buffer state object. 2469 */ 2470YY_BUFFER_STATE yy_scan_bytes YYFARGS2( yyconst char *,yybytes, yy_size_t ,_yybytes_len) 2471{ 2472 YY_BUFFER_STATE b; 2473 char *buf; 2474 yy_size_t n; 2475 yy_size_t i; 2476 m4_dnl M4_YY_DECL_GUTS_VAR(); 2477 2478 /* Get memory for full buffer, including space for trailing EOB's. */ 2479 n = _yybytes_len + 2; 2480 buf = (char *) yyalloc( n M4_YY_CALL_LAST_ARG ); 2481 if ( ! buf ) 2482 YY_FATAL_ERROR( "out of dynamic memory in yy_scan_bytes()" ); 2483 2484 for ( i = 0; i < _yybytes_len; ++i ) 2485 buf[i] = yybytes[i]; 2486 2487 buf[_yybytes_len] = buf[_yybytes_len+1] = YY_END_OF_BUFFER_CHAR; 2488 2489 b = yy_scan_buffer( buf, n M4_YY_CALL_LAST_ARG); 2490 if ( ! b ) 2491 YY_FATAL_ERROR( "bad buffer in yy_scan_bytes()" ); 2492 2493 /* It's okay to grow etc. this buffer, and we should throw it 2494 * away when we're done. 2495 */ 2496 b->yy_is_our_buffer = 1; 2497 2498 return b; 2499} 2500%endif 2501]]) 2502 2503 2504m4_ifdef( [[M4_YY_NO_PUSH_STATE]],, 2505[[ 2506%if-c-only 2507 static void yy_push_state YYFARGS1( int ,_new_state) 2508%endif 2509%if-c++-only 2510 void yyFlexLexer::yy_push_state( int _new_state ) 2511%endif 2512{ 2513 M4_YY_DECL_GUTS_VAR(); 2514 if ( YY_G(yy_start_stack_ptr) >= YY_G(yy_start_stack_depth) ) 2515 { 2516 yy_size_t new_size; 2517 2518 YY_G(yy_start_stack_depth) += YY_START_STACK_INCR; 2519 new_size = YY_G(yy_start_stack_depth) * sizeof( int ); 2520 2521 if ( ! YY_G(yy_start_stack) ) 2522 YY_G(yy_start_stack) = (int *) yyalloc( new_size M4_YY_CALL_LAST_ARG ); 2523 2524 else 2525 YY_G(yy_start_stack) = (int *) yyrealloc( 2526 (void *) YY_G(yy_start_stack), new_size M4_YY_CALL_LAST_ARG ); 2527 2528 if ( ! YY_G(yy_start_stack) ) 2529 YY_FATAL_ERROR( "out of memory expanding start-condition stack" ); 2530 } 2531 2532 YY_G(yy_start_stack)[YY_G(yy_start_stack_ptr)++] = YY_START; 2533 2534 BEGIN(_new_state); 2535} 2536]]) 2537 2538 2539m4_ifdef( [[M4_YY_NO_POP_STATE]],, 2540[[ 2541%if-c-only 2542 static void yy_pop_state YYFARGS0(void) 2543%endif 2544%if-c++-only 2545 void yyFlexLexer::yy_pop_state() 2546%endif 2547{ 2548 M4_YY_DECL_GUTS_VAR(); 2549 if ( --YY_G(yy_start_stack_ptr) < 0 ) 2550 YY_FATAL_ERROR( "start-condition stack underflow" ); 2551 2552 BEGIN(YY_G(yy_start_stack)[YY_G(yy_start_stack_ptr)]); 2553} 2554]]) 2555 2556 2557m4_ifdef( [[M4_YY_NO_TOP_STATE]],, 2558[[ 2559%if-c-only 2560 static int yy_top_state YYFARGS0(void) 2561%endif 2562%if-c++-only 2563 int yyFlexLexer::yy_top_state() 2564%endif 2565{ 2566 M4_YY_DECL_GUTS_VAR(); 2567 return YY_G(yy_start_stack)[YY_G(yy_start_stack_ptr) - 1]; 2568} 2569]]) 2570 2571#ifndef YY_EXIT_FAILURE 2572#define YY_EXIT_FAILURE 2 2573#endif 2574 2575%if-c-only 2576static void yy_fatal_error YYFARGS1(yyconst char*, msg) 2577{ 2578 M4_YY_DECL_GUTS_VAR(); 2579 M4_YY_NOOP_GUTS_VAR(); 2580 (void) fprintf( stderr, "%s\n", msg ); 2581 exit( YY_EXIT_FAILURE ); 2582} 2583%endif 2584%if-c++-only 2585void yyFlexLexer::LexerError( yyconst char msg[] ) 2586{ 2587 M4_YY_DECL_GUTS_VAR(); 2588 std::cerr << msg << std::endl; 2589 exit( YY_EXIT_FAILURE ); 2590} 2591%endif 2592 2593/* Redefine yyless() so it works in section 3 code. */ 2594 2595#undef yyless 2596#define yyless(n) \ 2597 do \ 2598 { \ 2599 /* Undo effects of setting up yytext. */ \ 2600 int yyless_macro_arg = (n); \ 2601 YY_LESS_LINENO(yyless_macro_arg);\ 2602 yytext[yyleng] = YY_G(yy_hold_char); \ 2603 YY_G(yy_c_buf_p) = yytext + yyless_macro_arg; \ 2604 YY_G(yy_hold_char) = *YY_G(yy_c_buf_p); \ 2605 *YY_G(yy_c_buf_p) = '\0'; \ 2606 yyleng = yyless_macro_arg; \ 2607 } \ 2608 while ( 0 ) 2609 2610 2611 2612/* Accessor methods (get/set functions) to struct members. */ 2613 2614%if-c-only 2615%if-reentrant 2616m4_ifdef( [[M4_YY_NO_GET_EXTRA]],, 2617[[ 2618/** Get the user-defined data for this scanner. 2619 * M4_YY_DOC_PARAM 2620 */ 2621YY_EXTRA_TYPE yyget_extra YYFARGS0(void) 2622{ 2623 M4_YY_DECL_GUTS_VAR(); 2624 return yyextra; 2625} 2626]]) 2627%endif 2628 2629m4_ifdef( [[M4_YY_NO_GET_LINENO]],, 2630[[ 2631/** Get the current line number. 2632 * M4_YY_DOC_PARAM 2633 */ 2634int yyget_lineno YYFARGS0(void) 2635{ 2636 M4_YY_DECL_GUTS_VAR(); 2637 2638 m4_ifdef( [[M4_YY_REENTRANT]], 2639 [[ 2640 if (! YY_CURRENT_BUFFER) 2641 return 0; 2642 ]]) 2643 return yylineno; 2644} 2645]]) 2646 2647m4_ifdef( [[M4_YY_REENTRANT]], 2648[[ 2649m4_ifdef( [[M4_YY_NO_GET_COLUMN]],, 2650[[ 2651/** Get the current column number. 2652 * M4_YY_DOC_PARAM 2653 */ 2654int yyget_column YYFARGS0(void) 2655{ 2656 M4_YY_DECL_GUTS_VAR(); 2657 2658 m4_ifdef( [[M4_YY_REENTRANT]], 2659 [[ 2660 if (! YY_CURRENT_BUFFER) 2661 return 0; 2662 ]]) 2663 return yycolumn; 2664} 2665]]) 2666]]) 2667 2668m4_ifdef( [[M4_YY_NO_GET_IN]],, 2669[[ 2670/** Get the input stream. 2671 * M4_YY_DOC_PARAM 2672 */ 2673FILE *yyget_in YYFARGS0(void) 2674{ 2675 M4_YY_DECL_GUTS_VAR(); 2676 return yyin; 2677} 2678]]) 2679 2680m4_ifdef( [[M4_YY_NO_GET_OUT]],, 2681[[ 2682/** Get the output stream. 2683 * M4_YY_DOC_PARAM 2684 */ 2685FILE *yyget_out YYFARGS0(void) 2686{ 2687 M4_YY_DECL_GUTS_VAR(); 2688 return yyout; 2689} 2690]]) 2691 2692m4_ifdef( [[M4_YY_NO_GET_LENG]],, 2693[[ 2694/** Get the length of the current token. 2695 * M4_YY_DOC_PARAM 2696 */ 2697yy_size_t yyget_leng YYFARGS0(void) 2698{ 2699 M4_YY_DECL_GUTS_VAR(); 2700 return yyleng; 2701} 2702]]) 2703 2704/** Get the current token. 2705 * M4_YY_DOC_PARAM 2706 */ 2707m4_ifdef( [[M4_YY_NO_GET_TEXT]],, 2708[[ 2709char *yyget_text YYFARGS0(void) 2710{ 2711 M4_YY_DECL_GUTS_VAR(); 2712 return yytext; 2713} 2714]]) 2715 2716%if-reentrant 2717m4_ifdef( [[M4_YY_NO_SET_EXTRA]],, 2718[[ 2719/** Set the user-defined data. This data is never touched by the scanner. 2720 * @param user_defined The data to be associated with this scanner. 2721 * M4_YY_DOC_PARAM 2722 */ 2723void yyset_extra YYFARGS1( YY_EXTRA_TYPE ,user_defined) 2724{ 2725 M4_YY_DECL_GUTS_VAR(); 2726 yyextra = user_defined ; 2727} 2728]]) 2729%endif 2730 2731m4_ifdef( [[M4_YY_NO_SET_LINENO]],, 2732[[ 2733/** Set the current line number. 2734 * @param _line_number line number 2735 * M4_YY_DOC_PARAM 2736 */ 2737void yyset_lineno YYFARGS1( int ,_line_number) 2738{ 2739 M4_YY_DECL_GUTS_VAR(); 2740 2741 m4_ifdef( [[M4_YY_REENTRANT]], 2742 [[ 2743 /* lineno is only valid if an input buffer exists. */ 2744 if (! YY_CURRENT_BUFFER ) 2745 YY_FATAL_ERROR( "yyset_lineno called with no buffer" ); 2746 ]]) 2747 yylineno = _line_number; 2748} 2749]]) 2750 2751m4_ifdef( [[M4_YY_REENTRANT]], 2752[[ 2753m4_ifdef( [[M4_YY_NO_SET_COLUMN]],, 2754[[ 2755/** Set the current column. 2756 * @param _column_no column number 2757 * M4_YY_DOC_PARAM 2758 */ 2759void yyset_column YYFARGS1( int , _column_no) 2760{ 2761 M4_YY_DECL_GUTS_VAR(); 2762 2763 m4_ifdef( [[M4_YY_REENTRANT]], 2764 [[ 2765 /* column is only valid if an input buffer exists. */ 2766 if (! YY_CURRENT_BUFFER ) 2767 YY_FATAL_ERROR( "yyset_column called with no buffer" ); 2768 ]]) 2769 yycolumn = _column_no; 2770} 2771]]) 2772]]) 2773 2774 2775m4_ifdef( [[M4_YY_NO_SET_IN]],, 2776[[ 2777/** Set the input stream. This does not discard the current 2778 * input buffer. 2779 * @param _in_str A readable stream. 2780 * M4_YY_DOC_PARAM 2781 * @see yy_switch_to_buffer 2782 */ 2783void yyset_in YYFARGS1( FILE * ,_in_str) 2784{ 2785 M4_YY_DECL_GUTS_VAR(); 2786 yyin = _in_str ; 2787} 2788]]) 2789 2790m4_ifdef( [[M4_YY_NO_SET_OUT]],, 2791[[ 2792void yyset_out YYFARGS1( FILE * ,_out_str) 2793{ 2794 M4_YY_DECL_GUTS_VAR(); 2795 yyout = _out_str ; 2796} 2797]]) 2798 2799 2800m4_ifdef( [[M4_YY_NO_GET_DEBUG]],, 2801[[ 2802int yyget_debug YYFARGS0(void) 2803{ 2804 M4_YY_DECL_GUTS_VAR(); 2805 return yy_flex_debug; 2806} 2807]]) 2808 2809m4_ifdef( [[M4_YY_NO_SET_DEBUG]],, 2810[[ 2811void yyset_debug YYFARGS1( int ,_bdebug) 2812{ 2813 M4_YY_DECL_GUTS_VAR(); 2814 yy_flex_debug = _bdebug ; 2815} 2816]]) 2817%endif 2818 2819%if-reentrant 2820/* Accessor methods for yylval and yylloc */ 2821 2822%if-bison-bridge 2823m4_ifdef( [[M4_YY_NO_GET_LVAL]],, 2824[[ 2825YYSTYPE * yyget_lval YYFARGS0(void) 2826{ 2827 M4_YY_DECL_GUTS_VAR(); 2828 return yylval; 2829} 2830]]) 2831 2832m4_ifdef( [[M4_YY_NO_SET_LVAL]],, 2833[[ 2834void yyset_lval YYFARGS1( YYSTYPE * ,yylval_param) 2835{ 2836 M4_YY_DECL_GUTS_VAR(); 2837 yylval = yylval_param; 2838} 2839]]) 2840 2841m4_ifdef( [[<M4_YY_BISON_LLOC>]], 2842[[ 2843 m4_ifdef( [[M4_YY_NO_GET_LLOC]],, 2844 [[ 2845YYLTYPE *yyget_lloc YYFARGS0(void) 2846{ 2847 M4_YY_DECL_GUTS_VAR(); 2848 return yylloc; 2849} 2850 ]]) 2851 2852 m4_ifdef( [[M4_YY_NO_SET_LLOC]],, 2853 [[ 2854void yyset_lloc YYFARGS1( YYLTYPE * ,yylloc_param) 2855{ 2856 M4_YY_DECL_GUTS_VAR(); 2857 yylloc = yylloc_param; 2858} 2859 ]]) 2860]]) 2861 2862%endif 2863 2864 2865/* User-visible API */ 2866 2867/* yylex_init is special because it creates the scanner itself, so it is 2868 * the ONLY reentrant function that doesn't take the scanner as the last argument. 2869 * That's why we explicitly handle the declaration, instead of using our macros. 2870 */ 2871m4_ifdef( [[M4_YY_NO_ANSI_FUNC_DEFS]], 2872[[ 2873int yylex_init( ptr_yy_globals ) 2874 yyscan_t* ptr_yy_globals; 2875]], 2876[[ 2877int yylex_init(yyscan_t* ptr_yy_globals) 2878]]) 2879{ 2880 if (ptr_yy_globals == NULL){ 2881 errno = EINVAL; 2882 return 1; 2883 } 2884 2885 *ptr_yy_globals = (yyscan_t) yyalloc ( sizeof( struct yyguts_t ), NULL ); 2886 2887 if (*ptr_yy_globals == NULL){ 2888 errno = ENOMEM; 2889 return 1; 2890 } 2891 2892 /* By setting to 0xAA, we expose bugs in yy_init_globals. Leave at 0x00 for releases. */ 2893 memset(*ptr_yy_globals,0x00,sizeof(struct yyguts_t)); 2894 2895 return yy_init_globals ( *ptr_yy_globals ); 2896} 2897 2898 2899/* yylex_init_extra has the same functionality as yylex_init, but follows the 2900 * convention of taking the scanner as the last argument. Note however, that 2901 * this is a *pointer* to a scanner, as it will be allocated by this call (and 2902 * is the reason, too, why this function also must handle its own declaration). 2903 * The user defined value in the first argument will be available to yyalloc in 2904 * the yyextra field. 2905 */ 2906m4_ifdef( [[M4_YY_NO_ANSI_FUNC_DEFS]], 2907[[ 2908int yylex_init_extra( yy_user_defined, ptr_yy_globals ) 2909 YY_EXTRA_TYPE yy_user_defined; 2910 yyscan_t* ptr_yy_globals; 2911]], 2912[[ 2913int yylex_init_extra( YY_EXTRA_TYPE yy_user_defined, yyscan_t* ptr_yy_globals ) 2914]]) 2915{ 2916 struct yyguts_t dummy_yyguts; 2917 2918 yyset_extra (yy_user_defined, &dummy_yyguts); 2919 2920 if (ptr_yy_globals == NULL){ 2921 errno = EINVAL; 2922 return 1; 2923 } 2924 2925 *ptr_yy_globals = (yyscan_t) yyalloc ( sizeof( struct yyguts_t ), &dummy_yyguts ); 2926 2927 if (*ptr_yy_globals == NULL){ 2928 errno = ENOMEM; 2929 return 1; 2930 } 2931 2932 /* By setting to 0xAA, we expose bugs in 2933 yy_init_globals. Leave at 0x00 for releases. */ 2934 memset(*ptr_yy_globals,0x00,sizeof(struct yyguts_t)); 2935 2936 yyset_extra (yy_user_defined, *ptr_yy_globals); 2937 2938 return yy_init_globals ( *ptr_yy_globals ); 2939} 2940 2941%endif if-c-only 2942%# Actually, that ended an if-rentrant section 2943 2944%if-c-only 2945static int yy_init_globals YYFARGS0(void) 2946{ 2947 M4_YY_DECL_GUTS_VAR(); 2948 /* Initialization is the same as for the non-reentrant scanner. 2949 * This function is called from yylex_destroy(), so don't allocate here. 2950 */ 2951 2952m4_ifdef( [[M4_YY_USE_LINENO]], 2953[[ 2954 m4_ifdef( [[M4_YY_NOT_REENTRANT]], 2955 [[ 2956 /* We do not touch yylineno unless the option is enabled. */ 2957 yylineno = 1; 2958 ]]) 2959]]) 2960 YY_G(yy_buffer_stack) = 0; 2961 YY_G(yy_buffer_stack_top) = 0; 2962 YY_G(yy_buffer_stack_max) = 0; 2963 YY_G(yy_c_buf_p) = (char *) 0; 2964 YY_G(yy_init) = 0; 2965 YY_G(yy_start) = 0; 2966 2967m4_ifdef( [[M4_YY_HAS_START_STACK_VARS]], 2968[[ 2969 YY_G(yy_start_stack_ptr) = 0; 2970 YY_G(yy_start_stack_depth) = 0; 2971 YY_G(yy_start_stack) = NULL; 2972]]) 2973 2974m4_ifdef( [[M4_YY_USES_REJECT]], 2975[[ 2976 YY_G(yy_state_buf) = 0; 2977 YY_G(yy_state_ptr) = 0; 2978 YY_G(yy_full_match) = 0; 2979 YY_G(yy_lp) = 0; 2980]]) 2981 2982m4_ifdef( [[M4_YY_TEXT_IS_ARRAY]], 2983[[ 2984 YY_G(yytext_ptr) = 0; 2985 YY_G(yy_more_offset) = 0; 2986 YY_G(yy_prev_more_offset) = 0; 2987]]) 2988 2989/* Defined in main.c */ 2990#ifdef YY_STDINIT 2991 yyin = stdin; 2992 yyout = stdout; 2993#else 2994 yyin = (FILE *) 0; 2995 yyout = (FILE *) 0; 2996#endif 2997 2998 /* For future reference: Set errno on error, since we are called by 2999 * yylex_init() 3000 */ 3001 return 0; 3002} 3003%endif 3004 3005 3006%if-c-only SNIP! this currently causes conflicts with the c++ scanner 3007/* yylex_destroy is for both reentrant and non-reentrant scanners. */ 3008int yylex_destroy YYFARGS0(void) 3009{ 3010 M4_YY_DECL_GUTS_VAR(); 3011 3012 /* Pop the buffer stack, destroying each element. */ 3013 while(YY_CURRENT_BUFFER){ 3014 yy_delete_buffer( YY_CURRENT_BUFFER M4_YY_CALL_LAST_ARG ); 3015 YY_CURRENT_BUFFER_LVALUE = NULL; 3016 yypop_buffer_state(M4_YY_CALL_ONLY_ARG); 3017 } 3018 3019 /* Destroy the stack itself. */ 3020 yyfree(YY_G(yy_buffer_stack) M4_YY_CALL_LAST_ARG); 3021 YY_G(yy_buffer_stack) = NULL; 3022 3023m4_ifdef( [[M4_YY_HAS_START_STACK_VARS]], 3024[[ 3025 /* Destroy the start condition stack. */ 3026 yyfree( YY_G(yy_start_stack) M4_YY_CALL_LAST_ARG ); 3027 YY_G(yy_start_stack) = NULL; 3028]]) 3029 3030m4_ifdef( [[M4_YY_USES_REJECT]], 3031[[ 3032 yyfree ( YY_G(yy_state_buf) M4_YY_CALL_LAST_ARG); 3033 YY_G(yy_state_buf) = NULL; 3034]]) 3035 3036 /* Reset the globals. This is important in a non-reentrant scanner so the next time 3037 * yylex() is called, initialization will occur. */ 3038 yy_init_globals( M4_YY_CALL_ONLY_ARG); 3039 3040%if-reentrant 3041 /* Destroy the main struct (reentrant only). */ 3042 yyfree ( yyscanner M4_YY_CALL_LAST_ARG ); 3043 yyscanner = NULL; 3044%endif 3045 return 0; 3046} 3047%endif 3048 3049 3050m4_ifdef( [[M4_YY_NOT_IN_HEADER]], 3051[[ 3052/* 3053 * Internal utility routines. 3054 */ 3055]]) 3056 3057m4_ifdef( [[M4_YY_NOT_IN_HEADER]], 3058[[ 3059#ifndef yytext_ptr 3060static void yy_flex_strncpy YYFARGS3( char*,s1, yyconst char *,s2, int,n) 3061{ 3062 M4_YY_DECL_GUTS_VAR(); 3063 M4_YY_NOOP_GUTS_VAR(); 3064 3065 int i; 3066 for ( i = 0; i < n; ++i ) 3067 s1[i] = s2[i]; 3068} 3069#endif 3070]]) 3071 3072m4_ifdef( [[M4_YY_NOT_IN_HEADER]], 3073[[ 3074#ifdef YY_NEED_STRLEN 3075static int yy_flex_strlen YYFARGS1( yyconst char *,s) 3076{ 3077 int n; 3078 for ( n = 0; s[n]; ++n ) 3079 ; 3080 3081 return n; 3082} 3083#endif 3084]]) 3085 3086m4_ifdef( [[M4_YY_NO_FLEX_ALLOC]],, 3087[[ 3088void *yyalloc YYFARGS1( yy_size_t ,size) 3089{ 3090 M4_YY_DECL_GUTS_VAR(); 3091 M4_YY_NOOP_GUTS_VAR(); 3092 return (void *) malloc( size ); 3093} 3094]]) 3095 3096m4_ifdef( [[M4_YY_NO_FLEX_REALLOC]],, 3097[[ 3098void *yyrealloc YYFARGS2( void *,ptr, yy_size_t ,size) 3099{ 3100 M4_YY_DECL_GUTS_VAR(); 3101 M4_YY_NOOP_GUTS_VAR(); 3102 3103 /* The cast to (char *) in the following accommodates both 3104 * implementations that use char* generic pointers, and those 3105 * that use void* generic pointers. It works with the latter 3106 * because both ANSI C and C++ allow castless assignment from 3107 * any pointer type to void*, and deal with argument conversions 3108 * as though doing an assignment. 3109 */ 3110 return (void *) realloc( (char *) ptr, size ); 3111} 3112]]) 3113 3114m4_ifdef( [[M4_YY_NO_FLEX_FREE]],, 3115[[ 3116void yyfree YYFARGS1( void *,ptr) 3117{ 3118 M4_YY_DECL_GUTS_VAR(); 3119 M4_YY_NOOP_GUTS_VAR(); 3120 free( (char *) ptr ); /* see yyrealloc() for (char *) cast */ 3121} 3122]]) 3123 3124%if-tables-serialization definitions 3125m4preproc_include(`tables_shared.c') 3126 3127static int yytbl_read8 (void *v, struct yytbl_reader * rd) 3128{ 3129 errno = 0; 3130 if (fread (v, sizeof (flex_uint8_t), 1, rd->fp) != 1){ 3131 errno = EIO; 3132 return -1; 3133 } 3134 rd->bread += sizeof(flex_uint8_t); 3135 return 0; 3136} 3137 3138static int yytbl_read16 (void *v, struct yytbl_reader * rd) 3139{ 3140 errno = 0; 3141 if (fread (v, sizeof (flex_uint16_t), 1, rd->fp) != 1){ 3142 errno = EIO; 3143 return -1; 3144 } 3145 *((flex_uint16_t *) v) = ntohs (*((flex_uint16_t *) v)); 3146 rd->bread += sizeof(flex_uint16_t); 3147 return 0; 3148} 3149 3150static int yytbl_read32 (void *v, struct yytbl_reader * rd) 3151{ 3152 errno = 0; 3153 if (fread (v, sizeof (flex_uint32_t), 1, rd->fp) != 1){ 3154 errno = EIO; 3155 return -1; 3156 } 3157 *((flex_uint32_t *) v) = ntohl (*((flex_uint32_t *) v)); 3158 rd->bread += sizeof(flex_uint32_t); 3159 return 0; 3160} 3161 3162/** Read the header */ 3163static int yytbl_hdr_read YYFARGS2(struct yytbl_hdr *, th, struct yytbl_reader *, rd) 3164{ 3165 size_t bytes; 3166 memset (th, 0, sizeof (struct yytbl_hdr)); 3167 3168 if (yytbl_read32 (&(th->th_magic), rd) != 0) 3169 return -1; 3170 3171 if (th->th_magic != YYTBL_MAGIC){ 3172 YY_FATAL_ERROR( "bad magic number" ); /* TODO: not fatal. */ 3173 return -1; 3174 } 3175 3176 if (yytbl_read32 (&(th->th_hsize), rd) != 0 3177 || yytbl_read32 (&(th->th_ssize), rd) != 0 3178 || yytbl_read16 (&(th->th_flags), rd) != 0) 3179 return -1; 3180 3181 /* Sanity check on header size. Greater than 1k suggests some funny business. */ 3182 if (th->th_hsize < 16 || th->th_hsize > 1024){ 3183 YY_FATAL_ERROR( "insane header size detected" ); /* TODO: not fatal. */ 3184 return -1; 3185 } 3186 3187 /* Allocate enough space for the version and name fields */ 3188 bytes = th->th_hsize - 14; 3189 th->th_version = (char *) yyalloc (bytes M4_YY_CALL_LAST_ARG); 3190 if ( ! th->th_version ) 3191 YY_FATAL_ERROR( "out of dynamic memory in yytbl_hdr_read()" ); 3192 3193 /* we read it all into th_version, and point th_name into that data */ 3194 if (fread (th->th_version, 1, bytes, rd->fp) != bytes){ 3195 errno = EIO; 3196 yyfree(th->th_version M4_YY_CALL_LAST_ARG); 3197 th->th_version = NULL; 3198 return -1; 3199 } 3200 else 3201 rd->bread += bytes; 3202 3203 th->th_name = th->th_version + strlen (th->th_version) + 1; 3204 return 0; 3205} 3206 3207/** lookup id in the dmap list. 3208 * @param dmap pointer to first element in list 3209 * @return NULL if not found. 3210 */ 3211static struct yytbl_dmap *yytbl_dmap_lookup YYFARGS2(struct yytbl_dmap *, dmap, 3212 int, id) 3213{ 3214 M4_YY_DECL_GUTS_VAR(); 3215 M4_YY_NOOP_GUTS_VAR(); 3216 3217 while (dmap->dm_id) 3218 if ((int)(dmap->dm_id) == id) 3219 return dmap; 3220 else 3221 dmap++; 3222 return NULL; 3223} 3224 3225/** Read a table while mapping its contents to the local array. 3226 * @param dmap used to performing mapping 3227 * @return 0 on success 3228 */ 3229static int yytbl_data_load YYFARGS2(struct yytbl_dmap *, dmap, struct yytbl_reader*, rd) 3230{ 3231 struct yytbl_data td; 3232 struct yytbl_dmap *transdmap=0; 3233 int len, i, rv, inner_loop_count; 3234 void *p=0; 3235 3236 memset (&td, 0, sizeof (struct yytbl_data)); 3237 3238 if (yytbl_read16 (&td.td_id, rd) != 0 3239 || yytbl_read16 (&td.td_flags, rd) != 0 3240 || yytbl_read32 (&td.td_hilen, rd) != 0 3241 || yytbl_read32 (&td.td_lolen, rd) != 0) 3242 return -1; 3243 3244 /* Lookup the map for the transition table so we have it in case we need it 3245 * inside the loop below. This scanner might not even have a transition 3246 * table, which is ok. 3247 */ 3248 transdmap = yytbl_dmap_lookup (dmap, YYTD_ID_TRANSITION M4_YY_CALL_LAST_ARG); 3249 3250 if ((dmap = yytbl_dmap_lookup (dmap, td.td_id M4_YY_CALL_LAST_ARG)) == NULL){ 3251 YY_FATAL_ERROR( "table id not found in map." ); /* TODO: not fatal. */ 3252 return -1; 3253 } 3254 3255 /* Allocate space for table. 3256 * The --full yy_transition table is a special case, since we 3257 * need the dmap.dm_sz entry to tell us the sizeof the individual 3258 * struct members. 3259 */ 3260 { 3261 size_t bytes; 3262 3263 if ((td.td_flags & YYTD_STRUCT)) 3264 bytes = sizeof(struct yy_trans_info) * td.td_lolen * (td.td_hilen ? td.td_hilen : 1); 3265 else 3266 bytes = td.td_lolen * (td.td_hilen ? td.td_hilen : 1) * dmap->dm_sz; 3267 3268 if(M4_YY_TABLES_VERIFY) 3269 /* We point to the array itself */ 3270 p = dmap->dm_arr; 3271 else 3272 /* We point to the address of a pointer. */ 3273 *dmap->dm_arr = p = (void *) yyalloc (bytes M4_YY_CALL_LAST_ARG); 3274 if ( ! p ) 3275 YY_FATAL_ERROR( "out of dynamic memory in yytbl_data_load()" ); 3276 } 3277 3278 /* If it's a struct, we read 2 integers to get one element */ 3279 if ((td.td_flags & YYTD_STRUCT) != 0) 3280 inner_loop_count = 2; 3281 else 3282 inner_loop_count = 1; 3283 3284 /* read and map each element. 3285 * This loop iterates once for each element of the td_data array. 3286 * Notice that we increment 'i' in the inner loop. 3287 */ 3288 len = yytbl_calc_total_len (&td); 3289 for (i = 0; i < len; ){ 3290 int j; 3291 3292 3293 /* This loop really executes exactly 1 or 2 times. 3294 * The second time is to handle the second member of the 3295 * YYTD_STRUCT for the yy_transition array. 3296 */ 3297 for (j = 0; j < inner_loop_count; j++, i++) { 3298 flex_int32_t t32; 3299 3300 /* read into t32 no matter what the real size is. */ 3301 { 3302 flex_int16_t t16; 3303 flex_int8_t t8; 3304 3305 switch (YYTDFLAGS2BYTES (td.td_flags)) { 3306 case sizeof (flex_int32_t): 3307 rv = yytbl_read32 (&t32, rd); 3308 break; 3309 case sizeof (flex_int16_t): 3310 rv = yytbl_read16 (&t16, rd); 3311 t32 = t16; 3312 break; 3313 case sizeof (flex_int8_t): 3314 rv = yytbl_read8 (&t8, rd); 3315 t32 = t8; 3316 break; 3317 default: 3318 YY_FATAL_ERROR( "invalid td_flags" ); /* TODO: not fatal. */ 3319 return -1; 3320 } 3321 } 3322 if (rv != 0) 3323 return -1; 3324 3325 /* copy into the deserialized array... */ 3326 3327 if ((td.td_flags & YYTD_STRUCT)) { 3328 /* t32 is the j'th member of a two-element struct. */ 3329 void *v; 3330 3331 v = j == 0 ? &(((struct yy_trans_info *) p)->yy_verify) 3332 : &(((struct yy_trans_info *) p)->yy_nxt); 3333 3334 switch (dmap->dm_sz) { 3335 case sizeof (flex_int32_t): 3336 if (M4_YY_TABLES_VERIFY){ 3337 if( ((flex_int32_t *) v)[0] != (flex_int32_t) t32) 3338 YY_FATAL_ERROR( "tables verification failed at YYTD_STRUCT flex_int32_t" ); 3339 }else 3340 ((flex_int32_t *) v)[0] = (flex_int32_t) t32; 3341 break; 3342 case sizeof (flex_int16_t): 3343 if (M4_YY_TABLES_VERIFY ){ 3344 if(((flex_int16_t *) v)[0] != (flex_int16_t) t32) 3345 YY_FATAL_ERROR( "tables verification failed at YYTD_STRUCT flex_int16_t" ); 3346 }else 3347 ((flex_int16_t *) v)[0] = (flex_int16_t) t32; 3348 break; 3349 case sizeof(flex_int8_t): 3350 if (M4_YY_TABLES_VERIFY ){ 3351 if( ((flex_int8_t *) v)[0] != (flex_int8_t) t32) 3352 YY_FATAL_ERROR( "tables verification failed at YYTD_STRUCT flex_int8_t" ); 3353 }else 3354 ((flex_int8_t *) v)[0] = (flex_int8_t) t32; 3355 break; 3356 default: 3357 YY_FATAL_ERROR( "invalid dmap->dm_sz for struct" ); /* TODO: not fatal. */ 3358 return -1; 3359 } 3360 3361 /* if we're done with j, increment p */ 3362 if (j == 1) 3363 p = (struct yy_trans_info *) p + 1; 3364 } 3365 else if ((td.td_flags & YYTD_PTRANS)) { 3366 /* t32 is an index into the transition array. */ 3367 struct yy_trans_info *v; 3368 3369 3370 if (!transdmap){ 3371 YY_FATAL_ERROR( "transition table not found" ); /* TODO: not fatal. */ 3372 return -1; 3373 } 3374 3375 if( M4_YY_TABLES_VERIFY) 3376 v = &(((struct yy_trans_info *) (transdmap->dm_arr))[t32]); 3377 else 3378 v = &((*((struct yy_trans_info **) (transdmap->dm_arr)))[t32]); 3379 3380 if(M4_YY_TABLES_VERIFY ){ 3381 if( ((struct yy_trans_info **) p)[0] != v) 3382 YY_FATAL_ERROR( "tables verification failed at YYTD_PTRANS" ); 3383 }else 3384 ((struct yy_trans_info **) p)[0] = v; 3385 3386 /* increment p */ 3387 p = (struct yy_trans_info **) p + 1; 3388 } 3389 else { 3390 /* t32 is a plain int. copy data, then incrememnt p. */ 3391 switch (dmap->dm_sz) { 3392 case sizeof (flex_int32_t): 3393 if(M4_YY_TABLES_VERIFY ){ 3394 if( ((flex_int32_t *) p)[0] != (flex_int32_t) t32) 3395 YY_FATAL_ERROR( "tables verification failed at flex_int32_t" ); 3396 }else 3397 ((flex_int32_t *) p)[0] = (flex_int32_t) t32; 3398 p = ((flex_int32_t *) p) + 1; 3399 break; 3400 case sizeof (flex_int16_t): 3401 if(M4_YY_TABLES_VERIFY ){ 3402 if( ((flex_int16_t *) p)[0] != (flex_int16_t) t32) 3403 YY_FATAL_ERROR( "tables verification failed at flex_int16_t" ); 3404 }else 3405 ((flex_int16_t *) p)[0] = (flex_int16_t) t32; 3406 p = ((flex_int16_t *) p) + 1; 3407 break; 3408 case sizeof (flex_int8_t): 3409 if(M4_YY_TABLES_VERIFY ){ 3410 if( ((flex_int8_t *) p)[0] != (flex_int8_t) t32) 3411 YY_FATAL_ERROR( "tables verification failed at flex_int8_t" ); 3412 }else 3413 ((flex_int8_t *) p)[0] = (flex_int8_t) t32; 3414 p = ((flex_int8_t *) p) + 1; 3415 break; 3416 default: 3417 YY_FATAL_ERROR( "invalid dmap->dm_sz for plain int" ); /* TODO: not fatal. */ 3418 return -1; 3419 } 3420 } 3421 } 3422 3423 } 3424 3425 /* Now eat padding. */ 3426 { 3427 int pad; 3428 pad = yypad64(rd->bread); 3429 while(--pad >= 0){ 3430 flex_int8_t t8; 3431 if(yytbl_read8(&t8,rd) != 0) 3432 return -1; 3433 } 3434 } 3435 3436 return 0; 3437} 3438 3439%define-yytables The name for this specific scanner's tables. 3440 3441/* Find the key and load the DFA tables from the given stream. */ 3442static int yytbl_fload YYFARGS2(FILE *, fp, const char *, key) 3443{ 3444 int rv=0; 3445 struct yytbl_hdr th; 3446 struct yytbl_reader rd; 3447 3448 rd.fp = fp; 3449 th.th_version = NULL; 3450 3451 /* Keep trying until we find the right set of tables or end of file. */ 3452 while (!feof(rd.fp)) { 3453 rd.bread = 0; 3454 if (yytbl_hdr_read (&th, &rd M4_YY_CALL_LAST_ARG) != 0){ 3455 rv = -1; 3456 goto return_rv; 3457 } 3458 3459 /* A NULL key means choose the first set of tables. */ 3460 if (key == NULL) 3461 break; 3462 3463 if (strcmp(th.th_name,key) != 0){ 3464 /* Skip ahead to next set */ 3465 fseek(rd.fp, th.th_ssize - th.th_hsize, SEEK_CUR); 3466 yyfree(th.th_version M4_YY_CALL_LAST_ARG); 3467 th.th_version = NULL; 3468 } 3469 else 3470 break; 3471 } 3472 3473 while (rd.bread < th.th_ssize){ 3474 /* Load the data tables */ 3475 if(yytbl_data_load (yydmap,&rd M4_YY_CALL_LAST_ARG) != 0){ 3476 rv = -1; 3477 goto return_rv; 3478 } 3479 } 3480 3481return_rv: 3482 if(th.th_version){ 3483 yyfree(th.th_version M4_YY_CALL_LAST_ARG); 3484 th.th_version = NULL; 3485 } 3486 3487 return rv; 3488} 3489 3490/** Load the DFA tables for this scanner from the given stream. */ 3491int yytables_fload YYFARGS1(FILE *, fp) 3492{ 3493 3494 if( yytbl_fload(fp, YYTABLES_NAME M4_YY_CALL_LAST_ARG) != 0) 3495 return -1; 3496 return 0; 3497} 3498 3499/** Destroy the loaded tables, freeing memory, etc.. */ 3500int yytables_destroy YYFARGS0(void) 3501{ 3502 struct yytbl_dmap *dmap=0; 3503 3504 if(!M4_YY_TABLES_VERIFY){ 3505 /* Walk the dmap, freeing the pointers */ 3506 for(dmap=yydmap; dmap->dm_id; dmap++) { 3507 void * v; 3508 v = dmap->dm_arr; 3509 if(v && *(char**)v){ 3510 yyfree(*(char**)v M4_YY_CALL_LAST_ARG); 3511 *(char**)v = NULL; 3512 } 3513 } 3514 } 3515 3516 return 0; 3517} 3518 3519/* end table serialization code definitions */ 3520%endif 3521 3522 3523m4_ifdef([[M4_YY_MAIN]], [[ 3524int main M4_YY_PARAMS(void); 3525 3526int main () 3527{ 3528 3529%if-reentrant 3530 yyscan_t lexer; 3531 yylex_init(&lexer); 3532 yylex( lexer ); 3533 yylex_destroy( lexer); 3534 3535%endif 3536%if-not-reentrant 3537 yylex(); 3538%endif 3539 3540 return 0; 3541} 3542]]) 3543 3544%ok-for-header 3545m4_ifdef( [[M4_YY_IN_HEADER]], 3546[[ 3547#undef YY_NEW_FILE 3548#undef YY_FLUSH_BUFFER 3549#undef yy_set_bol 3550#undef yy_new_buffer 3551#undef yy_set_interactive 3552#undef YY_DO_BEFORE_ACTION 3553 3554#ifdef YY_DECL_IS_OURS 3555#undef YY_DECL_IS_OURS 3556#undef YY_DECL 3557#endif 3558]]) 3559