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