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