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