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