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