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