1 #line 2 "ktrfmt.yy.c" 2 3 #line 4 "ktrfmt.yy.c" 4 5 #define YY_INT_ALIGNED short int 6 7 /* A lexical scanner generated by flex */ 8 9 #define yy_create_buffer __ktrfmt_create_buffer 10 #define yy_delete_buffer __ktrfmt_delete_buffer 11 #define yy_flex_debug __ktrfmt_flex_debug 12 #define yy_init_buffer __ktrfmt_init_buffer 13 #define yy_flush_buffer __ktrfmt_flush_buffer 14 #define yy_load_buffer_state __ktrfmt_load_buffer_state 15 #define yy_switch_to_buffer __ktrfmt_switch_to_buffer 16 #define yyin __ktrfmtin 17 #define yyleng __ktrfmtleng 18 #define yylex __ktrfmtlex 19 #define yylineno __ktrfmtlineno 20 #define yyout __ktrfmtout 21 #define yyrestart __ktrfmtrestart 22 #define yytext __ktrfmttext 23 #define yywrap __ktrfmtwrap 24 #define yyalloc __ktrfmtalloc 25 #define yyrealloc __ktrfmtrealloc 26 #define yyfree __ktrfmtfree 27 28 #define FLEX_SCANNER 29 #define YY_FLEX_MAJOR_VERSION 2 30 #define YY_FLEX_MINOR_VERSION 5 31 #define YY_FLEX_SUBMINOR_VERSION 35 32 #if YY_FLEX_SUBMINOR_VERSION > 0 33 #define FLEX_BETA 34 #endif 35 36 /* First, we deal with platform-specific or compiler-specific issues. */ 37 38 /* begin standard C headers. */ 39 #include <stdio.h> 40 #include <string.h> 41 #include <errno.h> 42 #include <stdlib.h> 43 44 /* end standard C headers. */ 45 46 /* flex integer type definitions */ 47 48 #ifndef FLEXINT_H 49 #define FLEXINT_H 50 51 /* C99 systems have <inttypes.h>. Non-C99 systems may or may not. */ 52 53 #if defined (__STDC_VERSION__) && __STDC_VERSION__ >= 199901L 54 55 /* C99 says to define __STDC_LIMIT_MACROS before including stdint.h, 56 * if you want the limit (max/min) macros for int types. 57 */ 58 #ifndef __STDC_LIMIT_MACROS 59 #define __STDC_LIMIT_MACROS 1 60 #endif 61 62 #include <inttypes.h> 63 typedef int8_t flex_int8_t; 64 typedef uint8_t flex_uint8_t; 65 typedef int16_t flex_int16_t; 66 typedef uint16_t flex_uint16_t; 67 typedef int32_t flex_int32_t; 68 typedef uint32_t flex_uint32_t; 69 #else 70 typedef signed char flex_int8_t; 71 typedef short int flex_int16_t; 72 typedef int flex_int32_t; 73 typedef unsigned char flex_uint8_t; 74 typedef unsigned short int flex_uint16_t; 75 typedef unsigned int flex_uint32_t; 76 #endif /* ! C99 */ 77 78 /* Limits of integral types. */ 79 #ifndef INT8_MIN 80 #define INT8_MIN (-128) 81 #endif 82 #ifndef INT16_MIN 83 #define INT16_MIN (-32767-1) 84 #endif 85 #ifndef INT32_MIN 86 #define INT32_MIN (-2147483647-1) 87 #endif 88 #ifndef INT8_MAX 89 #define INT8_MAX (127) 90 #endif 91 #ifndef INT16_MAX 92 #define INT16_MAX (32767) 93 #endif 94 #ifndef INT32_MAX 95 #define INT32_MAX (2147483647) 96 #endif 97 #ifndef UINT8_MAX 98 #define UINT8_MAX (255U) 99 #endif 100 #ifndef UINT16_MAX 101 #define UINT16_MAX (65535U) 102 #endif 103 #ifndef UINT32_MAX 104 #define UINT32_MAX (4294967295U) 105 #endif 106 107 #endif /* ! FLEXINT_H */ 108 109 #ifdef __cplusplus 110 111 /* The "const" storage-class-modifier is valid. */ 112 #define YY_USE_CONST 113 114 #else /* ! __cplusplus */ 115 116 /* C99 requires __STDC__ to be defined as 1. */ 117 #if defined (__STDC__) 118 119 #define YY_USE_CONST 120 121 #endif /* defined (__STDC__) */ 122 #endif /* ! __cplusplus */ 123 124 #ifdef YY_USE_CONST 125 #define yyconst const 126 #else 127 #define yyconst 128 #endif 129 130 /* Returned upon end-of-file. */ 131 #define YY_NULL 0 132 133 /* Promotes a possibly negative, possibly signed char to an unsigned 134 * integer for use as an array index. If the signed char is negative, 135 * we want to instead treat it as an 8-bit unsigned char, hence the 136 * double cast. 137 */ 138 #define YY_SC_TO_UI(c) ((unsigned int) (unsigned char) c) 139 140 /* Enter a start condition. This macro really ought to take a parameter, 141 * but we do it the disgusting crufty way forced on us by the ()-less 142 * definition of BEGIN. 143 */ 144 #define BEGIN (yy_start) = 1 + 2 * 145 146 /* Translate the current start state into a value that can be later handed 147 * to BEGIN to return to the state. The YYSTATE alias is for lex 148 * compatibility. 149 */ 150 #define YY_START (((yy_start) - 1) / 2) 151 #define YYSTATE YY_START 152 153 /* Action number for EOF rule of a given start state. */ 154 #define YY_STATE_EOF(state) (YY_END_OF_BUFFER + state + 1) 155 156 /* Special action meaning "start processing a new file". */ 157 #define YY_NEW_FILE __ktrfmtrestart(__ktrfmtin ) 158 159 #define YY_END_OF_BUFFER_CHAR 0 160 161 /* Size of default input buffer. */ 162 #ifndef YY_BUF_SIZE 163 #define YY_BUF_SIZE 16384 164 #endif 165 166 /* The state buf must be large enough to hold one state per character in the main buffer. 167 */ 168 #define YY_STATE_BUF_SIZE ((YY_BUF_SIZE + 2) * sizeof(yy_state_type)) 169 170 #ifndef YY_TYPEDEF_YY_BUFFER_STATE 171 #define YY_TYPEDEF_YY_BUFFER_STATE 172 typedef struct yy_buffer_state *YY_BUFFER_STATE; 173 #endif 174 175 extern int __ktrfmtleng; 176 177 extern FILE *__ktrfmtin, *__ktrfmtout; 178 179 #define EOB_ACT_CONTINUE_SCAN 0 180 #define EOB_ACT_END_OF_FILE 1 181 #define EOB_ACT_LAST_MATCH 2 182 183 #define YY_LESS_LINENO(n) 184 185 /* Return all but the first "n" matched characters back to the input stream. */ 186 #define yyless(n) \ 187 do \ 188 { \ 189 /* Undo effects of setting up __ktrfmttext. */ \ 190 int yyless_macro_arg = (n); \ 191 YY_LESS_LINENO(yyless_macro_arg);\ 192 *yy_cp = (yy_hold_char); \ 193 YY_RESTORE_YY_MORE_OFFSET \ 194 (yy_c_buf_p) = yy_cp = yy_bp + yyless_macro_arg - YY_MORE_ADJ; \ 195 YY_DO_BEFORE_ACTION; /* set up __ktrfmttext again */ \ 196 } \ 197 while ( 0 ) 198 199 #define unput(c) yyunput( c, (yytext_ptr) ) 200 201 #ifndef YY_TYPEDEF_YY_SIZE_T 202 #define YY_TYPEDEF_YY_SIZE_T 203 typedef size_t yy_size_t; 204 #endif 205 206 #ifndef YY_STRUCT_YY_BUFFER_STATE 207 #define YY_STRUCT_YY_BUFFER_STATE 208 struct yy_buffer_state 209 { 210 FILE *yy_input_file; 211 212 char *yy_ch_buf; /* input buffer */ 213 char *yy_buf_pos; /* current position in input buffer */ 214 215 /* Size of input buffer in bytes, not including room for EOB 216 * characters. 217 */ 218 yy_size_t yy_buf_size; 219 220 /* Number of characters read into yy_ch_buf, not including EOB 221 * characters. 222 */ 223 int yy_n_chars; 224 225 /* Whether we "own" the buffer - i.e., we know we created it, 226 * and can realloc() it to grow it, and should free() it to 227 * delete it. 228 */ 229 int yy_is_our_buffer; 230 231 /* Whether this is an "interactive" input source; if so, and 232 * if we're using stdio for input, then we want to use getc() 233 * instead of fread(), to make sure we stop fetching input after 234 * each newline. 235 */ 236 int yy_is_interactive; 237 238 /* Whether we're considered to be at the beginning of a line. 239 * If so, '^' rules will be active on the next match, otherwise 240 * not. 241 */ 242 int yy_at_bol; 243 244 int yy_bs_lineno; /**< The line count. */ 245 int yy_bs_column; /**< The column count. */ 246 247 /* Whether to try to fill the input buffer when we reach the 248 * end of it. 249 */ 250 int yy_fill_buffer; 251 252 int yy_buffer_status; 253 254 #define YY_BUFFER_NEW 0 255 #define YY_BUFFER_NORMAL 1 256 /* When an EOF's been seen but there's still some text to process 257 * then we mark the buffer as YY_EOF_PENDING, to indicate that we 258 * shouldn't try reading from the input source any more. We might 259 * still have a bunch of tokens to match, though, because of 260 * possible backing-up. 261 * 262 * When we actually see the EOF, we change the status to "new" 263 * (via __ktrfmtrestart()), so that the user can continue scanning by 264 * just pointing __ktrfmtin at a new input file. 265 */ 266 #define YY_BUFFER_EOF_PENDING 2 267 268 }; 269 #endif /* !YY_STRUCT_YY_BUFFER_STATE */ 270 271 /* Stack of input buffers. */ 272 static size_t yy_buffer_stack_top = 0; /**< index of top of stack. */ 273 static size_t yy_buffer_stack_max = 0; /**< capacity of stack. */ 274 static YY_BUFFER_STATE * yy_buffer_stack = NULL; /**< Stack as an array. */ 275 276 /* We provide macros for accessing buffer states in case in the 277 * future we want to put the buffer states in a more general 278 * "scanner state". 279 * 280 * Returns the top of the stack, or NULL. 281 */ 282 #define YY_CURRENT_BUFFER ( (yy_buffer_stack) \ 283 ? (yy_buffer_stack)[(yy_buffer_stack_top)] \ 284 : NULL) 285 286 /* Same as previous macro, but useful when we know that the buffer stack is not 287 * NULL or when we need an lvalue. For internal use only. 288 */ 289 #define YY_CURRENT_BUFFER_LVALUE (yy_buffer_stack)[(yy_buffer_stack_top)] 290 291 /* yy_hold_char holds the character lost when __ktrfmttext is formed. */ 292 static char yy_hold_char; 293 static int yy_n_chars; /* number of characters read into yy_ch_buf */ 294 int __ktrfmtleng; 295 296 /* Points to current character in buffer. */ 297 static char *yy_c_buf_p = (char *) 0; 298 static int yy_init = 0; /* whether we need to initialize */ 299 static int yy_start = 0; /* start state number */ 300 301 /* Flag which is used to allow __ktrfmtwrap()'s to do buffer switches 302 * instead of setting up a fresh __ktrfmtin. A bit of a hack ... 303 */ 304 static int yy_did_buffer_switch_on_eof; 305 306 void __ktrfmtrestart (FILE *input_file ); 307 void __ktrfmt_switch_to_buffer (YY_BUFFER_STATE new_buffer ); 308 YY_BUFFER_STATE __ktrfmt_create_buffer (FILE *file,int size ); 309 void __ktrfmt_delete_buffer (YY_BUFFER_STATE b ); 310 void __ktrfmt_flush_buffer (YY_BUFFER_STATE b ); 311 void __ktrfmtpush_buffer_state (YY_BUFFER_STATE new_buffer ); 312 void __ktrfmtpop_buffer_state (void ); 313 314 static void __ktrfmtensure_buffer_stack (void ); 315 static void __ktrfmt_load_buffer_state (void ); 316 static void __ktrfmt_init_buffer (YY_BUFFER_STATE b,FILE *file ); 317 318 #define YY_FLUSH_BUFFER __ktrfmt_flush_buffer(YY_CURRENT_BUFFER ) 319 320 YY_BUFFER_STATE __ktrfmt_scan_buffer (char *base,yy_size_t size ); 321 YY_BUFFER_STATE __ktrfmt_scan_string (yyconst char *yy_str ); 322 YY_BUFFER_STATE __ktrfmt_scan_bytes (yyconst char *bytes,int len ); 323 324 void *__ktrfmtalloc (yy_size_t ); 325 void *__ktrfmtrealloc (void *,yy_size_t ); 326 void __ktrfmtfree (void * ); 327 328 #define yy_new_buffer __ktrfmt_create_buffer 329 330 #define yy_set_interactive(is_interactive) \ 331 { \ 332 if ( ! YY_CURRENT_BUFFER ){ \ 333 __ktrfmtensure_buffer_stack (); \ 334 YY_CURRENT_BUFFER_LVALUE = \ 335 __ktrfmt_create_buffer(__ktrfmtin,YY_BUF_SIZE ); \ 336 } \ 337 YY_CURRENT_BUFFER_LVALUE->yy_is_interactive = is_interactive; \ 338 } 339 340 #define yy_set_bol(at_bol) \ 341 { \ 342 if ( ! YY_CURRENT_BUFFER ){\ 343 __ktrfmtensure_buffer_stack (); \ 344 YY_CURRENT_BUFFER_LVALUE = \ 345 __ktrfmt_create_buffer(__ktrfmtin,YY_BUF_SIZE ); \ 346 } \ 347 YY_CURRENT_BUFFER_LVALUE->yy_at_bol = at_bol; \ 348 } 349 350 #define YY_AT_BOL() (YY_CURRENT_BUFFER_LVALUE->yy_at_bol) 351 352 /* Begin user sect3 */ 353 354 #define __ktrfmtwrap(n) 1 355 #define YY_SKIP_YYWRAP 356 357 typedef unsigned char YY_CHAR; 358 359 FILE *__ktrfmtin = (FILE *) 0, *__ktrfmtout = (FILE *) 0; 360 361 typedef int yy_state_type; 362 363 extern int __ktrfmtlineno; 364 365 int __ktrfmtlineno = 1; 366 367 extern char *__ktrfmttext; 368 #define yytext_ptr __ktrfmttext 369 370 static yy_state_type yy_get_previous_state (void ); 371 static yy_state_type yy_try_NUL_trans (yy_state_type current_state ); 372 static int yy_get_next_buffer (void ); 373 static void yy_fatal_error (yyconst char msg[] ); 374 375 /* Done after the current pattern has been matched and before the 376 * corresponding action - sets up __ktrfmttext. 377 */ 378 #define YY_DO_BEFORE_ACTION \ 379 (yytext_ptr) = yy_bp; \ 380 __ktrfmtleng = (size_t) (yy_cp - yy_bp); \ 381 (yy_hold_char) = *yy_cp; \ 382 *yy_cp = '\0'; \ 383 (yy_c_buf_p) = yy_cp; 384 385 #define YY_NUM_RULES 11 386 #define YY_END_OF_BUFFER 12 387 /* This struct is not used in this scanner, 388 but its presence is necessary. */ 389 struct yy_trans_info 390 { 391 flex_int32_t yy_verify; 392 flex_int32_t yy_nxt; 393 }; 394 static yyconst flex_int16_t yy_accept[26] = 395 { 0, 396 0, 0, 12, 11, 1, 11, 3, 8, 5, 5, 397 7, 4, 9, 10, 1, 0, 0, 3, 5, 0, 398 4, 2, 2, 6, 0 399 } ; 400 401 static yyconst flex_int32_t yy_ec[256] = 402 { 0, 403 1, 1, 1, 1, 1, 1, 1, 1, 2, 3, 404 1, 1, 2, 1, 1, 1, 1, 1, 1, 1, 405 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 406 1, 2, 1, 4, 1, 5, 1, 1, 1, 1, 407 1, 1, 1, 1, 1, 6, 1, 7, 8, 8, 408 8, 8, 8, 8, 8, 8, 8, 1, 1, 1, 409 9, 1, 1, 1, 10, 10, 10, 10, 10, 10, 410 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 411 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 412 12, 13, 14, 1, 15, 1, 16, 16, 16, 16, 413 414 16, 16, 15, 15, 15, 15, 15, 15, 15, 15, 415 15, 15, 15, 15, 15, 15, 15, 15, 15, 17, 416 15, 15, 1, 1, 1, 1, 1, 1, 1, 1, 417 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 418 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 419 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 420 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 421 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 422 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 423 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 424 425 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 426 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 427 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 428 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 429 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 430 1, 1, 1, 1, 1 431 } ; 432 433 static yyconst flex_int32_t yy_meta[18] = 434 { 0, 435 1, 1, 2, 2, 1, 1, 3, 3, 1, 4, 436 5, 1, 1, 1, 5, 4, 6 437 } ; 438 439 static yyconst flex_int16_t yy_base[31] = 440 { 0, 441 0, 0, 31, 54, 26, 14, 0, 54, 9, 11, 442 54, 0, 54, 54, 23, 16, 17, 0, 15, 0, 443 0, 54, 20, 0, 54, 33, 37, 41, 45, 49 444 } ; 445 446 static yyconst flex_int16_t yy_def[31] = 447 { 0, 448 25, 1, 25, 25, 25, 26, 27, 25, 28, 25, 449 25, 29, 25, 25, 25, 26, 26, 27, 25, 30, 450 29, 25, 26, 30, 0, 25, 25, 25, 25, 25 451 } ; 452 453 static yyconst flex_int16_t yy_nxt[72] = 454 { 0, 455 4, 5, 4, 6, 7, 8, 9, 10, 11, 12, 456 12, 13, 4, 14, 7, 7, 7, 19, 19, 22, 457 23, 19, 19, 22, 15, 20, 17, 15, 17, 17, 458 25, 25, 17, 16, 25, 16, 16, 16, 16, 18, 459 18, 18, 18, 19, 25, 25, 19, 21, 21, 21, 460 21, 24, 24, 3, 25, 25, 25, 25, 25, 25, 461 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 462 25 463 } ; 464 465 static yyconst flex_int16_t yy_chk[72] = 466 { 0, 467 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 468 1, 1, 1, 1, 1, 1, 1, 10, 10, 16, 469 17, 19, 19, 23, 15, 9, 6, 5, 16, 17, 470 3, 0, 23, 26, 0, 26, 26, 26, 26, 27, 471 27, 27, 27, 28, 0, 0, 28, 29, 29, 29, 472 29, 30, 30, 25, 25, 25, 25, 25, 25, 25, 473 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 474 25 475 } ; 476 477 static yy_state_type yy_last_accepting_state; 478 static char *yy_last_accepting_cpos; 479 480 extern int __ktrfmt_flex_debug; 481 int __ktrfmt_flex_debug = 0; 482 483 /* The intent behind this definition is that it'll catch 484 * any uses of REJECT which flex missed. 485 */ 486 #define REJECT reject_used_but_not_detected 487 #define yymore() yymore_used_but_not_detected 488 #define YY_MORE_ADJ 0 489 #define YY_RESTORE_YY_MORE_OFFSET 490 char *__ktrfmttext; 491 #line 1 "ktrfmt.l" 492 #line 2 "ktrfmt.l" 493 494 #include <assert.h> 495 //#define YYSTYPE struct token 496 #define YY_NO_INPUT 497 #include <stdlib.h> 498 #include "ktrfmt.tab.h" 499 #include "tok.h" 500 #include "internal.h" 501 502 enum { 503 NR_TOKENS = 18, 504 }; 505 506 /* XXX: need to switch to reentrant lexer */ 507 static struct token tokens[NR_TOKENS]; 508 static int curr_tok; 509 static struct symtab *strtab; 510 511 static 512 struct token * 513 tok_new(void) 514 { 515 ++curr_tok; 516 if (curr_tok == NR_TOKENS) { 517 /* can't happen */ 518 fprintf(stderr, "Reached max number of tokens\n"); 519 abort(); 520 } 521 return &tokens[curr_tok]; 522 } 523 524 void 525 tok_free(struct token *tok) 526 { 527 assert(&tokens[curr_tok] == tok); 528 --curr_tok; 529 } 530 531 /* 532 * We keep track of strings we've seen before so string comparison 533 * can be done w/ a simple pointer comparison 534 */ 535 static 536 char * 537 newstr(const char *s) 538 { 539 void *r; 540 if (!strtab) 541 strtab = symtab_new(); 542 if ((r = symtab_find(strtab, s))) 543 return r; 544 if (!(r = strdup(s))) 545 return r; 546 symtab_insert(strtab, r, r); 547 return r; 548 } 549 550 #line 551 "ktrfmt.yy.c" 551 552 #define INITIAL 0 553 554 #ifndef YY_NO_UNISTD_H 555 /* Special case for "unistd.h", since it is non-ANSI. We include it way 556 * down here because we want the user's section 1 to have been scanned first. 557 * The user has a chance to override it with an option. 558 */ 559 #include <unistd.h> 560 #endif 561 562 #ifndef YY_EXTRA_TYPE 563 #define YY_EXTRA_TYPE void * 564 #endif 565 566 static int yy_init_globals (void ); 567 568 /* Accessor methods to globals. 569 These are made visible to non-reentrant scanners for convenience. */ 570 571 int __ktrfmtlex_destroy (void ); 572 573 int __ktrfmtget_debug (void ); 574 575 void __ktrfmtset_debug (int debug_flag ); 576 577 YY_EXTRA_TYPE __ktrfmtget_extra (void ); 578 579 void __ktrfmtset_extra (YY_EXTRA_TYPE user_defined ); 580 581 FILE *__ktrfmtget_in (void ); 582 583 void __ktrfmtset_in (FILE * in_str ); 584 585 FILE *__ktrfmtget_out (void ); 586 587 void __ktrfmtset_out (FILE * out_str ); 588 589 int __ktrfmtget_leng (void ); 590 591 char *__ktrfmtget_text (void ); 592 593 int __ktrfmtget_lineno (void ); 594 595 void __ktrfmtset_lineno (int line_number ); 596 597 YYSTYPE * __ktrfmtget_lval (void ); 598 599 void __ktrfmtset_lval (YYSTYPE * yylval_param ); 600 601 /* Macros after this point can all be overridden by user definitions in 602 * section 1. 603 */ 604 605 #ifndef YY_SKIP_YYWRAP 606 #ifdef __cplusplus 607 extern "C" int __ktrfmtwrap (void ); 608 #else 609 extern int __ktrfmtwrap (void ); 610 #endif 611 #endif 612 613 #ifndef yytext_ptr 614 static void yy_flex_strncpy (char *,yyconst char *,int ); 615 #endif 616 617 #ifdef YY_NEED_STRLEN 618 static int yy_flex_strlen (yyconst char * ); 619 #endif 620 621 #ifndef YY_NO_INPUT 622 623 #ifdef __cplusplus 624 static int yyinput (void ); 625 #else 626 static int input (void ); 627 #endif 628 629 #endif 630 631 /* Amount of stuff to slurp up with each read. */ 632 #ifndef YY_READ_BUF_SIZE 633 #define YY_READ_BUF_SIZE 8192 634 #endif 635 636 /* Copy whatever the last rule matched to the standard output. */ 637 #ifndef ECHO 638 /* This used to be an fputs(), but since the string might contain NUL's, 639 * we now use fwrite(). 640 */ 641 #define ECHO fwrite( __ktrfmttext, __ktrfmtleng, 1, __ktrfmtout ) 642 #endif 643 644 /* Gets input and stuffs it into "buf". number of characters read, or YY_NULL, 645 * is returned in "result". 646 */ 647 #ifndef YY_INPUT 648 #define YY_INPUT(buf,result,max_size) \ 649 if ( YY_CURRENT_BUFFER_LVALUE->yy_is_interactive ) \ 650 { \ 651 int c = '*'; \ 652 int n; \ 653 for ( n = 0; n < max_size && \ 654 (c = getc( __ktrfmtin )) != EOF && c != '\n'; ++n ) \ 655 buf[n] = (char) c; \ 656 if ( c == '\n' ) \ 657 buf[n++] = (char) c; \ 658 if ( c == EOF && ferror( __ktrfmtin ) ) \ 659 YY_FATAL_ERROR( "input in flex scanner failed" ); \ 660 result = n; \ 661 } \ 662 else \ 663 { \ 664 errno=0; \ 665 while ( (result = fread(buf, 1, max_size, __ktrfmtin))==0 && ferror(__ktrfmtin)) \ 666 { \ 667 if( errno != EINTR) \ 668 { \ 669 YY_FATAL_ERROR( "input in flex scanner failed" ); \ 670 break; \ 671 } \ 672 errno=0; \ 673 clearerr(__ktrfmtin); \ 674 } \ 675 }\ 676 \ 677 678 #endif 679 680 /* No semi-colon after return; correct usage is to write "yyterminate();" - 681 * we don't want an extra ';' after the "return" because that will cause 682 * some compilers to complain about unreachable statements. 683 */ 684 #ifndef yyterminate 685 #define yyterminate() return YY_NULL 686 #endif 687 688 /* Number of entries by which start-condition stack grows. */ 689 #ifndef YY_START_STACK_INCR 690 #define YY_START_STACK_INCR 25 691 #endif 692 693 /* Report a fatal error. */ 694 #ifndef YY_FATAL_ERROR 695 #define YY_FATAL_ERROR(msg) yy_fatal_error( msg ) 696 #endif 697 698 /* end tables serialization structures and prototypes */ 699 700 /* Default declaration of generated scanner - a define so the user can 701 * easily add parameters. 702 */ 703 #ifndef YY_DECL 704 #define YY_DECL_IS_OURS 1 705 706 extern int __ktrfmtlex \ 707 (YYSTYPE * yylval_param ); 708 709 #define YY_DECL int __ktrfmtlex \ 710 (YYSTYPE * yylval_param ) 711 #endif /* !YY_DECL */ 712 713 /* Code executed at the beginning of each rule, after __ktrfmttext and __ktrfmtleng 714 * have been set up. 715 */ 716 #ifndef YY_USER_ACTION 717 #define YY_USER_ACTION 718 #endif 719 720 /* Code executed at the end of each rule. */ 721 #ifndef YY_BREAK 722 #define YY_BREAK break; 723 #endif 724 725 #define YY_RULE_SETUP \ 726 YY_USER_ACTION 727 728 /** The main scanner function which does all the work. 729 */ 730 YY_DECL 731 { 732 register yy_state_type yy_current_state; 733 register char *yy_cp, *yy_bp; 734 register int yy_act; 735 736 YYSTYPE * yylval; 737 738 #line 73 "ktrfmt.l" 739 740 #line 741 "ktrfmt.yy.c" 741 742 yylval = yylval_param; 743 744 if ( !(yy_init) ) 745 { 746 (yy_init) = 1; 747 748 #ifdef YY_USER_INIT 749 YY_USER_INIT; 750 #endif 751 752 if ( ! (yy_start) ) 753 (yy_start) = 1; /* first start state */ 754 755 if ( ! __ktrfmtin ) 756 __ktrfmtin = stdin; 757 758 if ( ! __ktrfmtout ) 759 __ktrfmtout = stdout; 760 761 if ( ! YY_CURRENT_BUFFER ) { 762 __ktrfmtensure_buffer_stack (); 763 YY_CURRENT_BUFFER_LVALUE = 764 __ktrfmt_create_buffer(__ktrfmtin,YY_BUF_SIZE ); 765 } 766 767 __ktrfmt_load_buffer_state( ); 768 } 769 770 while ( 1 ) /* loops until end-of-file is reached */ 771 { 772 yy_cp = (yy_c_buf_p); 773 774 /* Support of __ktrfmttext. */ 775 *yy_cp = (yy_hold_char); 776 777 /* yy_bp points to the position in yy_ch_buf of the start of 778 * the current run. 779 */ 780 yy_bp = yy_cp; 781 782 yy_current_state = (yy_start); 783 yy_match: 784 do 785 { 786 register YY_CHAR yy_c = yy_ec[YY_SC_TO_UI(*yy_cp)]; 787 if ( yy_accept[yy_current_state] ) 788 { 789 (yy_last_accepting_state) = yy_current_state; 790 (yy_last_accepting_cpos) = yy_cp; 791 } 792 while ( yy_chk[yy_base[yy_current_state] + yy_c] != yy_current_state ) 793 { 794 yy_current_state = (int) yy_def[yy_current_state]; 795 if ( yy_current_state >= 26 ) 796 yy_c = yy_meta[(unsigned int) yy_c]; 797 } 798 yy_current_state = yy_nxt[yy_base[yy_current_state] + (unsigned int) yy_c]; 799 ++yy_cp; 800 } 801 while ( yy_base[yy_current_state] != 54 ); 802 803 yy_find_action: 804 yy_act = yy_accept[yy_current_state]; 805 if ( yy_act == 0 ) 806 { /* have to back up */ 807 yy_cp = (yy_last_accepting_cpos); 808 yy_current_state = (yy_last_accepting_state); 809 yy_act = yy_accept[yy_current_state]; 810 } 811 812 YY_DO_BEFORE_ACTION; 813 814 do_action: /* This label is used only to access EOF actions. */ 815 816 switch ( yy_act ) 817 { /* beginning of action switch */ 818 case 0: /* must back up */ 819 /* undo the effects of YY_DO_BEFORE_ACTION */ 820 *yy_cp = (yy_hold_char); 821 yy_cp = (yy_last_accepting_cpos); 822 yy_current_state = (yy_last_accepting_state); 823 goto yy_find_action; 824 825 case 1: 826 YY_RULE_SETUP 827 #line 74 "ktrfmt.l" 828 { /* ignore */ } 829 YY_BREAK 830 case 2: 831 YY_RULE_SETUP 832 #line 75 "ktrfmt.l" 833 { 834 size_t len; 835 yylval->tok = tok_new(); 836 yylval->tok->type = TOK_STR; 837 len = strlen(__ktrfmttext); 838 assert(__ktrfmttext[len - 1] == '"'); 839 __ktrfmttext[len - 1] = '\0'; /* kill trailing quote */ 840 printd(LEX, "newstr(\"%s\")\n", __ktrfmttext + 1); 841 yylval->tok->str = newstr(__ktrfmttext + 1); /* parser detects oom */ 842 __ktrfmttext[len - 1] = '"'; /* restore quote */ 843 printd(LEX, "TOK_STR: \"%s\"\n", yylval->tok->str); 844 return TOK_STR; 845 } 846 YY_BREAK 847 case 3: 848 YY_RULE_SETUP 849 #line 88 "ktrfmt.l" 850 { 851 yylval->tok = tok_new(); 852 yylval->tok->type = TOK_ID; 853 printd(LEX, "tok %p TOK_ID %p:%s\n", yylval->tok, __ktrfmttext, __ktrfmttext); 854 yylval->tok->str = newstr(__ktrfmttext); /* parser detects oom */ 855 return TOK_ID; 856 } 857 YY_BREAK 858 case 4: 859 YY_RULE_SETUP 860 #line 95 "ktrfmt.l" 861 { 862 yylval->tok = tok_new(); 863 yylval->tok->type = TOK_CTOR; 864 printd(LEX, "tok %p TOK_CTOR %p:%s\n", yylval->tok, __ktrfmttext, __ktrfmttext); 865 yylval->tok->str = newstr(__ktrfmttext); /* parser detects oom */ 866 return TOK_CTOR; 867 } 868 YY_BREAK 869 case 5: 870 YY_RULE_SETUP 871 #line 102 "ktrfmt.l" 872 { 873 yylval->tok = tok_new(); 874 yylval->tok->type = TOK_INT; 875 yylval->tok->str = strdup(__ktrfmttext); /* parser detects oom */ 876 printd(LEX, "TOK_INT\n"); 877 return TOK_INT; 878 } 879 YY_BREAK 880 case 6: 881 YY_RULE_SETUP 882 #line 109 "ktrfmt.l" 883 { 884 yylval->tok = tok_new(); 885 yylval->tok->type = TOK_INT; 886 yylval->tok->str = strdup(__ktrfmttext); /* parser detects oom */ 887 printd(LEX, "TOK_INT\n"); 888 return TOK_INT; 889 } 890 YY_BREAK 891 case 7: 892 YY_RULE_SETUP 893 #line 116 "ktrfmt.l" 894 { 895 yylval = NULL; 896 printd(LEX, "TOK_EQ\n"); 897 return TOK_EQ; 898 } 899 YY_BREAK 900 case 8: 901 YY_RULE_SETUP 902 #line 121 "ktrfmt.l" 903 { 904 yylval = NULL; 905 printd(LEX, "TOK_DOT\n"); 906 return TOK_DOT; 907 } 908 YY_BREAK 909 case 9: 910 YY_RULE_SETUP 911 #line 126 "ktrfmt.l" 912 { 913 yylval = NULL; 914 printd(LEX, "TOK_LEFT_BRACK\n"); 915 return TOK_LEFT_BRACK; 916 } 917 YY_BREAK 918 case 10: 919 YY_RULE_SETUP 920 #line 131 "ktrfmt.l" 921 { 922 yylval = NULL; 923 printd(LEX, "TOK_RIGHT_BRACK\n"); 924 return TOK_RIGHT_BRACK; 925 } 926 YY_BREAK 927 case 11: 928 YY_RULE_SETUP 929 #line 137 "ktrfmt.l" 930 ECHO; 931 YY_BREAK 932 #line 933 "ktrfmt.yy.c" 933 case YY_STATE_EOF(INITIAL): 934 yyterminate(); 935 936 case YY_END_OF_BUFFER: 937 { 938 /* Amount of text matched not including the EOB char. */ 939 int yy_amount_of_matched_text = (int) (yy_cp - (yytext_ptr)) - 1; 940 941 /* Undo the effects of YY_DO_BEFORE_ACTION. */ 942 *yy_cp = (yy_hold_char); 943 YY_RESTORE_YY_MORE_OFFSET 944 945 if ( YY_CURRENT_BUFFER_LVALUE->yy_buffer_status == YY_BUFFER_NEW ) 946 { 947 /* We're scanning a new file or input source. It's 948 * possible that this happened because the user 949 * just pointed __ktrfmtin at a new source and called 950 * __ktrfmtlex(). If so, then we have to assure 951 * consistency between YY_CURRENT_BUFFER and our 952 * globals. Here is the right place to do so, because 953 * this is the first action (other than possibly a 954 * back-up) that will match for the new input source. 955 */ 956 (yy_n_chars) = YY_CURRENT_BUFFER_LVALUE->yy_n_chars; 957 YY_CURRENT_BUFFER_LVALUE->yy_input_file = __ktrfmtin; 958 YY_CURRENT_BUFFER_LVALUE->yy_buffer_status = YY_BUFFER_NORMAL; 959 } 960 961 /* Note that here we test for yy_c_buf_p "<=" to the position 962 * of the first EOB in the buffer, since yy_c_buf_p will 963 * already have been incremented past the NUL character 964 * (since all states make transitions on EOB to the 965 * end-of-buffer state). Contrast this with the test 966 * in input(). 967 */ 968 if ( (yy_c_buf_p) <= &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[(yy_n_chars)] ) 969 { /* This was really a NUL. */ 970 yy_state_type yy_next_state; 971 972 (yy_c_buf_p) = (yytext_ptr) + yy_amount_of_matched_text; 973 974 yy_current_state = yy_get_previous_state( ); 975 976 /* Okay, we're now positioned to make the NUL 977 * transition. We couldn't have 978 * yy_get_previous_state() go ahead and do it 979 * for us because it doesn't know how to deal 980 * with the possibility of jamming (and we don't 981 * want to build jamming into it because then it 982 * will run more slowly). 983 */ 984 985 yy_next_state = yy_try_NUL_trans( yy_current_state ); 986 987 yy_bp = (yytext_ptr) + YY_MORE_ADJ; 988 989 if ( yy_next_state ) 990 { 991 /* Consume the NUL. */ 992 yy_cp = ++(yy_c_buf_p); 993 yy_current_state = yy_next_state; 994 goto yy_match; 995 } 996 997 else 998 { 999 yy_cp = (yy_c_buf_p); 1000 goto yy_find_action; 1001 } 1002 } 1003 1004 else switch ( yy_get_next_buffer( ) ) 1005 { 1006 case EOB_ACT_END_OF_FILE: 1007 { 1008 (yy_did_buffer_switch_on_eof) = 0; 1009 1010 if ( __ktrfmtwrap( ) ) 1011 { 1012 /* Note: because we've taken care in 1013 * yy_get_next_buffer() to have set up 1014 * __ktrfmttext, we can now set up 1015 * yy_c_buf_p so that if some total 1016 * hoser (like flex itself) wants to 1017 * call the scanner after we return the 1018 * YY_NULL, it'll still work - another 1019 * YY_NULL will get returned. 1020 */ 1021 (yy_c_buf_p) = (yytext_ptr) + YY_MORE_ADJ; 1022 1023 yy_act = YY_STATE_EOF(YY_START); 1024 goto do_action; 1025 } 1026 1027 else 1028 { 1029 if ( ! (yy_did_buffer_switch_on_eof) ) 1030 YY_NEW_FILE; 1031 } 1032 break; 1033 } 1034 1035 case EOB_ACT_CONTINUE_SCAN: 1036 (yy_c_buf_p) = 1037 (yytext_ptr) + yy_amount_of_matched_text; 1038 1039 yy_current_state = yy_get_previous_state( ); 1040 1041 yy_cp = (yy_c_buf_p); 1042 yy_bp = (yytext_ptr) + YY_MORE_ADJ; 1043 goto yy_match; 1044 1045 case EOB_ACT_LAST_MATCH: 1046 (yy_c_buf_p) = 1047 &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[(yy_n_chars)]; 1048 1049 yy_current_state = yy_get_previous_state( ); 1050 1051 yy_cp = (yy_c_buf_p); 1052 yy_bp = (yytext_ptr) + YY_MORE_ADJ; 1053 goto yy_find_action; 1054 } 1055 break; 1056 } 1057 1058 default: 1059 YY_FATAL_ERROR( 1060 "fatal flex scanner internal error--no action found" ); 1061 } /* end of action switch */ 1062 } /* end of scanning one token */ 1063 } /* end of __ktrfmtlex */ 1064 1065 /* yy_get_next_buffer - try to read in a new buffer 1066 * 1067 * Returns a code representing an action: 1068 * EOB_ACT_LAST_MATCH - 1069 * EOB_ACT_CONTINUE_SCAN - continue scanning from current position 1070 * EOB_ACT_END_OF_FILE - end of file 1071 */ 1072 static int yy_get_next_buffer (void) 1073 { 1074 register char *dest = YY_CURRENT_BUFFER_LVALUE->yy_ch_buf; 1075 register char *source = (yytext_ptr); 1076 register int number_to_move, i; 1077 int ret_val; 1078 1079 if ( (yy_c_buf_p) > &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[(yy_n_chars) + 1] ) 1080 YY_FATAL_ERROR( 1081 "fatal flex scanner internal error--end of buffer missed" ); 1082 1083 if ( YY_CURRENT_BUFFER_LVALUE->yy_fill_buffer == 0 ) 1084 { /* Don't try to fill the buffer, so this is an EOF. */ 1085 if ( (yy_c_buf_p) - (yytext_ptr) - YY_MORE_ADJ == 1 ) 1086 { 1087 /* We matched a single character, the EOB, so 1088 * treat this as a final EOF. 1089 */ 1090 return EOB_ACT_END_OF_FILE; 1091 } 1092 1093 else 1094 { 1095 /* We matched some text prior to the EOB, first 1096 * process it. 1097 */ 1098 return EOB_ACT_LAST_MATCH; 1099 } 1100 } 1101 1102 /* Try to read more data. */ 1103 1104 /* First move last chars to start of buffer. */ 1105 number_to_move = (int) ((yy_c_buf_p) - (yytext_ptr)) - 1; 1106 1107 for ( i = 0; i < number_to_move; ++i ) 1108 *(dest++) = *(source++); 1109 1110 if ( YY_CURRENT_BUFFER_LVALUE->yy_buffer_status == YY_BUFFER_EOF_PENDING ) 1111 /* don't do the read, it's not guaranteed to return an EOF, 1112 * just force an EOF 1113 */ 1114 YY_CURRENT_BUFFER_LVALUE->yy_n_chars = (yy_n_chars) = 0; 1115 1116 else 1117 { 1118 int num_to_read = 1119 YY_CURRENT_BUFFER_LVALUE->yy_buf_size - number_to_move - 1; 1120 1121 while ( num_to_read <= 0 ) 1122 { /* Not enough room in the buffer - grow it. */ 1123 1124 /* just a shorter name for the current buffer */ 1125 YY_BUFFER_STATE b = YY_CURRENT_BUFFER; 1126 1127 int yy_c_buf_p_offset = 1128 (int) ((yy_c_buf_p) - b->yy_ch_buf); 1129 1130 if ( b->yy_is_our_buffer ) 1131 { 1132 int new_size = b->yy_buf_size * 2; 1133 1134 if ( new_size <= 0 ) 1135 b->yy_buf_size += b->yy_buf_size / 8; 1136 else 1137 b->yy_buf_size *= 2; 1138 1139 b->yy_ch_buf = (char *) 1140 /* Include room in for 2 EOB chars. */ 1141 __ktrfmtrealloc((void *) b->yy_ch_buf,b->yy_buf_size + 2 ); 1142 } 1143 else 1144 /* Can't grow it, we don't own it. */ 1145 b->yy_ch_buf = NULL; 1146 1147 if ( ! b->yy_ch_buf ) 1148 YY_FATAL_ERROR( 1149 "fatal error - scanner input buffer overflow" ); 1150 1151 (yy_c_buf_p) = &b->yy_ch_buf[yy_c_buf_p_offset]; 1152 1153 num_to_read = YY_CURRENT_BUFFER_LVALUE->yy_buf_size - 1154 number_to_move - 1; 1155 1156 } 1157 1158 if ( num_to_read > YY_READ_BUF_SIZE ) 1159 num_to_read = YY_READ_BUF_SIZE; 1160 1161 /* Read in more data. */ 1162 YY_INPUT( (&YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[number_to_move]), 1163 (yy_n_chars), (size_t) num_to_read ); 1164 1165 YY_CURRENT_BUFFER_LVALUE->yy_n_chars = (yy_n_chars); 1166 } 1167 1168 if ( (yy_n_chars) == 0 ) 1169 { 1170 if ( number_to_move == YY_MORE_ADJ ) 1171 { 1172 ret_val = EOB_ACT_END_OF_FILE; 1173 __ktrfmtrestart(__ktrfmtin ); 1174 } 1175 1176 else 1177 { 1178 ret_val = EOB_ACT_LAST_MATCH; 1179 YY_CURRENT_BUFFER_LVALUE->yy_buffer_status = 1180 YY_BUFFER_EOF_PENDING; 1181 } 1182 } 1183 1184 else 1185 ret_val = EOB_ACT_CONTINUE_SCAN; 1186 1187 if ((yy_size_t) ((yy_n_chars) + number_to_move) > YY_CURRENT_BUFFER_LVALUE->yy_buf_size) { 1188 /* Extend the array by 50%, plus the number we really need. */ 1189 yy_size_t new_size = (yy_n_chars) + number_to_move + ((yy_n_chars) >> 1); 1190 YY_CURRENT_BUFFER_LVALUE->yy_ch_buf = (char *) __ktrfmtrealloc((void *) YY_CURRENT_BUFFER_LVALUE->yy_ch_buf,new_size ); 1191 if ( ! YY_CURRENT_BUFFER_LVALUE->yy_ch_buf ) 1192 YY_FATAL_ERROR( "out of dynamic memory in yy_get_next_buffer()" ); 1193 } 1194 1195 (yy_n_chars) += number_to_move; 1196 YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[(yy_n_chars)] = YY_END_OF_BUFFER_CHAR; 1197 YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[(yy_n_chars) + 1] = YY_END_OF_BUFFER_CHAR; 1198 1199 (yytext_ptr) = &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[0]; 1200 1201 return ret_val; 1202 } 1203 1204 /* yy_get_previous_state - get the state just before the EOB char was reached */ 1205 1206 static yy_state_type yy_get_previous_state (void) 1207 { 1208 register yy_state_type yy_current_state; 1209 register char *yy_cp; 1210 1211 yy_current_state = (yy_start); 1212 1213 for ( yy_cp = (yytext_ptr) + YY_MORE_ADJ; yy_cp < (yy_c_buf_p); ++yy_cp ) 1214 { 1215 register YY_CHAR yy_c = (*yy_cp ? yy_ec[YY_SC_TO_UI(*yy_cp)] : 1); 1216 if ( yy_accept[yy_current_state] ) 1217 { 1218 (yy_last_accepting_state) = yy_current_state; 1219 (yy_last_accepting_cpos) = yy_cp; 1220 } 1221 while ( yy_chk[yy_base[yy_current_state] + yy_c] != yy_current_state ) 1222 { 1223 yy_current_state = (int) yy_def[yy_current_state]; 1224 if ( yy_current_state >= 26 ) 1225 yy_c = yy_meta[(unsigned int) yy_c]; 1226 } 1227 yy_current_state = yy_nxt[yy_base[yy_current_state] + (unsigned int) yy_c]; 1228 } 1229 1230 return yy_current_state; 1231 } 1232 1233 /* yy_try_NUL_trans - try to make a transition on the NUL character 1234 * 1235 * synopsis 1236 * next_state = yy_try_NUL_trans( current_state ); 1237 */ 1238 static yy_state_type yy_try_NUL_trans (yy_state_type yy_current_state ) 1239 { 1240 register int yy_is_jam; 1241 register char *yy_cp = (yy_c_buf_p); 1242 1243 register YY_CHAR yy_c = 1; 1244 if ( yy_accept[yy_current_state] ) 1245 { 1246 (yy_last_accepting_state) = yy_current_state; 1247 (yy_last_accepting_cpos) = yy_cp; 1248 } 1249 while ( yy_chk[yy_base[yy_current_state] + yy_c] != yy_current_state ) 1250 { 1251 yy_current_state = (int) yy_def[yy_current_state]; 1252 if ( yy_current_state >= 26 ) 1253 yy_c = yy_meta[(unsigned int) yy_c]; 1254 } 1255 yy_current_state = yy_nxt[yy_base[yy_current_state] + (unsigned int) yy_c]; 1256 yy_is_jam = (yy_current_state == 25); 1257 1258 return yy_is_jam ? 0 : yy_current_state; 1259 } 1260 1261 #ifndef YY_NO_INPUT 1262 #ifdef __cplusplus 1263 static int yyinput (void) 1264 #else 1265 static int input (void) 1266 #endif 1267 1268 { 1269 int c; 1270 1271 *(yy_c_buf_p) = (yy_hold_char); 1272 1273 if ( *(yy_c_buf_p) == YY_END_OF_BUFFER_CHAR ) 1274 { 1275 /* yy_c_buf_p now points to the character we want to return. 1276 * If this occurs *before* the EOB characters, then it's a 1277 * valid NUL; if not, then we've hit the end of the buffer. 1278 */ 1279 if ( (yy_c_buf_p) < &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[(yy_n_chars)] ) 1280 /* This was really a NUL. */ 1281 *(yy_c_buf_p) = '\0'; 1282 1283 else 1284 { /* need more input */ 1285 int offset = (yy_c_buf_p) - (yytext_ptr); 1286 ++(yy_c_buf_p); 1287 1288 switch ( yy_get_next_buffer( ) ) 1289 { 1290 case EOB_ACT_LAST_MATCH: 1291 /* This happens because yy_g_n_b() 1292 * sees that we've accumulated a 1293 * token and flags that we need to 1294 * try matching the token before 1295 * proceeding. But for input(), 1296 * there's no matching to consider. 1297 * So convert the EOB_ACT_LAST_MATCH 1298 * to EOB_ACT_END_OF_FILE. 1299 */ 1300 1301 /* Reset buffer status. */ 1302 __ktrfmtrestart(__ktrfmtin ); 1303 1304 /*FALLTHROUGH*/ 1305 1306 case EOB_ACT_END_OF_FILE: 1307 { 1308 if ( __ktrfmtwrap( ) ) 1309 return EOF; 1310 1311 if ( ! (yy_did_buffer_switch_on_eof) ) 1312 YY_NEW_FILE; 1313 #ifdef __cplusplus 1314 return yyinput(); 1315 #else 1316 return input(); 1317 #endif 1318 } 1319 1320 case EOB_ACT_CONTINUE_SCAN: 1321 (yy_c_buf_p) = (yytext_ptr) + offset; 1322 break; 1323 } 1324 } 1325 } 1326 1327 c = *(unsigned char *) (yy_c_buf_p); /* cast for 8-bit char's */ 1328 *(yy_c_buf_p) = '\0'; /* preserve __ktrfmttext */ 1329 (yy_hold_char) = *++(yy_c_buf_p); 1330 1331 return c; 1332 } 1333 #endif /* ifndef YY_NO_INPUT */ 1334 1335 /** Immediately switch to a different input stream. 1336 * @param input_file A readable stream. 1337 * 1338 * @note This function does not reset the start condition to @c INITIAL . 1339 */ 1340 void __ktrfmtrestart (FILE * input_file ) 1341 { 1342 1343 if ( ! YY_CURRENT_BUFFER ){ 1344 __ktrfmtensure_buffer_stack (); 1345 YY_CURRENT_BUFFER_LVALUE = 1346 __ktrfmt_create_buffer(__ktrfmtin,YY_BUF_SIZE ); 1347 } 1348 1349 __ktrfmt_init_buffer(YY_CURRENT_BUFFER,input_file ); 1350 __ktrfmt_load_buffer_state( ); 1351 } 1352 1353 /** Switch to a different input buffer. 1354 * @param new_buffer The new input buffer. 1355 * 1356 */ 1357 void __ktrfmt_switch_to_buffer (YY_BUFFER_STATE new_buffer ) 1358 { 1359 1360 /* TODO. We should be able to replace this entire function body 1361 * with 1362 * __ktrfmtpop_buffer_state(); 1363 * __ktrfmtpush_buffer_state(new_buffer); 1364 */ 1365 __ktrfmtensure_buffer_stack (); 1366 if ( YY_CURRENT_BUFFER == new_buffer ) 1367 return; 1368 1369 if ( YY_CURRENT_BUFFER ) 1370 { 1371 /* Flush out information for old buffer. */ 1372 *(yy_c_buf_p) = (yy_hold_char); 1373 YY_CURRENT_BUFFER_LVALUE->yy_buf_pos = (yy_c_buf_p); 1374 YY_CURRENT_BUFFER_LVALUE->yy_n_chars = (yy_n_chars); 1375 } 1376 1377 YY_CURRENT_BUFFER_LVALUE = new_buffer; 1378 __ktrfmt_load_buffer_state( ); 1379 1380 /* We don't actually know whether we did this switch during 1381 * EOF (__ktrfmtwrap()) processing, but the only time this flag 1382 * is looked at is after __ktrfmtwrap() is called, so it's safe 1383 * to go ahead and always set it. 1384 */ 1385 (yy_did_buffer_switch_on_eof) = 1; 1386 } 1387 1388 static void __ktrfmt_load_buffer_state (void) 1389 { 1390 (yy_n_chars) = YY_CURRENT_BUFFER_LVALUE->yy_n_chars; 1391 (yytext_ptr) = (yy_c_buf_p) = YY_CURRENT_BUFFER_LVALUE->yy_buf_pos; 1392 __ktrfmtin = YY_CURRENT_BUFFER_LVALUE->yy_input_file; 1393 (yy_hold_char) = *(yy_c_buf_p); 1394 } 1395 1396 /** Allocate and initialize an input buffer state. 1397 * @param file A readable stream. 1398 * @param size The character buffer size in bytes. When in doubt, use @c YY_BUF_SIZE. 1399 * 1400 * @return the allocated buffer state. 1401 */ 1402 YY_BUFFER_STATE __ktrfmt_create_buffer (FILE * file, int size ) 1403 { 1404 YY_BUFFER_STATE b; 1405 1406 b = (YY_BUFFER_STATE) __ktrfmtalloc(sizeof( struct yy_buffer_state ) ); 1407 if ( ! b ) 1408 YY_FATAL_ERROR( "out of dynamic memory in __ktrfmt_create_buffer()" ); 1409 1410 b->yy_buf_size = size; 1411 1412 /* yy_ch_buf has to be 2 characters longer than the size given because 1413 * we need to put in 2 end-of-buffer characters. 1414 */ 1415 b->yy_ch_buf = (char *) __ktrfmtalloc(b->yy_buf_size + 2 ); 1416 if ( ! b->yy_ch_buf ) 1417 YY_FATAL_ERROR( "out of dynamic memory in __ktrfmt_create_buffer()" ); 1418 1419 b->yy_is_our_buffer = 1; 1420 1421 __ktrfmt_init_buffer(b,file ); 1422 1423 return b; 1424 } 1425 1426 /** Destroy the buffer. 1427 * @param b a buffer created with __ktrfmt_create_buffer() 1428 * 1429 */ 1430 void __ktrfmt_delete_buffer (YY_BUFFER_STATE b ) 1431 { 1432 1433 if ( ! b ) 1434 return; 1435 1436 if ( b == YY_CURRENT_BUFFER ) /* Not sure if we should pop here. */ 1437 YY_CURRENT_BUFFER_LVALUE = (YY_BUFFER_STATE) 0; 1438 1439 if ( b->yy_is_our_buffer ) 1440 __ktrfmtfree((void *) b->yy_ch_buf ); 1441 1442 __ktrfmtfree((void *) b ); 1443 } 1444 1445 #ifndef __cplusplus 1446 extern int isatty (int ); 1447 #endif /* __cplusplus */ 1448 1449 /* Initializes or reinitializes a buffer. 1450 * This function is sometimes called more than once on the same buffer, 1451 * such as during a __ktrfmtrestart() or at EOF. 1452 */ 1453 static void __ktrfmt_init_buffer (YY_BUFFER_STATE b, FILE * file ) 1454 1455 { 1456 int oerrno = errno; 1457 1458 __ktrfmt_flush_buffer(b ); 1459 1460 b->yy_input_file = file; 1461 b->yy_fill_buffer = 1; 1462 1463 /* If b is the current buffer, then __ktrfmt_init_buffer was _probably_ 1464 * called from __ktrfmtrestart() or through yy_get_next_buffer. 1465 * In that case, we don't want to reset the lineno or column. 1466 */ 1467 if (b != YY_CURRENT_BUFFER){ 1468 b->yy_bs_lineno = 1; 1469 b->yy_bs_column = 0; 1470 } 1471 1472 b->yy_is_interactive = file ? (isatty( fileno(file) ) > 0) : 0; 1473 1474 errno = oerrno; 1475 } 1476 1477 /** Discard all buffered characters. On the next scan, YY_INPUT will be called. 1478 * @param b the buffer state to be flushed, usually @c YY_CURRENT_BUFFER. 1479 * 1480 */ 1481 void __ktrfmt_flush_buffer (YY_BUFFER_STATE b ) 1482 { 1483 if ( ! b ) 1484 return; 1485 1486 b->yy_n_chars = 0; 1487 1488 /* We always need two end-of-buffer characters. The first causes 1489 * a transition to the end-of-buffer state. The second causes 1490 * a jam in that state. 1491 */ 1492 b->yy_ch_buf[0] = YY_END_OF_BUFFER_CHAR; 1493 b->yy_ch_buf[1] = YY_END_OF_BUFFER_CHAR; 1494 1495 b->yy_buf_pos = &b->yy_ch_buf[0]; 1496 1497 b->yy_at_bol = 1; 1498 b->yy_buffer_status = YY_BUFFER_NEW; 1499 1500 if ( b == YY_CURRENT_BUFFER ) 1501 __ktrfmt_load_buffer_state( ); 1502 } 1503 1504 /** Pushes the new state onto the stack. The new state becomes 1505 * the current state. This function will allocate the stack 1506 * if necessary. 1507 * @param new_buffer The new state. 1508 * 1509 */ 1510 void __ktrfmtpush_buffer_state (YY_BUFFER_STATE new_buffer ) 1511 { 1512 if (new_buffer == NULL) 1513 return; 1514 1515 __ktrfmtensure_buffer_stack(); 1516 1517 /* This block is copied from __ktrfmt_switch_to_buffer. */ 1518 if ( YY_CURRENT_BUFFER ) 1519 { 1520 /* Flush out information for old buffer. */ 1521 *(yy_c_buf_p) = (yy_hold_char); 1522 YY_CURRENT_BUFFER_LVALUE->yy_buf_pos = (yy_c_buf_p); 1523 YY_CURRENT_BUFFER_LVALUE->yy_n_chars = (yy_n_chars); 1524 } 1525 1526 /* Only push if top exists. Otherwise, replace top. */ 1527 if (YY_CURRENT_BUFFER) 1528 (yy_buffer_stack_top)++; 1529 YY_CURRENT_BUFFER_LVALUE = new_buffer; 1530 1531 /* copied from __ktrfmt_switch_to_buffer. */ 1532 __ktrfmt_load_buffer_state( ); 1533 (yy_did_buffer_switch_on_eof) = 1; 1534 } 1535 1536 /** Removes and deletes the top of the stack, if present. 1537 * The next element becomes the new top. 1538 * 1539 */ 1540 void __ktrfmtpop_buffer_state (void) 1541 { 1542 if (!YY_CURRENT_BUFFER) 1543 return; 1544 1545 __ktrfmt_delete_buffer(YY_CURRENT_BUFFER ); 1546 YY_CURRENT_BUFFER_LVALUE = NULL; 1547 if ((yy_buffer_stack_top) > 0) 1548 --(yy_buffer_stack_top); 1549 1550 if (YY_CURRENT_BUFFER) { 1551 __ktrfmt_load_buffer_state( ); 1552 (yy_did_buffer_switch_on_eof) = 1; 1553 } 1554 } 1555 1556 /* Allocates the stack if it does not exist. 1557 * Guarantees space for at least one push. 1558 */ 1559 static void __ktrfmtensure_buffer_stack (void) 1560 { 1561 int num_to_alloc; 1562 1563 if (!(yy_buffer_stack)) { 1564 1565 /* First allocation is just for 2 elements, since we don't know if this 1566 * scanner will even need a stack. We use 2 instead of 1 to avoid an 1567 * immediate realloc on the next call. 1568 */ 1569 num_to_alloc = 1; 1570 (yy_buffer_stack) = (struct yy_buffer_state**)__ktrfmtalloc 1571 (num_to_alloc * sizeof(struct yy_buffer_state*) 1572 ); 1573 if ( ! (yy_buffer_stack) ) 1574 YY_FATAL_ERROR( "out of dynamic memory in __ktrfmtensure_buffer_stack()" ); 1575 1576 memset((yy_buffer_stack), 0, num_to_alloc * sizeof(struct yy_buffer_state*)); 1577 1578 (yy_buffer_stack_max) = num_to_alloc; 1579 (yy_buffer_stack_top) = 0; 1580 return; 1581 } 1582 1583 if ((yy_buffer_stack_top) >= ((yy_buffer_stack_max)) - 1){ 1584 1585 /* Increase the buffer to prepare for a possible push. */ 1586 int grow_size = 8 /* arbitrary grow size */; 1587 1588 num_to_alloc = (yy_buffer_stack_max) + grow_size; 1589 (yy_buffer_stack) = (struct yy_buffer_state**)__ktrfmtrealloc 1590 ((yy_buffer_stack), 1591 num_to_alloc * sizeof(struct yy_buffer_state*) 1592 ); 1593 if ( ! (yy_buffer_stack) ) 1594 YY_FATAL_ERROR( "out of dynamic memory in __ktrfmtensure_buffer_stack()" ); 1595 1596 /* zero only the new slots.*/ 1597 memset((yy_buffer_stack) + (yy_buffer_stack_max), 0, grow_size * sizeof(struct yy_buffer_state*)); 1598 (yy_buffer_stack_max) = num_to_alloc; 1599 } 1600 } 1601 1602 /** Setup the input buffer state to scan directly from a user-specified character buffer. 1603 * @param base the character buffer 1604 * @param size the size in bytes of the character buffer 1605 * 1606 * @return the newly allocated buffer state object. 1607 */ 1608 YY_BUFFER_STATE __ktrfmt_scan_buffer (char * base, yy_size_t size ) 1609 { 1610 YY_BUFFER_STATE b; 1611 1612 if ( size < 2 || 1613 base[size-2] != YY_END_OF_BUFFER_CHAR || 1614 base[size-1] != YY_END_OF_BUFFER_CHAR ) 1615 /* They forgot to leave room for the EOB's. */ 1616 return 0; 1617 1618 b = (YY_BUFFER_STATE) __ktrfmtalloc(sizeof( struct yy_buffer_state ) ); 1619 if ( ! b ) 1620 YY_FATAL_ERROR( "out of dynamic memory in __ktrfmt_scan_buffer()" ); 1621 1622 b->yy_buf_size = size - 2; /* "- 2" to take care of EOB's */ 1623 b->yy_buf_pos = b->yy_ch_buf = base; 1624 b->yy_is_our_buffer = 0; 1625 b->yy_input_file = NULL; 1626 b->yy_n_chars = b->yy_buf_size; 1627 b->yy_is_interactive = 0; 1628 b->yy_at_bol = 1; 1629 b->yy_fill_buffer = 0; 1630 b->yy_buffer_status = YY_BUFFER_NEW; 1631 1632 __ktrfmt_switch_to_buffer(b ); 1633 1634 return b; 1635 } 1636 1637 /** Setup the input buffer state to scan a string. The next call to __ktrfmtlex() will 1638 * scan from a @e copy of @a str. 1639 * @param yystr a NUL-terminated string to scan 1640 * 1641 * @return the newly allocated buffer state object. 1642 * @note If you want to scan bytes that may contain NUL values, then use 1643 * __ktrfmt_scan_bytes() instead. 1644 */ 1645 YY_BUFFER_STATE __ktrfmt_scan_string (yyconst char * yystr ) 1646 { 1647 1648 return __ktrfmt_scan_bytes(yystr,strlen(yystr) ); 1649 } 1650 1651 /** Setup the input buffer state to scan the given bytes. The next call to __ktrfmtlex() will 1652 * scan from a @e copy of @a bytes. 1653 * @param bytes the byte buffer to scan 1654 * @param len the number of bytes in the buffer pointed to by @a bytes. 1655 * 1656 * @return the newly allocated buffer state object. 1657 */ 1658 YY_BUFFER_STATE __ktrfmt_scan_bytes (yyconst char * yybytes, int _yybytes_len ) 1659 { 1660 YY_BUFFER_STATE b; 1661 char *buf; 1662 yy_size_t n; 1663 int i; 1664 1665 /* Get memory for full buffer, including space for trailing EOB's. */ 1666 n = _yybytes_len + 2; 1667 buf = (char *) __ktrfmtalloc(n ); 1668 if ( ! buf ) 1669 YY_FATAL_ERROR( "out of dynamic memory in __ktrfmt_scan_bytes()" ); 1670 1671 for ( i = 0; i < _yybytes_len; ++i ) 1672 buf[i] = yybytes[i]; 1673 1674 buf[_yybytes_len] = buf[_yybytes_len+1] = YY_END_OF_BUFFER_CHAR; 1675 1676 b = __ktrfmt_scan_buffer(buf,n ); 1677 if ( ! b ) 1678 YY_FATAL_ERROR( "bad buffer in __ktrfmt_scan_bytes()" ); 1679 1680 /* It's okay to grow etc. this buffer, and we should throw it 1681 * away when we're done. 1682 */ 1683 b->yy_is_our_buffer = 1; 1684 1685 return b; 1686 } 1687 1688 #ifndef YY_EXIT_FAILURE 1689 #define YY_EXIT_FAILURE 2 1690 #endif 1691 1692 static void yy_fatal_error (yyconst char* msg ) 1693 { 1694 (void) fprintf( stderr, "%s\n", msg ); 1695 exit( YY_EXIT_FAILURE ); 1696 } 1697 1698 /* Redefine yyless() so it works in section 3 code. */ 1699 1700 #undef yyless 1701 #define yyless(n) \ 1702 do \ 1703 { \ 1704 /* Undo effects of setting up __ktrfmttext. */ \ 1705 int yyless_macro_arg = (n); \ 1706 YY_LESS_LINENO(yyless_macro_arg);\ 1707 __ktrfmttext[__ktrfmtleng] = (yy_hold_char); \ 1708 (yy_c_buf_p) = __ktrfmttext + yyless_macro_arg; \ 1709 (yy_hold_char) = *(yy_c_buf_p); \ 1710 *(yy_c_buf_p) = '\0'; \ 1711 __ktrfmtleng = yyless_macro_arg; \ 1712 } \ 1713 while ( 0 ) 1714 1715 /* Accessor methods (get/set functions) to struct members. */ 1716 1717 /** Get the current line number. 1718 * 1719 */ 1720 int __ktrfmtget_lineno (void) 1721 { 1722 1723 return __ktrfmtlineno; 1724 } 1725 1726 /** Get the input stream. 1727 * 1728 */ 1729 FILE *__ktrfmtget_in (void) 1730 { 1731 return __ktrfmtin; 1732 } 1733 1734 /** Get the output stream. 1735 * 1736 */ 1737 FILE *__ktrfmtget_out (void) 1738 { 1739 return __ktrfmtout; 1740 } 1741 1742 /** Get the length of the current token. 1743 * 1744 */ 1745 int __ktrfmtget_leng (void) 1746 { 1747 return __ktrfmtleng; 1748 } 1749 1750 /** Get the current token. 1751 * 1752 */ 1753 1754 char *__ktrfmtget_text (void) 1755 { 1756 return __ktrfmttext; 1757 } 1758 1759 /** Set the current line number. 1760 * @param line_number 1761 * 1762 */ 1763 void __ktrfmtset_lineno (int line_number ) 1764 { 1765 1766 __ktrfmtlineno = line_number; 1767 } 1768 1769 /** Set the input stream. This does not discard the current 1770 * input buffer. 1771 * @param in_str A readable stream. 1772 * 1773 * @see __ktrfmt_switch_to_buffer 1774 */ 1775 void __ktrfmtset_in (FILE * in_str ) 1776 { 1777 __ktrfmtin = in_str ; 1778 } 1779 1780 void __ktrfmtset_out (FILE * out_str ) 1781 { 1782 __ktrfmtout = out_str ; 1783 } 1784 1785 int __ktrfmtget_debug (void) 1786 { 1787 return __ktrfmt_flex_debug; 1788 } 1789 1790 void __ktrfmtset_debug (int bdebug ) 1791 { 1792 __ktrfmt_flex_debug = bdebug ; 1793 } 1794 1795 static int yy_init_globals (void) 1796 { 1797 /* Initialization is the same as for the non-reentrant scanner. 1798 * This function is called from __ktrfmtlex_destroy(), so don't allocate here. 1799 */ 1800 1801 (yy_buffer_stack) = NULL; 1802 (yy_buffer_stack_top) = 0; 1803 (yy_buffer_stack_max) = 0; 1804 (yy_c_buf_p) = (char *) 0; 1805 (yy_init) = 0; 1806 (yy_start) = 0; 1807 1808 /* Defined in main.c */ 1809 #ifdef YY_STDINIT 1810 __ktrfmtin = stdin; 1811 __ktrfmtout = stdout; 1812 #else 1813 __ktrfmtin = (FILE *) 0; 1814 __ktrfmtout = (FILE *) 0; 1815 #endif 1816 1817 /* For future reference: Set errno on error, since we are called by 1818 * __ktrfmtlex_init() 1819 */ 1820 return 0; 1821 } 1822 1823 /* __ktrfmtlex_destroy is for both reentrant and non-reentrant scanners. */ 1824 int __ktrfmtlex_destroy (void) 1825 { 1826 1827 /* Pop the buffer stack, destroying each element. */ 1828 while(YY_CURRENT_BUFFER){ 1829 __ktrfmt_delete_buffer(YY_CURRENT_BUFFER ); 1830 YY_CURRENT_BUFFER_LVALUE = NULL; 1831 __ktrfmtpop_buffer_state(); 1832 } 1833 1834 /* Destroy the stack itself. */ 1835 __ktrfmtfree((yy_buffer_stack) ); 1836 (yy_buffer_stack) = NULL; 1837 1838 /* Reset the globals. This is important in a non-reentrant scanner so the next time 1839 * __ktrfmtlex() is called, initialization will occur. */ 1840 yy_init_globals( ); 1841 1842 return 0; 1843 } 1844 1845 /* 1846 * Internal utility routines. 1847 */ 1848 1849 #ifndef yytext_ptr 1850 static void yy_flex_strncpy (char* s1, yyconst char * s2, int n ) 1851 { 1852 register int i; 1853 for ( i = 0; i < n; ++i ) 1854 s1[i] = s2[i]; 1855 } 1856 #endif 1857 1858 #ifdef YY_NEED_STRLEN 1859 static int yy_flex_strlen (yyconst char * s ) 1860 { 1861 register int n; 1862 for ( n = 0; s[n]; ++n ) 1863 ; 1864 1865 return n; 1866 } 1867 #endif 1868 1869 void *__ktrfmtalloc (yy_size_t size ) 1870 { 1871 return (void *) malloc( size ); 1872 } 1873 1874 void *__ktrfmtrealloc (void * ptr, yy_size_t size ) 1875 { 1876 /* The cast to (char *) in the following accommodates both 1877 * implementations that use char* generic pointers, and those 1878 * that use void* generic pointers. It works with the latter 1879 * because both ANSI C and C++ allow castless assignment from 1880 * any pointer type to void*, and deal with argument conversions 1881 * as though doing an assignment. 1882 */ 1883 return (void *) realloc( (char *) ptr, size ); 1884 } 1885 1886 void __ktrfmtfree (void * ptr ) 1887 { 1888 free( (char *) ptr ); /* see __ktrfmtrealloc() for (char *) cast */ 1889 } 1890 1891 #define YYTABLES_NAME "yytables" 1892 1893 #line 137 "ktrfmt.l" 1894 1895 1896 1897