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