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