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