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