1/* $OpenBSD: flex.skl,v 1.16 2017/05/02 19:16:19 millert 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 *)yyalloc(YY_STATE_BUF_SIZE M4_YY_CALL_LAST_ARG); 1313 if ( ! YY_G(yy_state_buf) ) 1314 YY_FATAL_ERROR( "out of dynamic memory in yylex()" ); 1315]]) 1316 1317 if ( ! YY_G(yy_start) ) 1318 YY_G(yy_start) = 1; /* first start state */ 1319 1320 if ( ! yyin ) 1321%if-c-only 1322 yyin = stdin; 1323%endif 1324%if-c++-only 1325 yyin = & std::cin; 1326%endif 1327 1328 if ( ! yyout ) 1329%if-c-only 1330 yyout = stdout; 1331%endif 1332%if-c++-only 1333 yyout = & std::cout; 1334%endif 1335 1336 if ( ! YY_CURRENT_BUFFER ) { 1337 yyensure_buffer_stack (M4_YY_CALL_ONLY_ARG); 1338 YY_CURRENT_BUFFER_LVALUE = 1339 yy_create_buffer( yyin, YY_BUF_SIZE M4_YY_CALL_LAST_ARG); 1340 } 1341 1342 yy_load_buffer_state( M4_YY_CALL_ONLY_ARG ); 1343 } 1344 1345 { 1346%% [7.0] user's declarations go here 1347 1348 while ( 1 ) /* loops until end-of-file is reached */ 1349 { 1350%% [8.0] yymore()-related code goes here 1351 yy_cp = YY_G(yy_c_buf_p); 1352 1353 /* Support of yytext. */ 1354 *yy_cp = YY_G(yy_hold_char); 1355 1356 /* yy_bp points to the position in yy_ch_buf of the start of 1357 * the current run. 1358 */ 1359 yy_bp = yy_cp; 1360 1361%% [9.0] code to set up and find next match goes here 1362 1363yy_find_action: 1364%% [10.0] code to find the action number goes here 1365 1366 YY_DO_BEFORE_ACTION; 1367 1368%% [11.0] code for yylineno update goes here 1369 1370do_action: /* This label is used only to access EOF actions. */ 1371 1372%% [12.0] debug code goes here 1373 1374 switch ( yy_act ) 1375 { /* beginning of action switch */ 1376%% [13.0] actions go here 1377 1378 case YY_END_OF_BUFFER: 1379 { 1380 /* Amount of text matched not including the EOB char. */ 1381 int yy_amount_of_matched_text = (int) (yy_cp - YY_G(yytext_ptr)) - 1; 1382 1383 /* Undo the effects of YY_DO_BEFORE_ACTION. */ 1384 *yy_cp = YY_G(yy_hold_char); 1385 YY_RESTORE_YY_MORE_OFFSET 1386 1387 if ( YY_CURRENT_BUFFER_LVALUE->yy_buffer_status == YY_BUFFER_NEW ) 1388 { 1389 /* We're scanning a new file or input source. It's 1390 * possible that this happened because the user 1391 * just pointed yyin at a new source and called 1392 * yylex(). If so, then we have to assure 1393 * consistency between YY_CURRENT_BUFFER and our 1394 * globals. Here is the right place to do so, because 1395 * this is the first action (other than possibly a 1396 * back-up) that will match for the new input source. 1397 */ 1398 YY_G(yy_n_chars) = YY_CURRENT_BUFFER_LVALUE->yy_n_chars; 1399 YY_CURRENT_BUFFER_LVALUE->yy_input_file = yyin; 1400 YY_CURRENT_BUFFER_LVALUE->yy_buffer_status = YY_BUFFER_NORMAL; 1401 } 1402 1403 /* Note that here we test for yy_c_buf_p "<=" to the position 1404 * of the first EOB in the buffer, since yy_c_buf_p will 1405 * already have been incremented past the NUL character 1406 * (since all states make transitions on EOB to the 1407 * end-of-buffer state). Contrast this with the test 1408 * in input(). 1409 */ 1410 if ( YY_G(yy_c_buf_p) <= &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[YY_G(yy_n_chars)] ) 1411 { /* This was really a NUL. */ 1412 yy_state_type yy_next_state; 1413 1414 YY_G(yy_c_buf_p) = YY_G(yytext_ptr) + yy_amount_of_matched_text; 1415 1416 yy_current_state = yy_get_previous_state( M4_YY_CALL_ONLY_ARG ); 1417 1418 /* Okay, we're now positioned to make the NUL 1419 * transition. We couldn't have 1420 * yy_get_previous_state() go ahead and do it 1421 * for us because it doesn't know how to deal 1422 * with the possibility of jamming (and we don't 1423 * want to build jamming into it because then it 1424 * will run more slowly). 1425 */ 1426 1427 yy_next_state = yy_try_NUL_trans( yy_current_state M4_YY_CALL_LAST_ARG); 1428 1429 yy_bp = YY_G(yytext_ptr) + YY_MORE_ADJ; 1430 1431 if ( yy_next_state ) 1432 { 1433 /* Consume the NUL. */ 1434 yy_cp = ++YY_G(yy_c_buf_p); 1435 yy_current_state = yy_next_state; 1436 goto yy_match; 1437 } 1438 1439 else 1440 { 1441%% [14.0] code to do back-up for compressed tables and set up yy_cp goes here 1442 goto yy_find_action; 1443 } 1444 } 1445 1446 else switch ( yy_get_next_buffer( M4_YY_CALL_ONLY_ARG ) ) 1447 { 1448 case EOB_ACT_END_OF_FILE: 1449 { 1450 YY_G(yy_did_buffer_switch_on_eof) = 0; 1451 1452 if ( yywrap( M4_YY_CALL_ONLY_ARG ) ) 1453 { 1454 /* Note: because we've taken care in 1455 * yy_get_next_buffer() to have set up 1456 * yytext, we can now set up 1457 * yy_c_buf_p so that if some total 1458 * hoser (like flex itself) wants to 1459 * call the scanner after we return the 1460 * YY_NULL, it'll still work - another 1461 * YY_NULL will get returned. 1462 */ 1463 YY_G(yy_c_buf_p) = YY_G(yytext_ptr) + YY_MORE_ADJ; 1464 1465 yy_act = YY_STATE_EOF(YY_START); 1466 goto do_action; 1467 } 1468 1469 else 1470 { 1471 if ( ! YY_G(yy_did_buffer_switch_on_eof) ) 1472 YY_NEW_FILE; 1473 } 1474 break; 1475 } 1476 1477 case EOB_ACT_CONTINUE_SCAN: 1478 YY_G(yy_c_buf_p) = 1479 YY_G(yytext_ptr) + yy_amount_of_matched_text; 1480 1481 yy_current_state = yy_get_previous_state( M4_YY_CALL_ONLY_ARG ); 1482 1483 yy_cp = YY_G(yy_c_buf_p); 1484 yy_bp = YY_G(yytext_ptr) + YY_MORE_ADJ; 1485 goto yy_match; 1486 1487 case EOB_ACT_LAST_MATCH: 1488 YY_G(yy_c_buf_p) = 1489 &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[YY_G(yy_n_chars)]; 1490 1491 yy_current_state = yy_get_previous_state( M4_YY_CALL_ONLY_ARG ); 1492 1493 yy_cp = YY_G(yy_c_buf_p); 1494 yy_bp = YY_G(yytext_ptr) + YY_MORE_ADJ; 1495 goto yy_find_action; 1496 } 1497 break; 1498 } 1499 1500 default: 1501 YY_FATAL_ERROR( 1502 "fatal flex scanner internal error--no action found" ); 1503 } /* end of action switch */ 1504 } /* end of scanning one token */ 1505 } /* end of user's declarations */ 1506} /* end of yylex */ 1507%ok-for-header 1508 1509%if-c++-only 1510%not-for-header 1511/* The contents of this function are C++ specific, so the YY_G macro is not used. 1512 */ 1513yyFlexLexer::yyFlexLexer( std::istream* arg_yyin, std::ostream* arg_yyout ) 1514{ 1515 yyin = arg_yyin; 1516 yyout = arg_yyout; 1517 yy_c_buf_p = 0; 1518 yy_init = 0; 1519 yy_start = 0; 1520 yy_flex_debug = 0; 1521 yylineno = 1; // this will only get updated if %option yylineno 1522 1523 yy_did_buffer_switch_on_eof = 0; 1524 1525 yy_looking_for_trail_begin = 0; 1526 yy_more_flag = 0; 1527 yy_more_len = 0; 1528 yy_more_offset = yy_prev_more_offset = 0; 1529 1530 yy_start_stack_ptr = yy_start_stack_depth = 0; 1531 yy_start_stack = NULL; 1532 1533 yy_buffer_stack = 0; 1534 yy_buffer_stack_top = 0; 1535 yy_buffer_stack_max = 0; 1536 1537 1538m4_ifdef( [[M4_YY_USES_REJECT]], 1539[[ 1540 yy_state_buf = new yy_state_type[YY_STATE_BUF_SIZE]; 1541]], 1542[[ 1543 yy_state_buf = 0; 1544]]) 1545} 1546 1547/* The contents of this function are C++ specific, so the YY_G macro is not used. 1548 */ 1549yyFlexLexer::~yyFlexLexer() 1550{ 1551 delete [] yy_state_buf; 1552 yyfree( yy_start_stack M4_YY_CALL_LAST_ARG ); 1553 yy_delete_buffer( YY_CURRENT_BUFFER M4_YY_CALL_LAST_ARG); 1554 yyfree( yy_buffer_stack M4_YY_CALL_LAST_ARG ); 1555} 1556 1557/* The contents of this function are C++ specific, so the YY_G macro is not used. 1558 */ 1559void yyFlexLexer::switch_streams( std::istream* new_in, std::ostream* new_out ) 1560{ 1561 if ( new_in ) 1562 { 1563 yy_delete_buffer( YY_CURRENT_BUFFER M4_YY_CALL_LAST_ARG); 1564 yy_switch_to_buffer( yy_create_buffer( new_in, YY_BUF_SIZE M4_YY_CALL_LAST_ARG) M4_YY_CALL_LAST_ARG); 1565 } 1566 1567 if ( new_out ) 1568 yyout = new_out; 1569} 1570 1571#ifdef YY_INTERACTIVE 1572int yyFlexLexer::LexerInput( char* buf, int /* max_size */ ) 1573#else 1574int yyFlexLexer::LexerInput( char* buf, int max_size ) 1575#endif 1576{ 1577 if ( yyin->eof() || yyin->fail() ) 1578 return 0; 1579 1580#ifdef YY_INTERACTIVE 1581 yyin->get( buf[0] ); 1582 1583 if ( yyin->eof() ) 1584 return 0; 1585 1586 if ( yyin->bad() ) 1587 return -1; 1588 1589 return 1; 1590 1591#else 1592 (void) yyin->read( buf, max_size ); 1593 1594 if ( yyin->bad() ) 1595 return -1; 1596 else 1597 return yyin->gcount(); 1598#endif 1599} 1600 1601void yyFlexLexer::LexerOutput( const char* buf, int size ) 1602{ 1603 (void) yyout->write( buf, size ); 1604} 1605%ok-for-header 1606%endif 1607 1608m4_ifdef( [[M4_YY_NOT_IN_HEADER]], 1609[[ 1610/* yy_get_next_buffer - try to read in a new buffer 1611 * 1612 * Returns a code representing an action: 1613 * EOB_ACT_LAST_MATCH - 1614 * EOB_ACT_CONTINUE_SCAN - continue scanning from current position 1615 * EOB_ACT_END_OF_FILE - end of file 1616 */ 1617%if-c-only 1618static int yy_get_next_buffer YYFARGS0(void) 1619%endif 1620%if-c++-only 1621int yyFlexLexer::yy_get_next_buffer() 1622%endif 1623{ 1624 M4_YY_DECL_GUTS_VAR(); 1625 char *dest = YY_CURRENT_BUFFER_LVALUE->yy_ch_buf; 1626 char *source = YY_G(yytext_ptr); 1627 int number_to_move, i; 1628 int ret_val; 1629 1630 if ( YY_G(yy_c_buf_p) > &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[YY_G(yy_n_chars) + 1] ) 1631 YY_FATAL_ERROR( 1632 "fatal flex scanner internal error--end of buffer missed" ); 1633 1634 if ( YY_CURRENT_BUFFER_LVALUE->yy_fill_buffer == 0 ) 1635 { /* Don't try to fill the buffer, so this is an EOF. */ 1636 if ( YY_G(yy_c_buf_p) - YY_G(yytext_ptr) - YY_MORE_ADJ == 1 ) 1637 { 1638 /* We matched a single character, the EOB, so 1639 * treat this as a final EOF. 1640 */ 1641 return EOB_ACT_END_OF_FILE; 1642 } 1643 1644 else 1645 { 1646 /* We matched some text prior to the EOB, first 1647 * process it. 1648 */ 1649 return EOB_ACT_LAST_MATCH; 1650 } 1651 } 1652 1653 /* Try to read more data. */ 1654 1655 /* First move last chars to start of buffer. */ 1656 number_to_move = (int) (YY_G(yy_c_buf_p) - YY_G(yytext_ptr)) - 1; 1657 1658 for ( i = 0; i < number_to_move; ++i ) 1659 *(dest++) = *(source++); 1660 1661 if ( YY_CURRENT_BUFFER_LVALUE->yy_buffer_status == YY_BUFFER_EOF_PENDING ) 1662 /* don't do the read, it's not guaranteed to return an EOF, 1663 * just force an EOF 1664 */ 1665 YY_CURRENT_BUFFER_LVALUE->yy_n_chars = YY_G(yy_n_chars) = 0; 1666 1667 else 1668 { 1669 yy_size_t num_to_read = 1670 YY_CURRENT_BUFFER_LVALUE->yy_buf_size - number_to_move - 1; 1671 1672 while ( num_to_read <= 0 ) 1673 { /* Not enough room in the buffer - grow it. */ 1674m4_ifdef( [[M4_YY_USES_REJECT]], 1675[[ 1676 YY_FATAL_ERROR( 1677"input buffer overflow, can't enlarge buffer because scanner uses REJECT" ); 1678]], 1679[[ 1680 /* just a shorter name for the current buffer */ 1681 YY_BUFFER_STATE b = YY_CURRENT_BUFFER_LVALUE; 1682 1683 int yy_c_buf_p_offset = 1684 (int) (YY_G(yy_c_buf_p) - b->yy_ch_buf); 1685 1686 if ( b->yy_is_our_buffer ) 1687 { 1688 yy_size_t new_size = b->yy_buf_size * 2; 1689 1690 if ( new_size <= 0 ) 1691 b->yy_buf_size += b->yy_buf_size / 8; 1692 else 1693 b->yy_buf_size *= 2; 1694 1695 b->yy_ch_buf = (char *) 1696 /* Include room in for 2 EOB chars. */ 1697 yyrealloc( (void *) b->yy_ch_buf, 1698 b->yy_buf_size + 2 M4_YY_CALL_LAST_ARG ); 1699 } 1700 else 1701 /* Can't grow it, we don't own it. */ 1702 b->yy_ch_buf = 0; 1703 1704 if ( ! b->yy_ch_buf ) 1705 YY_FATAL_ERROR( 1706 "fatal error - scanner input buffer overflow" ); 1707 1708 YY_G(yy_c_buf_p) = &b->yy_ch_buf[yy_c_buf_p_offset]; 1709 1710 num_to_read = YY_CURRENT_BUFFER_LVALUE->yy_buf_size - 1711 number_to_move - 1; 1712]]) 1713 } 1714 1715 if ( num_to_read > YY_READ_BUF_SIZE ) 1716 num_to_read = YY_READ_BUF_SIZE; 1717 1718 /* Read in more data. */ 1719 YY_INPUT( (&YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[number_to_move]), 1720 YY_G(yy_n_chars), num_to_read ); 1721 1722 YY_CURRENT_BUFFER_LVALUE->yy_n_chars = YY_G(yy_n_chars); 1723 } 1724 1725 if ( YY_G(yy_n_chars) == 0 ) 1726 { 1727 if ( number_to_move == YY_MORE_ADJ ) 1728 { 1729 ret_val = EOB_ACT_END_OF_FILE; 1730 yyrestart( yyin M4_YY_CALL_LAST_ARG); 1731 } 1732 1733 else 1734 { 1735 ret_val = EOB_ACT_LAST_MATCH; 1736 YY_CURRENT_BUFFER_LVALUE->yy_buffer_status = 1737 YY_BUFFER_EOF_PENDING; 1738 } 1739 } 1740 1741 else 1742 ret_val = EOB_ACT_CONTINUE_SCAN; 1743 1744 if ((yy_size_t) (YY_G(yy_n_chars) + number_to_move) > YY_CURRENT_BUFFER_LVALUE->yy_buf_size) { 1745 /* Extend the array by 50%, plus the number we really need. */ 1746 yy_size_t new_size = YY_G(yy_n_chars) + number_to_move + (YY_G(yy_n_chars) >> 1); 1747 YY_CURRENT_BUFFER_LVALUE->yy_ch_buf = (char *) yyrealloc( 1748 (void *) YY_CURRENT_BUFFER_LVALUE->yy_ch_buf, new_size M4_YY_CALL_LAST_ARG ); 1749 if ( ! YY_CURRENT_BUFFER_LVALUE->yy_ch_buf ) 1750 YY_FATAL_ERROR( "out of dynamic memory in yy_get_next_buffer()" ); 1751 /* "- 2" to take care of EOB's */ 1752 YY_CURRENT_BUFFER_LVALUE->yy_buf_size = (int) (new_size - 2); 1753 } 1754 1755 YY_G(yy_n_chars) += number_to_move; 1756 YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[YY_G(yy_n_chars)] = YY_END_OF_BUFFER_CHAR; 1757 YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[YY_G(yy_n_chars) + 1] = YY_END_OF_BUFFER_CHAR; 1758 1759 YY_G(yytext_ptr) = &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[0]; 1760 1761 return ret_val; 1762} 1763]]) 1764 1765/* yy_get_previous_state - get the state just before the EOB char was reached */ 1766 1767%if-c-only 1768%not-for-header 1769 static yy_state_type yy_get_previous_state YYFARGS0(void) 1770%endif 1771%if-c++-only 1772 yy_state_type yyFlexLexer::yy_get_previous_state() 1773%endif 1774{ 1775 yy_state_type yy_current_state; 1776 char *yy_cp; 1777 M4_YY_DECL_GUTS_VAR(); 1778 1779%% [15.0] code to get the start state into yy_current_state goes here 1780 1781 for ( yy_cp = YY_G(yytext_ptr) + YY_MORE_ADJ; yy_cp < YY_G(yy_c_buf_p); ++yy_cp ) 1782 { 1783%% [16.0] code to find the next state goes here 1784 } 1785 1786 return yy_current_state; 1787} 1788 1789 1790/* yy_try_NUL_trans - try to make a transition on the NUL character 1791 * 1792 * synopsis 1793 * next_state = yy_try_NUL_trans( current_state ); 1794 */ 1795%if-c-only 1796 static yy_state_type yy_try_NUL_trans YYFARGS1( yy_state_type, yy_current_state) 1797%endif 1798%if-c++-only 1799 yy_state_type yyFlexLexer::yy_try_NUL_trans( yy_state_type yy_current_state ) 1800%endif 1801{ 1802 int yy_is_jam; 1803 M4_YY_DECL_GUTS_VAR(); /* This var may be unused depending upon options. */ 1804%% [17.0] code to find the next state, and perhaps do backing up, goes here 1805 1806 M4_YY_NOOP_GUTS_VAR(); 1807 return yy_is_jam ? 0 : yy_current_state; 1808} 1809 1810 1811%if-c-only 1812m4_ifdef( [[M4_YY_NO_UNPUT]],, 1813[[ 1814 static void yyunput YYFARGS2( int,c, char *,yy_bp) 1815%endif 1816%if-c++-only 1817 void yyFlexLexer::yyunput( int c, char* yy_bp) 1818%endif 1819{ 1820 char *yy_cp; 1821 M4_YY_DECL_GUTS_VAR(); 1822 1823 yy_cp = YY_G(yy_c_buf_p); 1824 1825 /* undo effects of setting up yytext */ 1826 *yy_cp = YY_G(yy_hold_char); 1827 1828 if ( yy_cp < YY_CURRENT_BUFFER_LVALUE->yy_ch_buf + 2 ) 1829 { /* need to shift things up to make room */ 1830 /* +2 for EOB chars. */ 1831 yy_size_t number_to_move = YY_G(yy_n_chars) + 2; 1832 char *dest = &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[ 1833 YY_CURRENT_BUFFER_LVALUE->yy_buf_size + 2]; 1834 char *source = 1835 &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[number_to_move]; 1836 1837 while ( source > YY_CURRENT_BUFFER_LVALUE->yy_ch_buf ) 1838 *--dest = *--source; 1839 1840 yy_cp += (int) (dest - source); 1841 yy_bp += (int) (dest - source); 1842 YY_CURRENT_BUFFER_LVALUE->yy_n_chars = 1843 YY_G(yy_n_chars) = YY_CURRENT_BUFFER_LVALUE->yy_buf_size; 1844 1845 if ( yy_cp < YY_CURRENT_BUFFER_LVALUE->yy_ch_buf + 2 ) 1846 YY_FATAL_ERROR( "flex scanner push-back overflow" ); 1847 } 1848 1849 *--yy_cp = (char) c; 1850 1851%% [18.0] update yylineno here 1852m4_ifdef( [[M4_YY_USE_LINENO]], 1853[[ 1854 if ( c == '\n' ){ 1855 --yylineno; 1856 } 1857]]) 1858 1859 YY_G(yytext_ptr) = yy_bp; 1860 YY_G(yy_hold_char) = *yy_cp; 1861 YY_G(yy_c_buf_p) = yy_cp; 1862} 1863%if-c-only 1864]]) 1865%endif 1866 1867%if-c-only 1868#ifndef YY_NO_INPUT 1869#ifdef __cplusplus 1870 static int yyinput YYFARGS0(void) 1871#else 1872 static int input YYFARGS0(void) 1873#endif 1874 1875%endif 1876%if-c++-only 1877 int yyFlexLexer::yyinput() 1878%endif 1879{ 1880 int c; 1881 M4_YY_DECL_GUTS_VAR(); 1882 1883 *YY_G(yy_c_buf_p) = YY_G(yy_hold_char); 1884 1885 if ( *YY_G(yy_c_buf_p) == YY_END_OF_BUFFER_CHAR ) 1886 { 1887 /* yy_c_buf_p now points to the character we want to return. 1888 * If this occurs *before* the EOB characters, then it's a 1889 * valid NUL; if not, then we've hit the end of the buffer. 1890 */ 1891 if ( YY_G(yy_c_buf_p) < &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[YY_G(yy_n_chars)] ) 1892 /* This was really a NUL. */ 1893 *YY_G(yy_c_buf_p) = '\0'; 1894 1895 else 1896 { /* need more input */ 1897 yy_size_t offset = YY_G(yy_c_buf_p) - YY_G(yytext_ptr); 1898 ++YY_G(yy_c_buf_p); 1899 1900 switch ( yy_get_next_buffer( M4_YY_CALL_ONLY_ARG ) ) 1901 { 1902 case EOB_ACT_LAST_MATCH: 1903 /* This happens because yy_g_n_b() 1904 * sees that we've accumulated a 1905 * token and flags that we need to 1906 * try matching the token before 1907 * proceeding. But for input(), 1908 * there's no matching to consider. 1909 * So convert the EOB_ACT_LAST_MATCH 1910 * to EOB_ACT_END_OF_FILE. 1911 */ 1912 1913 /* Reset buffer status. */ 1914 yyrestart( yyin M4_YY_CALL_LAST_ARG); 1915 1916 /*FALLTHROUGH*/ 1917 1918 case EOB_ACT_END_OF_FILE: 1919 { 1920 if ( yywrap( M4_YY_CALL_ONLY_ARG ) ) 1921 return EOF; 1922 1923 if ( ! YY_G(yy_did_buffer_switch_on_eof) ) 1924 YY_NEW_FILE; 1925#ifdef __cplusplus 1926 return yyinput(M4_YY_CALL_ONLY_ARG); 1927#else 1928 return input(M4_YY_CALL_ONLY_ARG); 1929#endif 1930 } 1931 1932 case EOB_ACT_CONTINUE_SCAN: 1933 YY_G(yy_c_buf_p) = YY_G(yytext_ptr) + offset; 1934 break; 1935 } 1936 } 1937 } 1938 1939 c = *(unsigned char *) YY_G(yy_c_buf_p); /* cast for 8-bit char's */ 1940 *YY_G(yy_c_buf_p) = '\0'; /* preserve yytext */ 1941 YY_G(yy_hold_char) = *++YY_G(yy_c_buf_p); 1942 1943%% [19.0] update BOL and yylineno 1944 1945 return c; 1946} 1947%if-c-only 1948#endif /* ifndef YY_NO_INPUT */ 1949%endif 1950 1951/** Immediately switch to a different input stream. 1952 * @param input_file A readable stream. 1953 * M4_YY_DOC_PARAM 1954 * @note This function does not reset the start condition to @c INITIAL . 1955 */ 1956%if-c-only 1957 void yyrestart YYFARGS1( FILE *,input_file) 1958%endif 1959%if-c++-only 1960 void yyFlexLexer::yyrestart( std::istream* input_file ) 1961%endif 1962{ 1963 M4_YY_DECL_GUTS_VAR(); 1964 1965 if ( ! YY_CURRENT_BUFFER ){ 1966 yyensure_buffer_stack (M4_YY_CALL_ONLY_ARG); 1967 YY_CURRENT_BUFFER_LVALUE = 1968 yy_create_buffer( yyin, YY_BUF_SIZE M4_YY_CALL_LAST_ARG); 1969 } 1970 1971 yy_init_buffer( YY_CURRENT_BUFFER, input_file M4_YY_CALL_LAST_ARG); 1972 yy_load_buffer_state( M4_YY_CALL_ONLY_ARG ); 1973} 1974 1975/** Switch to a different input buffer. 1976 * @param new_buffer The new input buffer. 1977 * M4_YY_DOC_PARAM 1978 */ 1979%if-c-only 1980 void yy_switch_to_buffer YYFARGS1( YY_BUFFER_STATE ,new_buffer) 1981%endif 1982%if-c++-only 1983 void yyFlexLexer::yy_switch_to_buffer( YY_BUFFER_STATE new_buffer ) 1984%endif 1985{ 1986 M4_YY_DECL_GUTS_VAR(); 1987 1988 /* TODO. We should be able to replace this entire function body 1989 * with 1990 * yypop_buffer_state(); 1991 * yypush_buffer_state(new_buffer); 1992 */ 1993 yyensure_buffer_stack (M4_YY_CALL_ONLY_ARG); 1994 if ( YY_CURRENT_BUFFER == new_buffer ) 1995 return; 1996 1997 if ( YY_CURRENT_BUFFER ) 1998 { 1999 /* Flush out information for old buffer. */ 2000 *YY_G(yy_c_buf_p) = YY_G(yy_hold_char); 2001 YY_CURRENT_BUFFER_LVALUE->yy_buf_pos = YY_G(yy_c_buf_p); 2002 YY_CURRENT_BUFFER_LVALUE->yy_n_chars = YY_G(yy_n_chars); 2003 } 2004 2005 YY_CURRENT_BUFFER_LVALUE = new_buffer; 2006 yy_load_buffer_state( M4_YY_CALL_ONLY_ARG ); 2007 2008 /* We don't actually know whether we did this switch during 2009 * EOF (yywrap()) processing, but the only time this flag 2010 * is looked at is after yywrap() is called, so it's safe 2011 * to go ahead and always set it. 2012 */ 2013 YY_G(yy_did_buffer_switch_on_eof) = 1; 2014} 2015 2016 2017%if-c-only 2018static void yy_load_buffer_state YYFARGS0(void) 2019%endif 2020%if-c++-only 2021 void yyFlexLexer::yy_load_buffer_state() 2022%endif 2023{ 2024 M4_YY_DECL_GUTS_VAR(); 2025 YY_G(yy_n_chars) = YY_CURRENT_BUFFER_LVALUE->yy_n_chars; 2026 YY_G(yytext_ptr) = YY_G(yy_c_buf_p) = YY_CURRENT_BUFFER_LVALUE->yy_buf_pos; 2027 yyin = YY_CURRENT_BUFFER_LVALUE->yy_input_file; 2028 YY_G(yy_hold_char) = *YY_G(yy_c_buf_p); 2029} 2030 2031/** Allocate and initialize an input buffer state. 2032 * @param file A readable stream. 2033 * @param size The character buffer size in bytes. When in doubt, use @c YY_BUF_SIZE. 2034 * M4_YY_DOC_PARAM 2035 * @return the allocated buffer state. 2036 */ 2037%if-c-only 2038 YY_BUFFER_STATE yy_create_buffer YYFARGS2( FILE *,file, int ,size) 2039%endif 2040%if-c++-only 2041 YY_BUFFER_STATE yyFlexLexer::yy_create_buffer( std::istream* file, int size ) 2042%endif 2043{ 2044 YY_BUFFER_STATE b; 2045 m4_dnl M4_YY_DECL_GUTS_VAR(); 2046 2047 b = (YY_BUFFER_STATE) yyalloc( sizeof( struct yy_buffer_state ) M4_YY_CALL_LAST_ARG ); 2048 if ( ! b ) 2049 YY_FATAL_ERROR( "out of dynamic memory in yy_create_buffer()" ); 2050 2051 b->yy_buf_size = size; 2052 2053 /* yy_ch_buf has to be 2 characters longer than the size given because 2054 * we need to put in 2 end-of-buffer characters. 2055 */ 2056 b->yy_ch_buf = (char *) yyalloc( b->yy_buf_size + 2 M4_YY_CALL_LAST_ARG ); 2057 if ( ! b->yy_ch_buf ) 2058 YY_FATAL_ERROR( "out of dynamic memory in yy_create_buffer()" ); 2059 2060 b->yy_is_our_buffer = 1; 2061 2062 yy_init_buffer( b, file M4_YY_CALL_LAST_ARG); 2063 2064 return b; 2065} 2066 2067/** Destroy the buffer. 2068 * @param b a buffer created with yy_create_buffer() 2069 * M4_YY_DOC_PARAM 2070 */ 2071%if-c-only 2072 void yy_delete_buffer YYFARGS1( YY_BUFFER_STATE ,b) 2073%endif 2074%if-c++-only 2075 void yyFlexLexer::yy_delete_buffer( YY_BUFFER_STATE b ) 2076%endif 2077{ 2078 M4_YY_DECL_GUTS_VAR(); 2079 2080 if ( ! b ) 2081 return; 2082 2083 if ( b == YY_CURRENT_BUFFER ) /* Not sure if we should pop here. */ 2084 YY_CURRENT_BUFFER_LVALUE = (YY_BUFFER_STATE) 0; 2085 2086 if ( b->yy_is_our_buffer ) 2087 yyfree( (void *) b->yy_ch_buf M4_YY_CALL_LAST_ARG ); 2088 2089 yyfree( (void *) b M4_YY_CALL_LAST_ARG ); 2090} 2091 2092 2093/* Initializes or reinitializes a buffer. 2094 * This function is sometimes called more than once on the same buffer, 2095 * such as during a yyrestart() or at EOF. 2096 */ 2097%if-c-only 2098 static void yy_init_buffer YYFARGS2( YY_BUFFER_STATE ,b, FILE *,file) 2099%endif 2100%if-c++-only 2101 void yyFlexLexer::yy_init_buffer( YY_BUFFER_STATE b, std::istream* file ) 2102%endif 2103 2104{ 2105 int oerrno = errno; 2106 M4_YY_DECL_GUTS_VAR(); 2107 2108 yy_flush_buffer( b M4_YY_CALL_LAST_ARG); 2109 2110 b->yy_input_file = file; 2111 b->yy_fill_buffer = 1; 2112 2113 /* If b is the current buffer, then yy_init_buffer was _probably_ 2114 * called from yyrestart() or through yy_get_next_buffer. 2115 * In that case, we don't want to reset the lineno or column. 2116 */ 2117 if (b != YY_CURRENT_BUFFER){ 2118 b->yy_bs_lineno = 1; 2119 b->yy_bs_column = 0; 2120 } 2121 2122%if-c-only 2123m4_ifdef( [[M4_YY_ALWAYS_INTERACTIVE]], 2124[[ 2125 b->yy_is_interactive = 1; 2126]], 2127[[ 2128 m4_ifdef( [[M4_YY_NEVER_INTERACTIVE]], 2129 [[ 2130 b->yy_is_interactive = 0; 2131 ]], 2132 [[ 2133 b->yy_is_interactive = file ? (isatty( fileno(file) ) > 0) : 0; 2134 ]]) 2135]]) 2136%endif 2137%if-c++-only 2138 b->yy_is_interactive = 0; 2139%endif 2140 errno = oerrno; 2141} 2142 2143/** Discard all buffered characters. On the next scan, YY_INPUT will be called. 2144 * @param b the buffer state to be flushed, usually @c YY_CURRENT_BUFFER. 2145 * M4_YY_DOC_PARAM 2146 */ 2147%if-c-only 2148 void yy_flush_buffer YYFARGS1( YY_BUFFER_STATE ,b) 2149%endif 2150%if-c++-only 2151 void yyFlexLexer::yy_flush_buffer( YY_BUFFER_STATE b ) 2152%endif 2153{ 2154 M4_YY_DECL_GUTS_VAR(); 2155 if ( ! b ) 2156 return; 2157 2158 b->yy_n_chars = 0; 2159 2160 /* We always need two end-of-buffer characters. The first causes 2161 * a transition to the end-of-buffer state. The second causes 2162 * a jam in that state. 2163 */ 2164 b->yy_ch_buf[0] = YY_END_OF_BUFFER_CHAR; 2165 b->yy_ch_buf[1] = YY_END_OF_BUFFER_CHAR; 2166 2167 b->yy_buf_pos = &b->yy_ch_buf[0]; 2168 2169 b->yy_at_bol = 1; 2170 b->yy_buffer_status = YY_BUFFER_NEW; 2171 2172 if ( b == YY_CURRENT_BUFFER ) 2173 yy_load_buffer_state( M4_YY_CALL_ONLY_ARG ); 2174} 2175 2176%if-c-or-c++ 2177/** Pushes the new state onto the stack. The new state becomes 2178 * the current state. This function will allocate the stack 2179 * if necessary. 2180 * @param new_buffer The new state. 2181 * M4_YY_DOC_PARAM 2182 */ 2183%if-c-only 2184void yypush_buffer_state YYFARGS1(YY_BUFFER_STATE,new_buffer) 2185%endif 2186%if-c++-only 2187void yyFlexLexer::yypush_buffer_state (YY_BUFFER_STATE new_buffer) 2188%endif 2189{ 2190 M4_YY_DECL_GUTS_VAR(); 2191 if (new_buffer == NULL) 2192 return; 2193 2194 yyensure_buffer_stack(M4_YY_CALL_ONLY_ARG); 2195 2196 /* This block is copied from yy_switch_to_buffer. */ 2197 if ( YY_CURRENT_BUFFER ) 2198 { 2199 /* Flush out information for old buffer. */ 2200 *YY_G(yy_c_buf_p) = YY_G(yy_hold_char); 2201 YY_CURRENT_BUFFER_LVALUE->yy_buf_pos = YY_G(yy_c_buf_p); 2202 YY_CURRENT_BUFFER_LVALUE->yy_n_chars = YY_G(yy_n_chars); 2203 } 2204 2205 /* Only push if top exists. Otherwise, replace top. */ 2206 if (YY_CURRENT_BUFFER) 2207 YY_G(yy_buffer_stack_top)++; 2208 YY_CURRENT_BUFFER_LVALUE = new_buffer; 2209 2210 /* copied from yy_switch_to_buffer. */ 2211 yy_load_buffer_state( M4_YY_CALL_ONLY_ARG ); 2212 YY_G(yy_did_buffer_switch_on_eof) = 1; 2213} 2214%endif 2215 2216 2217%if-c-or-c++ 2218/** Removes and deletes the top of the stack, if present. 2219 * The next element becomes the new top. 2220 * M4_YY_DOC_PARAM 2221 */ 2222%if-c-only 2223void yypop_buffer_state YYFARGS0(void) 2224%endif 2225%if-c++-only 2226void yyFlexLexer::yypop_buffer_state (void) 2227%endif 2228{ 2229 M4_YY_DECL_GUTS_VAR(); 2230 if (!YY_CURRENT_BUFFER) 2231 return; 2232 2233 yy_delete_buffer(YY_CURRENT_BUFFER M4_YY_CALL_LAST_ARG); 2234 YY_CURRENT_BUFFER_LVALUE = NULL; 2235 if (YY_G(yy_buffer_stack_top) > 0) 2236 --YY_G(yy_buffer_stack_top); 2237 2238 if (YY_CURRENT_BUFFER) { 2239 yy_load_buffer_state( M4_YY_CALL_ONLY_ARG ); 2240 YY_G(yy_did_buffer_switch_on_eof) = 1; 2241 } 2242} 2243%endif 2244 2245 2246%if-c-or-c++ 2247/* Allocates the stack if it does not exist. 2248 * Guarantees space for at least one push. 2249 */ 2250%if-c-only 2251static void yyensure_buffer_stack YYFARGS0(void) 2252%endif 2253%if-c++-only 2254void yyFlexLexer::yyensure_buffer_stack(void) 2255%endif 2256{ 2257 yy_size_t num_to_alloc; 2258 M4_YY_DECL_GUTS_VAR(); 2259 2260 if (!YY_G(yy_buffer_stack)) { 2261 2262 /* First allocation is just for 2 elements, since we don't know if this 2263 * scanner will even need a stack. We use 2 instead of 1 to avoid an 2264 * immediate realloc on the next call. 2265 */ 2266 num_to_alloc = 1; 2267 YY_G(yy_buffer_stack) = (struct yy_buffer_state**)yyalloc 2268 (num_to_alloc * sizeof(struct yy_buffer_state*) 2269 M4_YY_CALL_LAST_ARG); 2270 if ( ! YY_G(yy_buffer_stack) ) 2271 YY_FATAL_ERROR( "out of dynamic memory in yyensure_buffer_stack()" ); 2272 2273 2274 memset(YY_G(yy_buffer_stack), 0, num_to_alloc * sizeof(struct yy_buffer_state*)); 2275 2276 YY_G(yy_buffer_stack_max) = num_to_alloc; 2277 YY_G(yy_buffer_stack_top) = 0; 2278 return; 2279 } 2280 2281 if (YY_G(yy_buffer_stack_top) >= (YY_G(yy_buffer_stack_max)) - 1){ 2282 2283 /* Increase the buffer to prepare for a possible push. */ 2284 int grow_size = 8 /* arbitrary grow size */; 2285 2286 num_to_alloc = YY_G(yy_buffer_stack_max) + grow_size; 2287 YY_G(yy_buffer_stack) = (struct yy_buffer_state**)yyrealloc 2288 (YY_G(yy_buffer_stack), 2289 num_to_alloc * sizeof(struct yy_buffer_state*) 2290 M4_YY_CALL_LAST_ARG); 2291 if ( ! YY_G(yy_buffer_stack) ) 2292 YY_FATAL_ERROR( "out of dynamic memory in yyensure_buffer_stack()" ); 2293 2294 /* zero only the new slots.*/ 2295 memset(YY_G(yy_buffer_stack) + YY_G(yy_buffer_stack_max), 0, grow_size * sizeof(struct yy_buffer_state*)); 2296 YY_G(yy_buffer_stack_max) = num_to_alloc; 2297 } 2298} 2299%endif 2300 2301 2302 2303 2304m4_ifdef( [[M4_YY_NO_SCAN_BUFFER]],, 2305[[ 2306%if-c-only 2307/** Setup the input buffer state to scan directly from a user-specified character buffer. 2308 * @param base the character buffer 2309 * @param size the size in bytes of the character buffer 2310 * M4_YY_DOC_PARAM 2311 * @return the newly allocated buffer state object. 2312 */ 2313YY_BUFFER_STATE yy_scan_buffer YYFARGS2( char *,base, yy_size_t ,size) 2314{ 2315 YY_BUFFER_STATE b; 2316 m4_dnl M4_YY_DECL_GUTS_VAR(); 2317 2318 if ( size < 2 || 2319 base[size-2] != YY_END_OF_BUFFER_CHAR || 2320 base[size-1] != YY_END_OF_BUFFER_CHAR ) 2321 /* They forgot to leave room for the EOB's. */ 2322 return 0; 2323 2324 b = (YY_BUFFER_STATE) yyalloc( sizeof( struct yy_buffer_state ) M4_YY_CALL_LAST_ARG ); 2325 if ( ! b ) 2326 YY_FATAL_ERROR( "out of dynamic memory in yy_scan_buffer()" ); 2327 2328 b->yy_buf_size = size - 2; /* "- 2" to take care of EOB's */ 2329 b->yy_buf_pos = b->yy_ch_buf = base; 2330 b->yy_is_our_buffer = 0; 2331 b->yy_input_file = 0; 2332 b->yy_n_chars = b->yy_buf_size; 2333 b->yy_is_interactive = 0; 2334 b->yy_at_bol = 1; 2335 b->yy_fill_buffer = 0; 2336 b->yy_buffer_status = YY_BUFFER_NEW; 2337 2338 yy_switch_to_buffer( b M4_YY_CALL_LAST_ARG ); 2339 2340 return b; 2341} 2342%endif 2343]]) 2344 2345 2346m4_ifdef( [[M4_YY_NO_SCAN_STRING]],, 2347[[ 2348%if-c-only 2349/** Setup the input buffer state to scan a string. The next call to yylex() will 2350 * scan from a @e copy of @a str. 2351 * @param yystr a NUL-terminated string to scan 2352 * M4_YY_DOC_PARAM 2353 * @return the newly allocated buffer state object. 2354 * @note If you want to scan bytes that may contain NUL values, then use 2355 * yy_scan_bytes() instead. 2356 */ 2357YY_BUFFER_STATE yy_scan_string YYFARGS1( yyconst char *, yystr) 2358{ 2359 m4_dnl M4_YY_DECL_GUTS_VAR(); 2360 2361 return yy_scan_bytes( yystr, strlen(yystr) M4_YY_CALL_LAST_ARG); 2362} 2363%endif 2364]]) 2365 2366 2367m4_ifdef( [[M4_YY_NO_SCAN_BYTES]],, 2368[[ 2369%if-c-only 2370/** Setup the input buffer state to scan the given bytes. The next call to yylex() will 2371 * scan from a @e copy of @a bytes. 2372 * @param yybytes the byte buffer to scan 2373 * @param _yybytes_len the number of bytes in the buffer pointed to by @a bytes. 2374 * M4_YY_DOC_PARAM 2375 * @return the newly allocated buffer state object. 2376 */ 2377YY_BUFFER_STATE yy_scan_bytes YYFARGS2( yyconst char *,yybytes, yy_size_t ,_yybytes_len) 2378{ 2379 YY_BUFFER_STATE b; 2380 char *buf; 2381 yy_size_t n; 2382 yy_size_t i; 2383 m4_dnl M4_YY_DECL_GUTS_VAR(); 2384 2385 /* Get memory for full buffer, including space for trailing EOB's. */ 2386 n = _yybytes_len + 2; 2387 buf = (char *) yyalloc( n M4_YY_CALL_LAST_ARG ); 2388 if ( ! buf ) 2389 YY_FATAL_ERROR( "out of dynamic memory in yy_scan_bytes()" ); 2390 2391 for ( i = 0; i < _yybytes_len; ++i ) 2392 buf[i] = yybytes[i]; 2393 2394 buf[_yybytes_len] = buf[_yybytes_len+1] = YY_END_OF_BUFFER_CHAR; 2395 2396 b = yy_scan_buffer( buf, n M4_YY_CALL_LAST_ARG); 2397 if ( ! b ) 2398 YY_FATAL_ERROR( "bad buffer in yy_scan_bytes()" ); 2399 2400 /* It's okay to grow etc. this buffer, and we should throw it 2401 * away when we're done. 2402 */ 2403 b->yy_is_our_buffer = 1; 2404 2405 return b; 2406} 2407%endif 2408]]) 2409 2410 2411m4_ifdef( [[M4_YY_NO_PUSH_STATE]],, 2412[[ 2413%if-c-only 2414 static void yy_push_state YYFARGS1( int ,new_state) 2415%endif 2416%if-c++-only 2417 void yyFlexLexer::yy_push_state( int new_state ) 2418%endif 2419{ 2420 M4_YY_DECL_GUTS_VAR(); 2421 if ( YY_G(yy_start_stack_ptr) >= YY_G(yy_start_stack_depth) ) 2422 { 2423 yy_size_t new_size; 2424 2425 YY_G(yy_start_stack_depth) += YY_START_STACK_INCR; 2426 new_size = YY_G(yy_start_stack_depth) * sizeof( int ); 2427 2428 if ( ! YY_G(yy_start_stack) ) 2429 YY_G(yy_start_stack) = (int *) yyalloc( new_size M4_YY_CALL_LAST_ARG ); 2430 2431 else 2432 YY_G(yy_start_stack) = (int *) yyrealloc( 2433 (void *) YY_G(yy_start_stack), new_size M4_YY_CALL_LAST_ARG ); 2434 2435 if ( ! YY_G(yy_start_stack) ) 2436 YY_FATAL_ERROR( "out of memory expanding start-condition stack" ); 2437 } 2438 2439 YY_G(yy_start_stack)[YY_G(yy_start_stack_ptr)++] = YY_START; 2440 2441 BEGIN(new_state); 2442} 2443]]) 2444 2445 2446m4_ifdef( [[M4_YY_NO_POP_STATE]],, 2447[[ 2448%if-c-only 2449 static void yy_pop_state YYFARGS0(void) 2450%endif 2451%if-c++-only 2452 void yyFlexLexer::yy_pop_state() 2453%endif 2454{ 2455 M4_YY_DECL_GUTS_VAR(); 2456 if ( --YY_G(yy_start_stack_ptr) < 0 ) 2457 YY_FATAL_ERROR( "start-condition stack underflow" ); 2458 2459 BEGIN(YY_G(yy_start_stack)[YY_G(yy_start_stack_ptr)]); 2460} 2461]]) 2462 2463 2464m4_ifdef( [[M4_YY_NO_TOP_STATE]],, 2465[[ 2466%if-c-only 2467 static int yy_top_state YYFARGS0(void) 2468%endif 2469%if-c++-only 2470 int yyFlexLexer::yy_top_state() 2471%endif 2472{ 2473 M4_YY_DECL_GUTS_VAR(); 2474 return YY_G(yy_start_stack)[YY_G(yy_start_stack_ptr) - 1]; 2475} 2476]]) 2477 2478#ifndef YY_EXIT_FAILURE 2479#define YY_EXIT_FAILURE 2 2480#endif 2481 2482%if-c-only 2483static void yy_fatal_error YYFARGS1(yyconst char*, msg) 2484{ 2485 m4_dnl M4_YY_DECL_GUTS_VAR(); 2486 (void) fprintf( stderr, "%s\n", msg ); 2487 exit( YY_EXIT_FAILURE ); 2488} 2489%endif 2490%if-c++-only 2491void yyFlexLexer::LexerError( yyconst char msg[] ) 2492{ 2493 M4_YY_DECL_GUTS_VAR(); 2494 std::cerr << msg << std::endl; 2495 exit( YY_EXIT_FAILURE ); 2496} 2497%endif 2498 2499/* Redefine yyless() so it works in section 3 code. */ 2500 2501#undef yyless 2502#define yyless(n) \ 2503 do \ 2504 { \ 2505 /* Undo effects of setting up yytext. */ \ 2506 int yyless_macro_arg = (n); \ 2507 YY_LESS_LINENO(yyless_macro_arg);\ 2508 yytext[yyleng] = YY_G(yy_hold_char); \ 2509 YY_G(yy_c_buf_p) = yytext + yyless_macro_arg; \ 2510 YY_G(yy_hold_char) = *YY_G(yy_c_buf_p); \ 2511 *YY_G(yy_c_buf_p) = '\0'; \ 2512 yyleng = yyless_macro_arg; \ 2513 } \ 2514 while ( 0 ) 2515 2516 2517 2518/* Accessor methods (get/set functions) to struct members. */ 2519 2520%if-c-only 2521%if-reentrant 2522m4_ifdef( [[M4_YY_NO_GET_EXTRA]],, 2523[[ 2524/** Get the user-defined data for this scanner. 2525 * M4_YY_DOC_PARAM 2526 */ 2527YY_EXTRA_TYPE yyget_extra YYFARGS0(void) 2528{ 2529 M4_YY_DECL_GUTS_VAR(); 2530 return yyextra; 2531} 2532]]) 2533%endif 2534 2535m4_ifdef( [[M4_YY_NO_GET_LINENO]],, 2536[[ 2537/** Get the current line number. 2538 * M4_YY_DOC_PARAM 2539 */ 2540int yyget_lineno YYFARGS0(void) 2541{ 2542 M4_YY_DECL_GUTS_VAR(); 2543 2544 m4_ifdef( [[M4_YY_REENTRANT]], 2545 [[ 2546 if (! YY_CURRENT_BUFFER) 2547 return 0; 2548 ]]) 2549 return yylineno; 2550} 2551]]) 2552 2553m4_ifdef( [[M4_YY_REENTRANT]], 2554[[ 2555m4_ifdef( [[M4_YY_NO_GET_COLUMN]],, 2556[[ 2557/** Get the current column number. 2558 * M4_YY_DOC_PARAM 2559 */ 2560int yyget_column YYFARGS0(void) 2561{ 2562 M4_YY_DECL_GUTS_VAR(); 2563 2564 m4_ifdef( [[M4_YY_REENTRANT]], 2565 [[ 2566 if (! YY_CURRENT_BUFFER) 2567 return 0; 2568 ]]) 2569 return yycolumn; 2570} 2571]]) 2572]]) 2573 2574m4_ifdef( [[M4_YY_NO_GET_IN]],, 2575[[ 2576/** Get the input stream. 2577 * M4_YY_DOC_PARAM 2578 */ 2579FILE *yyget_in YYFARGS0(void) 2580{ 2581 M4_YY_DECL_GUTS_VAR(); 2582 return yyin; 2583} 2584]]) 2585 2586m4_ifdef( [[M4_YY_NO_GET_OUT]],, 2587[[ 2588/** Get the output stream. 2589 * M4_YY_DOC_PARAM 2590 */ 2591FILE *yyget_out YYFARGS0(void) 2592{ 2593 M4_YY_DECL_GUTS_VAR(); 2594 return yyout; 2595} 2596]]) 2597 2598m4_ifdef( [[M4_YY_NO_GET_LENG]],, 2599[[ 2600/** Get the length of the current token. 2601 * M4_YY_DOC_PARAM 2602 */ 2603yy_size_t yyget_leng YYFARGS0(void) 2604{ 2605 M4_YY_DECL_GUTS_VAR(); 2606 return yyleng; 2607} 2608]]) 2609 2610/** Get the current token. 2611 * M4_YY_DOC_PARAM 2612 */ 2613m4_ifdef( [[M4_YY_NO_GET_TEXT]],, 2614[[ 2615char *yyget_text YYFARGS0(void) 2616{ 2617 M4_YY_DECL_GUTS_VAR(); 2618 return yytext; 2619} 2620]]) 2621 2622%if-reentrant 2623m4_ifdef( [[M4_YY_NO_SET_EXTRA]],, 2624[[ 2625/** Set the user-defined data. This data is never touched by the scanner. 2626 * @param user_defined The data to be associated with this scanner. 2627 * M4_YY_DOC_PARAM 2628 */ 2629void yyset_extra YYFARGS1( YY_EXTRA_TYPE ,user_defined) 2630{ 2631 M4_YY_DECL_GUTS_VAR(); 2632 yyextra = user_defined ; 2633} 2634]]) 2635%endif 2636 2637m4_ifdef( [[M4_YY_NO_SET_LINENO]],, 2638[[ 2639/** Set the current line number. 2640 * @param line_number 2641 * M4_YY_DOC_PARAM 2642 */ 2643void yyset_lineno YYFARGS1( int ,line_number) 2644{ 2645 M4_YY_DECL_GUTS_VAR(); 2646 2647 m4_ifdef( [[M4_YY_REENTRANT]], 2648 [[ 2649 /* lineno is only valid if an input buffer exists. */ 2650 if (! YY_CURRENT_BUFFER ) 2651 YY_FATAL_ERROR( "yyset_lineno called with no buffer" ); 2652 ]]) 2653 yylineno = line_number; 2654} 2655]]) 2656 2657m4_ifdef( [[M4_YY_REENTRANT]], 2658[[ 2659m4_ifdef( [[M4_YY_NO_SET_COLUMN]],, 2660[[ 2661/** Set the current column. 2662 * @param line_number 2663 * M4_YY_DOC_PARAM 2664 */ 2665void yyset_column YYFARGS1( int , column_no) 2666{ 2667 M4_YY_DECL_GUTS_VAR(); 2668 2669 m4_ifdef( [[M4_YY_REENTRANT]], 2670 [[ 2671 /* column is only valid if an input buffer exists. */ 2672 if (! YY_CURRENT_BUFFER ) 2673 YY_FATAL_ERROR( "yyset_column called with no buffer" ); 2674 ]]) 2675 yycolumn = column_no; 2676} 2677]]) 2678]]) 2679 2680 2681m4_ifdef( [[M4_YY_NO_SET_IN]],, 2682[[ 2683/** Set the input stream. This does not discard the current 2684 * input buffer. 2685 * @param in_str A readable stream. 2686 * M4_YY_DOC_PARAM 2687 * @see yy_switch_to_buffer 2688 */ 2689void yyset_in YYFARGS1( FILE * ,in_str) 2690{ 2691 M4_YY_DECL_GUTS_VAR(); 2692 yyin = in_str ; 2693} 2694]]) 2695 2696m4_ifdef( [[M4_YY_NO_SET_OUT]],, 2697[[ 2698void yyset_out YYFARGS1( FILE * ,out_str) 2699{ 2700 M4_YY_DECL_GUTS_VAR(); 2701 yyout = out_str ; 2702} 2703]]) 2704 2705 2706m4_ifdef( [[M4_YY_NO_GET_DEBUG]],, 2707[[ 2708int yyget_debug YYFARGS0(void) 2709{ 2710 M4_YY_DECL_GUTS_VAR(); 2711 return yy_flex_debug; 2712} 2713]]) 2714 2715m4_ifdef( [[M4_YY_NO_SET_DEBUG]],, 2716[[ 2717void yyset_debug YYFARGS1( int ,bdebug) 2718{ 2719 M4_YY_DECL_GUTS_VAR(); 2720 yy_flex_debug = bdebug ; 2721} 2722]]) 2723%endif 2724 2725%if-reentrant 2726/* Accessor methods for yylval and yylloc */ 2727 2728%if-bison-bridge 2729m4_ifdef( [[M4_YY_NO_GET_LVAL]],, 2730[[ 2731YYSTYPE * yyget_lval YYFARGS0(void) 2732{ 2733 M4_YY_DECL_GUTS_VAR(); 2734 return yylval; 2735} 2736]]) 2737 2738m4_ifdef( [[M4_YY_NO_SET_LVAL]],, 2739[[ 2740void yyset_lval YYFARGS1( YYSTYPE * ,yylval_param) 2741{ 2742 M4_YY_DECL_GUTS_VAR(); 2743 yylval = yylval_param; 2744} 2745]]) 2746 2747m4_ifdef( [[<M4_YY_BISON_LLOC>]], 2748[[ 2749 m4_ifdef( [[M4_YY_NO_GET_LLOC]],, 2750 [[ 2751YYLTYPE *yyget_lloc YYFARGS0(void) 2752{ 2753 M4_YY_DECL_GUTS_VAR(); 2754 return yylloc; 2755} 2756 ]]) 2757 2758 m4_ifdef( [[M4_YY_NO_SET_LLOC]],, 2759 [[ 2760void yyset_lloc YYFARGS1( YYLTYPE * ,yylloc_param) 2761{ 2762 M4_YY_DECL_GUTS_VAR(); 2763 yylloc = yylloc_param; 2764} 2765 ]]) 2766]]) 2767 2768%endif 2769 2770 2771/* User-visible API */ 2772 2773/* yylex_init is special because it creates the scanner itself, so it is 2774 * the ONLY reentrant function that doesn't take the scanner as the last argument. 2775 * That's why we explicitly handle the declaration, instead of using our macros. 2776 */ 2777m4_ifdef( [[M4_YY_NO_ANSI_FUNC_DEFS]], 2778[[ 2779int yylex_init( ptr_yy_globals ) 2780 yyscan_t* ptr_yy_globals; 2781]], 2782[[ 2783int yylex_init(yyscan_t* ptr_yy_globals) 2784]]) 2785{ 2786 if (ptr_yy_globals == NULL){ 2787 errno = EINVAL; 2788 return 1; 2789 } 2790 2791 *ptr_yy_globals = (yyscan_t) yyalloc ( sizeof( struct yyguts_t ), NULL ); 2792 2793 if (*ptr_yy_globals == NULL){ 2794 errno = ENOMEM; 2795 return 1; 2796 } 2797 2798 /* By setting to 0xAA, we expose bugs in yy_init_globals. Leave at 0x00 for releases. */ 2799 memset(*ptr_yy_globals,0x00,sizeof(struct yyguts_t)); 2800 2801 return yy_init_globals ( *ptr_yy_globals ); 2802} 2803 2804 2805/* yylex_init_extra has the same functionality as yylex_init, but follows the 2806 * convention of taking the scanner as the last argument. Note however, that 2807 * this is a *pointer* to a scanner, as it will be allocated by this call (and 2808 * is the reason, too, why this function also must handle its own declaration). 2809 * The user defined value in the first argument will be available to yyalloc in 2810 * the yyextra field. 2811 */ 2812m4_ifdef( [[M4_YY_NO_ANSI_FUNC_DEFS]], 2813[[ 2814int yylex_init_extra( yy_user_defined, ptr_yy_globals ) 2815 YY_EXTRA_TYPE yy_user_defined; 2816 yyscan_t* ptr_yy_globals; 2817]], 2818[[ 2819int yylex_init_extra( YY_EXTRA_TYPE yy_user_defined, yyscan_t* ptr_yy_globals ) 2820]]) 2821{ 2822 struct yyguts_t dummy_yyguts; 2823 2824 yyset_extra (yy_user_defined, &dummy_yyguts); 2825 2826 if (ptr_yy_globals == NULL){ 2827 errno = EINVAL; 2828 return 1; 2829 } 2830 2831 *ptr_yy_globals = (yyscan_t) yyalloc ( sizeof( struct yyguts_t ), &dummy_yyguts ); 2832 2833 if (*ptr_yy_globals == NULL){ 2834 errno = ENOMEM; 2835 return 1; 2836 } 2837 2838 /* By setting to 0xAA, we expose bugs in 2839 yy_init_globals. Leave at 0x00 for releases. */ 2840 memset(*ptr_yy_globals,0x00,sizeof(struct yyguts_t)); 2841 2842 yyset_extra (yy_user_defined, *ptr_yy_globals); 2843 2844 return yy_init_globals ( *ptr_yy_globals ); 2845} 2846 2847%endif if-c-only 2848 2849 2850%if-c-only 2851static int yy_init_globals YYFARGS0(void) 2852{ 2853 M4_YY_DECL_GUTS_VAR(); 2854 /* Initialization is the same as for the non-reentrant scanner. 2855 * This function is called from yylex_destroy(), so don't allocate here. 2856 */ 2857 2858m4_ifdef( [[M4_YY_USE_LINENO]], 2859[[ 2860 m4_ifdef( [[M4_YY_NOT_REENTRANT]], 2861 [[ 2862 /* We do not touch yylineno unless the option is enabled. */ 2863 yylineno = 1; 2864 ]]) 2865]]) 2866 YY_G(yy_buffer_stack) = 0; 2867 YY_G(yy_buffer_stack_top) = 0; 2868 YY_G(yy_buffer_stack_max) = 0; 2869 YY_G(yy_c_buf_p) = (char *) 0; 2870 YY_G(yy_init) = 0; 2871 YY_G(yy_start) = 0; 2872 2873m4_ifdef( [[M4_YY_HAS_START_STACK_VARS]], 2874[[ 2875 YY_G(yy_start_stack_ptr) = 0; 2876 YY_G(yy_start_stack_depth) = 0; 2877 YY_G(yy_start_stack) = NULL; 2878]]) 2879 2880m4_ifdef( [[M4_YY_USES_REJECT]], 2881[[ 2882 YY_G(yy_state_buf) = 0; 2883 YY_G(yy_state_ptr) = 0; 2884 YY_G(yy_full_match) = 0; 2885 YY_G(yy_lp) = 0; 2886]]) 2887 2888m4_ifdef( [[M4_YY_TEXT_IS_ARRAY]], 2889[[ 2890 YY_G(yytext_ptr) = 0; 2891 YY_G(yy_more_offset) = 0; 2892 YY_G(yy_prev_more_offset) = 0; 2893]]) 2894 2895/* Defined in main.c */ 2896#ifdef YY_STDINIT 2897 yyin = stdin; 2898 yyout = stdout; 2899#else 2900 yyin = (FILE *) 0; 2901 yyout = (FILE *) 0; 2902#endif 2903 2904 /* For future reference: Set errno on error, since we are called by 2905 * yylex_init() 2906 */ 2907 return 0; 2908} 2909%endif 2910 2911 2912%if-c-only SNIP! this currently causes conflicts with the c++ scanner 2913/* yylex_destroy is for both reentrant and non-reentrant scanners. */ 2914int yylex_destroy YYFARGS0(void) 2915{ 2916 M4_YY_DECL_GUTS_VAR(); 2917 2918 /* Pop the buffer stack, destroying each element. */ 2919 while(YY_CURRENT_BUFFER){ 2920 yy_delete_buffer( YY_CURRENT_BUFFER M4_YY_CALL_LAST_ARG ); 2921 YY_CURRENT_BUFFER_LVALUE = NULL; 2922 yypop_buffer_state(M4_YY_CALL_ONLY_ARG); 2923 } 2924 2925 /* Destroy the stack itself. */ 2926 yyfree(YY_G(yy_buffer_stack) M4_YY_CALL_LAST_ARG); 2927 YY_G(yy_buffer_stack) = NULL; 2928 2929m4_ifdef( [[M4_YY_HAS_START_STACK_VARS]], 2930[[ 2931 /* Destroy the start condition stack. */ 2932 yyfree( YY_G(yy_start_stack) M4_YY_CALL_LAST_ARG ); 2933 YY_G(yy_start_stack) = NULL; 2934]]) 2935 2936m4_ifdef( [[M4_YY_USES_REJECT]], 2937[[ 2938 yyfree ( YY_G(yy_state_buf) M4_YY_CALL_LAST_ARG); 2939 YY_G(yy_state_buf) = NULL; 2940]]) 2941 2942 /* Reset the globals. This is important in a non-reentrant scanner so the next time 2943 * yylex() is called, initialization will occur. */ 2944 yy_init_globals( M4_YY_CALL_ONLY_ARG); 2945 2946%if-reentrant 2947 /* Destroy the main struct (reentrant only). */ 2948 yyfree ( yyscanner M4_YY_CALL_LAST_ARG ); 2949 yyscanner = NULL; 2950%endif 2951 return 0; 2952} 2953%endif 2954 2955 2956m4_ifdef( [[M4_YY_NOT_IN_HEADER]], 2957[[ 2958/* 2959 * Internal utility routines. 2960 */ 2961]]) 2962 2963m4_ifdef( [[M4_YY_NOT_IN_HEADER]], 2964[[ 2965#ifndef yytext_ptr 2966static void yy_flex_strncpy YYFARGS3( char*,s1, yyconst char *,s2, int,n) 2967{ 2968 int i; 2969 for ( i = 0; i < n; ++i ) 2970 s1[i] = s2[i]; 2971} 2972#endif 2973]]) 2974 2975m4_ifdef( [[M4_YY_NOT_IN_HEADER]], 2976[[ 2977#ifdef YY_NEED_STRLEN 2978static int yy_flex_strlen YYFARGS1( yyconst char *,s) 2979{ 2980 int n; 2981 for ( n = 0; s[n]; ++n ) 2982 ; 2983 2984 return n; 2985} 2986#endif 2987]]) 2988 2989m4_ifdef( [[M4_YY_NO_FLEX_ALLOC]],, 2990[[ 2991void *yyalloc YYFARGS1( yy_size_t ,size) 2992{ 2993 return (void *) malloc( size ); 2994} 2995]]) 2996 2997m4_ifdef( [[M4_YY_NO_FLEX_REALLOC]],, 2998[[ 2999void *yyrealloc YYFARGS2( void *,ptr, yy_size_t ,size) 3000{ 3001 /* The cast to (char *) in the following accommodates both 3002 * implementations that use char* generic pointers, and those 3003 * that use void* generic pointers. It works with the latter 3004 * because both ANSI C and C++ allow castless assignment from 3005 * any pointer type to void*, and deal with argument conversions 3006 * as though doing an assignment. 3007 */ 3008 return (void *) realloc( (char *) ptr, size ); 3009} 3010]]) 3011 3012m4_ifdef( [[M4_YY_NO_FLEX_FREE]],, 3013[[ 3014void yyfree YYFARGS1( void *,ptr) 3015{ 3016 free( (char *) ptr ); /* see yyrealloc() for (char *) cast */ 3017} 3018]]) 3019 3020%if-tables-serialization definitions 3021m4preproc_include(`tables_shared.c') 3022 3023static int yytbl_read8 (void *v, struct yytbl_reader * rd) 3024{ 3025 errno = 0; 3026 if (fread (v, sizeof (flex_uint8_t), 1, rd->fp) != 1){ 3027 errno = EIO; 3028 return -1; 3029 } 3030 rd->bread += sizeof(flex_uint8_t); 3031 return 0; 3032} 3033 3034static int yytbl_read16 (void *v, struct yytbl_reader * rd) 3035{ 3036 errno = 0; 3037 if (fread (v, sizeof (flex_uint16_t), 1, rd->fp) != 1){ 3038 errno = EIO; 3039 return -1; 3040 } 3041 *((flex_uint16_t *) v) = ntohs (*((flex_uint16_t *) v)); 3042 rd->bread += sizeof(flex_uint16_t); 3043 return 0; 3044} 3045 3046static int yytbl_read32 (void *v, struct yytbl_reader * rd) 3047{ 3048 errno = 0; 3049 if (fread (v, sizeof (flex_uint32_t), 1, rd->fp) != 1){ 3050 errno = EIO; 3051 return -1; 3052 } 3053 *((flex_uint32_t *) v) = ntohl (*((flex_uint32_t *) v)); 3054 rd->bread += sizeof(flex_uint32_t); 3055 return 0; 3056} 3057 3058/** Read the header */ 3059static int yytbl_hdr_read YYFARGS2(struct yytbl_hdr *, th, struct yytbl_reader *, rd) 3060{ 3061 int bytes; 3062 memset (th, 0, sizeof (struct yytbl_hdr)); 3063 3064 if (yytbl_read32 (&(th->th_magic), rd) != 0) 3065 return -1; 3066 3067 if (th->th_magic != YYTBL_MAGIC){ 3068 YY_FATAL_ERROR( "bad magic number" ); /* TODO: not fatal. */ 3069 return -1; 3070 } 3071 3072 if (yytbl_read32 (&(th->th_hsize), rd) != 0 3073 || yytbl_read32 (&(th->th_ssize), rd) != 0 3074 || yytbl_read16 (&(th->th_flags), rd) != 0) 3075 return -1; 3076 3077 /* Sanity check on header size. Greater than 1k suggests some funny business. */ 3078 if (th->th_hsize < 16 || th->th_hsize > 1024){ 3079 YY_FATAL_ERROR( "insane header size detected" ); /* TODO: not fatal. */ 3080 return -1; 3081 } 3082 3083 /* Allocate enough space for the version and name fields */ 3084 bytes = th->th_hsize - 14; 3085 th->th_version = (char *) yyalloc (bytes M4_YY_CALL_LAST_ARG); 3086 if ( ! th->th_version ) 3087 YY_FATAL_ERROR( "out of dynamic memory in yytbl_hdr_read()" ); 3088 3089 /* we read it all into th_version, and point th_name into that data */ 3090 if (fread (th->th_version, 1, bytes, rd->fp) != bytes){ 3091 errno = EIO; 3092 yyfree(th->th_version M4_YY_CALL_LAST_ARG); 3093 th->th_version = NULL; 3094 return -1; 3095 } 3096 else 3097 rd->bread += bytes; 3098 3099 th->th_name = th->th_version + strlen (th->th_version) + 1; 3100 return 0; 3101} 3102 3103/** lookup id in the dmap list. 3104 * @param dmap pointer to first element in list 3105 * @return NULL if not found. 3106 */ 3107static struct yytbl_dmap *yytbl_dmap_lookup YYFARGS2(struct yytbl_dmap *, dmap, 3108 int, id) 3109{ 3110 while (dmap->dm_id) 3111 if (dmap->dm_id == id) 3112 return dmap; 3113 else 3114 dmap++; 3115 return NULL; 3116} 3117 3118/** Read a table while mapping its contents to the local array. 3119 * @param dmap used to performing mapping 3120 * @return 0 on success 3121 */ 3122static int yytbl_data_load YYFARGS2(struct yytbl_dmap *, dmap, struct yytbl_reader*, rd) 3123{ 3124 struct yytbl_data td; 3125 struct yytbl_dmap *transdmap=0; 3126 int len, i, rv, inner_loop_count; 3127 void *p=0; 3128 3129 memset (&td, 0, sizeof (struct yytbl_data)); 3130 3131 if (yytbl_read16 (&td.td_id, rd) != 0 3132 || yytbl_read16 (&td.td_flags, rd) != 0 3133 || yytbl_read32 (&td.td_hilen, rd) != 0 3134 || yytbl_read32 (&td.td_lolen, rd) != 0) 3135 return -1; 3136 3137 /* Lookup the map for the transition table so we have it in case we need it 3138 * inside the loop below. This scanner might not even have a transition 3139 * table, which is ok. 3140 */ 3141 transdmap = yytbl_dmap_lookup (dmap, YYTD_ID_TRANSITION M4_YY_CALL_LAST_ARG); 3142 3143 if ((dmap = yytbl_dmap_lookup (dmap, td.td_id M4_YY_CALL_LAST_ARG)) == NULL){ 3144 YY_FATAL_ERROR( "table id not found in map." ); /* TODO: not fatal. */ 3145 return -1; 3146 } 3147 3148 /* Allocate space for table. 3149 * The --full yy_transition table is a special case, since we 3150 * need the dmap.dm_sz entry to tell us the sizeof the individual 3151 * struct members. 3152 */ 3153 { 3154 size_t bytes; 3155 3156 if ((td.td_flags & YYTD_STRUCT)) 3157 bytes = sizeof(struct yy_trans_info) * td.td_lolen * (td.td_hilen ? td.td_hilen : 1); 3158 else 3159 bytes = td.td_lolen * (td.td_hilen ? td.td_hilen : 1) * dmap->dm_sz; 3160 3161 if(M4_YY_TABLES_VERIFY) 3162 /* We point to the array itself */ 3163 p = dmap->dm_arr; 3164 else 3165 /* We point to the address of a pointer. */ 3166 *dmap->dm_arr = p = (void *) yyalloc (bytes M4_YY_CALL_LAST_ARG); 3167 if ( ! p ) 3168 YY_FATAL_ERROR( "out of dynamic memory in yytbl_data_load()" ); 3169 } 3170 3171 /* If it's a struct, we read 2 integers to get one element */ 3172 if ((td.td_flags & YYTD_STRUCT) != 0) 3173 inner_loop_count = 2; 3174 else 3175 inner_loop_count = 1; 3176 3177 /* read and map each element. 3178 * This loop iterates once for each element of the td_data array. 3179 * Notice that we increment 'i' in the inner loop. 3180 */ 3181 len = yytbl_calc_total_len (&td); 3182 for (i = 0; i < len; ){ 3183 int j; 3184 3185 3186 /* This loop really executes exactly 1 or 2 times. 3187 * The second time is to handle the second member of the 3188 * YYTD_STRUCT for the yy_transition array. 3189 */ 3190 for (j = 0; j < inner_loop_count; j++, i++) { 3191 flex_int32_t t32; 3192 3193 /* read into t32 no matter what the real size is. */ 3194 { 3195 flex_int16_t t16; 3196 flex_int8_t t8; 3197 3198 switch (YYTDFLAGS2BYTES (td.td_flags)) { 3199 case sizeof (flex_int32_t): 3200 rv = yytbl_read32 (&t32, rd); 3201 break; 3202 case sizeof (flex_int16_t): 3203 rv = yytbl_read16 (&t16, rd); 3204 t32 = t16; 3205 break; 3206 case sizeof (flex_int8_t): 3207 rv = yytbl_read8 (&t8, rd); 3208 t32 = t8; 3209 break; 3210 default: 3211 YY_FATAL_ERROR( "invalid td_flags" ); /* TODO: not fatal. */ 3212 return -1; 3213 } 3214 } 3215 if (rv != 0) 3216 return -1; 3217 3218 /* copy into the deserialized array... */ 3219 3220 if ((td.td_flags & YYTD_STRUCT)) { 3221 /* t32 is the j'th member of a two-element struct. */ 3222 void *v; 3223 3224 v = j == 0 ? &(((struct yy_trans_info *) p)->yy_verify) 3225 : &(((struct yy_trans_info *) p)->yy_nxt); 3226 3227 switch (dmap->dm_sz) { 3228 case sizeof (flex_int32_t): 3229 if (M4_YY_TABLES_VERIFY){ 3230 if( ((flex_int32_t *) v)[0] != (flex_int32_t) t32) 3231 YY_FATAL_ERROR( "tables verification failed at YYTD_STRUCT flex_int32_t" ); 3232 }else 3233 ((flex_int32_t *) v)[0] = (flex_int32_t) t32; 3234 break; 3235 case sizeof (flex_int16_t): 3236 if (M4_YY_TABLES_VERIFY ){ 3237 if(((flex_int16_t *) v)[0] != (flex_int16_t) t32) 3238 YY_FATAL_ERROR( "tables verification failed at YYTD_STRUCT flex_int16_t" ); 3239 }else 3240 ((flex_int16_t *) v)[0] = (flex_int16_t) t32; 3241 break; 3242 case sizeof(flex_int8_t): 3243 if (M4_YY_TABLES_VERIFY ){ 3244 if( ((flex_int8_t *) v)[0] != (flex_int8_t) t32) 3245 YY_FATAL_ERROR( "tables verification failed at YYTD_STRUCT flex_int8_t" ); 3246 }else 3247 ((flex_int8_t *) v)[0] = (flex_int8_t) t32; 3248 break; 3249 default: 3250 YY_FATAL_ERROR( "invalid dmap->dm_sz for struct" ); /* TODO: not fatal. */ 3251 return -1; 3252 } 3253 3254 /* if we're done with j, increment p */ 3255 if (j == 1) 3256 p = (struct yy_trans_info *) p + 1; 3257 } 3258 else if ((td.td_flags & YYTD_PTRANS)) { 3259 /* t32 is an index into the transition array. */ 3260 struct yy_trans_info *v; 3261 3262 3263 if (!transdmap){ 3264 YY_FATAL_ERROR( "transition table not found" ); /* TODO: not fatal. */ 3265 return -1; 3266 } 3267 3268 if( M4_YY_TABLES_VERIFY) 3269 v = &(((struct yy_trans_info *) (transdmap->dm_arr))[t32]); 3270 else 3271 v = &((*((struct yy_trans_info **) (transdmap->dm_arr)))[t32]); 3272 3273 if(M4_YY_TABLES_VERIFY ){ 3274 if( ((struct yy_trans_info **) p)[0] != v) 3275 YY_FATAL_ERROR( "tables verification failed at YYTD_PTRANS" ); 3276 }else 3277 ((struct yy_trans_info **) p)[0] = v; 3278 3279 /* increment p */ 3280 p = (struct yy_trans_info **) p + 1; 3281 } 3282 else { 3283 /* t32 is a plain int. copy data, then incrememnt p. */ 3284 switch (dmap->dm_sz) { 3285 case sizeof (flex_int32_t): 3286 if(M4_YY_TABLES_VERIFY ){ 3287 if( ((flex_int32_t *) p)[0] != (flex_int32_t) t32) 3288 YY_FATAL_ERROR( "tables verification failed at flex_int32_t" ); 3289 }else 3290 ((flex_int32_t *) p)[0] = (flex_int32_t) t32; 3291 p = ((flex_int32_t *) p) + 1; 3292 break; 3293 case sizeof (flex_int16_t): 3294 if(M4_YY_TABLES_VERIFY ){ 3295 if( ((flex_int16_t *) p)[0] != (flex_int16_t) t32) 3296 YY_FATAL_ERROR( "tables verification failed at flex_int16_t" ); 3297 }else 3298 ((flex_int16_t *) p)[0] = (flex_int16_t) t32; 3299 p = ((flex_int16_t *) p) + 1; 3300 break; 3301 case sizeof (flex_int8_t): 3302 if(M4_YY_TABLES_VERIFY ){ 3303 if( ((flex_int8_t *) p)[0] != (flex_int8_t) t32) 3304 YY_FATAL_ERROR( "tables verification failed at flex_int8_t" ); 3305 }else 3306 ((flex_int8_t *) p)[0] = (flex_int8_t) t32; 3307 p = ((flex_int8_t *) p) + 1; 3308 break; 3309 default: 3310 YY_FATAL_ERROR( "invalid dmap->dm_sz for plain int" ); /* TODO: not fatal. */ 3311 return -1; 3312 } 3313 } 3314 } 3315 3316 } 3317 3318 /* Now eat padding. */ 3319 { 3320 int pad; 3321 pad = yypad64(rd->bread); 3322 while(--pad >= 0){ 3323 flex_int8_t t8; 3324 if(yytbl_read8(&t8,rd) != 0) 3325 return -1; 3326 } 3327 } 3328 3329 return 0; 3330} 3331 3332%define-yytables The name for this specific scanner's tables. 3333 3334/* Find the key and load the DFA tables from the given stream. */ 3335static int yytbl_fload YYFARGS2(FILE *, fp, const char *, key) 3336{ 3337 int rv=0; 3338 struct yytbl_hdr th; 3339 struct yytbl_reader rd; 3340 3341 rd.fp = fp; 3342 th.th_version = NULL; 3343 3344 /* Keep trying until we find the right set of tables or end of file. */ 3345 while (!feof(rd.fp)) { 3346 rd.bread = 0; 3347 if (yytbl_hdr_read (&th, &rd M4_YY_CALL_LAST_ARG) != 0){ 3348 rv = -1; 3349 goto return_rv; 3350 } 3351 3352 /* A NULL key means choose the first set of tables. */ 3353 if (key == NULL) 3354 break; 3355 3356 if (strcmp(th.th_name,key) != 0){ 3357 /* Skip ahead to next set */ 3358 fseek(rd.fp, th.th_ssize - th.th_hsize, SEEK_CUR); 3359 yyfree(th.th_version M4_YY_CALL_LAST_ARG); 3360 th.th_version = NULL; 3361 } 3362 else 3363 break; 3364 } 3365 3366 while (rd.bread < th.th_ssize){ 3367 /* Load the data tables */ 3368 if(yytbl_data_load (yydmap,&rd M4_YY_CALL_LAST_ARG) != 0){ 3369 rv = -1; 3370 goto return_rv; 3371 } 3372 } 3373 3374return_rv: 3375 if(th.th_version){ 3376 yyfree(th.th_version M4_YY_CALL_LAST_ARG); 3377 th.th_version = NULL; 3378 } 3379 3380 return rv; 3381} 3382 3383/** Load the DFA tables for this scanner from the given stream. */ 3384int yytables_fload YYFARGS1(FILE *, fp) 3385{ 3386 3387 if( yytbl_fload(fp, YYTABLES_NAME M4_YY_CALL_LAST_ARG) != 0) 3388 return -1; 3389 return 0; 3390} 3391 3392/** Destroy the loaded tables, freeing memory, etc.. */ 3393int yytables_destroy YYFARGS0(void) 3394{ 3395 struct yytbl_dmap *dmap=0; 3396 3397 if(!M4_YY_TABLES_VERIFY){ 3398 /* Walk the dmap, freeing the pointers */ 3399 for(dmap=yydmap; dmap->dm_id; dmap++) { 3400 void * v; 3401 v = dmap->dm_arr; 3402 if(v && *(char**)v){ 3403 yyfree(*(char**)v M4_YY_CALL_LAST_ARG); 3404 *(char**)v = NULL; 3405 } 3406 } 3407 } 3408 3409 return 0; 3410} 3411 3412/* end table serialization code definitions */ 3413%endif 3414 3415 3416m4_ifdef([[M4_YY_MAIN]], [[ 3417int main M4_YY_PARAMS(void); 3418 3419int main () 3420{ 3421 3422%if-reentrant 3423 yyscan_t lexer; 3424 yylex_init(&lexer); 3425 yylex( lexer ); 3426 yylex_destroy( lexer); 3427 3428%endif 3429%if-not-reentrant 3430 yylex(); 3431%endif 3432 3433 return 0; 3434} 3435]]) 3436 3437%ok-for-header 3438m4_ifdef( [[M4_YY_IN_HEADER]], 3439[[ 3440#undef YY_NEW_FILE 3441#undef YY_FLUSH_BUFFER 3442#undef yy_set_bol 3443#undef yy_new_buffer 3444#undef yy_set_interactive 3445#undef YY_DO_BEFORE_ACTION 3446 3447#ifdef YY_DECL_IS_OURS 3448#undef YY_DECL_IS_OURS 3449#undef YY_DECL 3450#endif 3451]]) 3452