00001 #line 2 "src/Robots/LoBot/baylog/LoBaylogParser.C" 00002 00003 #line 4 "src/Robots/LoBot/baylog/LoBaylogParser.C" 00004 00005 #define YY_INT_ALIGNED short int 00006 00007 /* A lexical scanner generated by flex */ 00008 00009 #define FLEX_SCANNER 00010 #define YY_FLEX_MAJOR_VERSION 2 00011 #define YY_FLEX_MINOR_VERSION 5 00012 #define YY_FLEX_SUBMINOR_VERSION 33 00013 #if YY_FLEX_SUBMINOR_VERSION > 0 00014 #define FLEX_BETA 00015 #endif 00016 00017 /* First, we deal with platform-specific or compiler-specific issues. */ 00018 00019 /* begin standard C headers. */ 00020 #include <stdio.h> 00021 #include <string.h> 00022 #include <errno.h> 00023 #include <stdlib.h> 00024 00025 /* end standard C headers. */ 00026 00027 /* flex integer type definitions */ 00028 00029 #ifndef FLEXINT_H 00030 #define FLEXINT_H 00031 00032 /* C99 systems have <inttypes.h>. Non-C99 systems may or may not. */ 00033 00034 #if __STDC_VERSION__ >= 199901L 00035 00036 /* C99 says to define __STDC_LIMIT_MACROS before including stdint.h, 00037 * if you want the limit (max/min) macros for int types. 00038 */ 00039 #ifndef __STDC_LIMIT_MACROS 00040 #define __STDC_LIMIT_MACROS 1 00041 #endif 00042 00043 #include <inttypes.h> 00044 typedef int8_t flex_int8_t; 00045 typedef uint8_t flex_uint8_t; 00046 typedef int16_t flex_int16_t; 00047 typedef uint16_t flex_uint16_t; 00048 typedef int32_t flex_int32_t; 00049 typedef uint32_t flex_uint32_t; 00050 #else 00051 typedef signed char flex_int8_t; 00052 typedef short int flex_int16_t; 00053 typedef int flex_int32_t; 00054 typedef unsigned char flex_uint8_t; 00055 typedef unsigned short int flex_uint16_t; 00056 typedef unsigned int flex_uint32_t; 00057 #endif /* ! C99 */ 00058 00059 /* Limits of integral types. */ 00060 #ifndef INT8_MIN 00061 #define INT8_MIN (-128) 00062 #endif 00063 #ifndef INT16_MIN 00064 #define INT16_MIN (-32767-1) 00065 #endif 00066 #ifndef INT32_MIN 00067 #define INT32_MIN (-2147483647-1) 00068 #endif 00069 #ifndef INT8_MAX 00070 #define INT8_MAX (127) 00071 #endif 00072 #ifndef INT16_MAX 00073 #define INT16_MAX (32767) 00074 #endif 00075 #ifndef INT32_MAX 00076 #define INT32_MAX (2147483647) 00077 #endif 00078 #ifndef UINT8_MAX 00079 #define UINT8_MAX (255U) 00080 #endif 00081 #ifndef UINT16_MAX 00082 #define UINT16_MAX (65535U) 00083 #endif 00084 #ifndef UINT32_MAX 00085 #define UINT32_MAX (4294967295U) 00086 #endif 00087 00088 #endif /* ! FLEXINT_H */ 00089 00090 #ifdef __cplusplus 00091 00092 /* The "const" storage-class-modifier is valid. */ 00093 #define YY_USE_CONST 00094 00095 #else /* ! __cplusplus */ 00096 00097 #if __STDC__ 00098 00099 #define YY_USE_CONST 00100 00101 #endif /* __STDC__ */ 00102 #endif /* ! __cplusplus */ 00103 00104 #ifdef YY_USE_CONST 00105 #define yyconst const 00106 #else 00107 #define yyconst 00108 #endif 00109 00110 /* Returned upon end-of-file. */ 00111 #define YY_NULL 0 00112 00113 /* Promotes a possibly negative, possibly signed char to an unsigned 00114 * integer for use as an array index. If the signed char is negative, 00115 * we want to instead treat it as an 8-bit unsigned char, hence the 00116 * double cast. 00117 */ 00118 #define YY_SC_TO_UI(c) ((unsigned int) (unsigned char) c) 00119 00120 /* An opaque pointer. */ 00121 #ifndef YY_TYPEDEF_YY_SCANNER_T 00122 #define YY_TYPEDEF_YY_SCANNER_T 00123 typedef void* yyscan_t; 00124 #endif 00125 00126 /* For convenience, these vars (plus the bison vars far below) 00127 are macros in the reentrant scanner. */ 00128 #define yyin yyg->yyin_r 00129 #define yyout yyg->yyout_r 00130 #define yyextra yyg->yyextra_r 00131 #define yyleng yyg->yyleng_r 00132 #define yytext yyg->yytext_r 00133 #define yylineno (YY_CURRENT_BUFFER_LVALUE->yy_bs_lineno) 00134 #define yycolumn (YY_CURRENT_BUFFER_LVALUE->yy_bs_column) 00135 #define yy_flex_debug yyg->yy_flex_debug_r 00136 00137 int lobay_parser_lex_init (yyscan_t* scanner); 00138 00139 /* Enter a start condition. This macro really ought to take a parameter, 00140 * but we do it the disgusting crufty way forced on us by the ()-less 00141 * definition of BEGIN. 00142 */ 00143 #define BEGIN yyg->yy_start = 1 + 2 * 00144 00145 /* Translate the current start state into a value that can be later handed 00146 * to BEGIN to return to the state. The YYSTATE alias is for lex 00147 * compatibility. 00148 */ 00149 #define YY_START ((yyg->yy_start - 1) / 2) 00150 #define YYSTATE YY_START 00151 00152 /* Action number for EOF rule of a given start state. */ 00153 #define YY_STATE_EOF(state) (YY_END_OF_BUFFER + state + 1) 00154 00155 /* Special action meaning "start processing a new file". */ 00156 #define YY_NEW_FILE lobay_parser_restart(yyin ,yyscanner ) 00157 00158 #define YY_END_OF_BUFFER_CHAR 0 00159 00160 /* Size of default input buffer. */ 00161 #ifndef YY_BUF_SIZE 00162 #define YY_BUF_SIZE 16384 00163 #endif 00164 00165 /* The state buf must be large enough to hold one state per character in the main buffer. 00166 */ 00167 #define YY_STATE_BUF_SIZE ((YY_BUF_SIZE + 2) * sizeof(yy_state_type)) 00168 00169 #ifndef YY_TYPEDEF_YY_BUFFER_STATE 00170 #define YY_TYPEDEF_YY_BUFFER_STATE 00171 typedef struct yy_buffer_state *YY_BUFFER_STATE; 00172 #endif 00173 00174 #define EOB_ACT_CONTINUE_SCAN 0 00175 #define EOB_ACT_END_OF_FILE 1 00176 #define EOB_ACT_LAST_MATCH 2 00177 00178 #define YY_LESS_LINENO(n) 00179 00180 /* Return all but the first "n" matched characters back to the input stream. */ 00181 #define yyless(n) \ 00182 do \ 00183 { \ 00184 /* Undo effects of setting up yytext. */ \ 00185 int yyless_macro_arg = (n); \ 00186 YY_LESS_LINENO(yyless_macro_arg);\ 00187 *yy_cp = yyg->yy_hold_char; \ 00188 YY_RESTORE_YY_MORE_OFFSET \ 00189 yyg->yy_c_buf_p = yy_cp = yy_bp + yyless_macro_arg - YY_MORE_ADJ; \ 00190 YY_DO_BEFORE_ACTION; /* set up yytext again */ \ 00191 } \ 00192 while ( 0 ) 00193 00194 #define unput(c) yyunput( c, yyg->yytext_ptr , yyscanner ) 00195 00196 /* The following is because we cannot portably get our hands on size_t 00197 * (without autoconf's help, which isn't available because we want 00198 * flex-generated scanners to compile on their own). 00199 */ 00200 00201 #ifndef YY_TYPEDEF_YY_SIZE_T 00202 #define YY_TYPEDEF_YY_SIZE_T 00203 typedef unsigned int yy_size_t; 00204 #endif 00205 00206 #ifndef YY_STRUCT_YY_BUFFER_STATE 00207 #define YY_STRUCT_YY_BUFFER_STATE 00208 struct yy_buffer_state 00209 { 00210 FILE *yy_input_file; 00211 00212 char *yy_ch_buf; /* input buffer */ 00213 char *yy_buf_pos; /* current position in input buffer */ 00214 00215 /* Size of input buffer in bytes, not including room for EOB 00216 * characters. 00217 */ 00218 yy_size_t yy_buf_size; 00219 00220 /* Number of characters read into yy_ch_buf, not including EOB 00221 * characters. 00222 */ 00223 int yy_n_chars; 00224 00225 /* Whether we "own" the buffer - i.e., we know we created it, 00226 * and can realloc() it to grow it, and should free() it to 00227 * delete it. 00228 */ 00229 int yy_is_our_buffer; 00230 00231 /* Whether this is an "interactive" input source; if so, and 00232 * if we're using stdio for input, then we want to use getc() 00233 * instead of fread(), to make sure we stop fetching input after 00234 * each newline. 00235 */ 00236 int yy_is_interactive; 00237 00238 /* Whether we're considered to be at the beginning of a line. 00239 * If so, '^' rules will be active on the next match, otherwise 00240 * not. 00241 */ 00242 int yy_at_bol; 00243 00244 int yy_bs_lineno; /**< The line count. */ 00245 int yy_bs_column; /**< The column count. */ 00246 00247 /* Whether to try to fill the input buffer when we reach the 00248 * end of it. 00249 */ 00250 int yy_fill_buffer; 00251 00252 int yy_buffer_status; 00253 00254 #define YY_BUFFER_NEW 0 00255 #define YY_BUFFER_NORMAL 1 00256 /* When an EOF's been seen but there's still some text to process 00257 * then we mark the buffer as YY_EOF_PENDING, to indicate that we 00258 * shouldn't try reading from the input source any more. We might 00259 * still have a bunch of tokens to match, though, because of 00260 * possible backing-up. 00261 * 00262 * When we actually see the EOF, we change the status to "new" 00263 * (via lobay_parser_restart()), so that the user can continue scanning by 00264 * just pointing yyin at a new input file. 00265 */ 00266 #define YY_BUFFER_EOF_PENDING 2 00267 00268 }; 00269 #endif /* !YY_STRUCT_YY_BUFFER_STATE */ 00270 00271 /* We provide macros for accessing buffer states in case in the 00272 * future we want to put the buffer states in a more general 00273 * "scanner state". 00274 * 00275 * Returns the top of the stack, or NULL. 00276 */ 00277 #define YY_CURRENT_BUFFER ( yyg->yy_buffer_stack \ 00278 ? yyg->yy_buffer_stack[yyg->yy_buffer_stack_top] \ 00279 : NULL) 00280 00281 /* Same as previous macro, but useful when we know that the buffer stack is not 00282 * NULL or when we need an lvalue. For internal use only. 00283 */ 00284 #define YY_CURRENT_BUFFER_LVALUE yyg->yy_buffer_stack[yyg->yy_buffer_stack_top] 00285 00286 void lobay_parser_restart (FILE *input_file ,yyscan_t yyscanner ); 00287 void lobay_parser__switch_to_buffer (YY_BUFFER_STATE new_buffer ,yyscan_t yyscanner ); 00288 YY_BUFFER_STATE lobay_parser__create_buffer (FILE *file,int size ,yyscan_t yyscanner ); 00289 void lobay_parser__delete_buffer (YY_BUFFER_STATE b ,yyscan_t yyscanner ); 00290 void lobay_parser__flush_buffer (YY_BUFFER_STATE b ,yyscan_t yyscanner ); 00291 void lobay_parser_push_buffer_state (YY_BUFFER_STATE new_buffer ,yyscan_t yyscanner ); 00292 void lobay_parser_pop_buffer_state (yyscan_t yyscanner ); 00293 00294 static void lobay_parser_ensure_buffer_stack (yyscan_t yyscanner ); 00295 static void lobay_parser__load_buffer_state (yyscan_t yyscanner ); 00296 static void lobay_parser__init_buffer (YY_BUFFER_STATE b,FILE *file ,yyscan_t yyscanner ); 00297 00298 #define YY_FLUSH_BUFFER lobay_parser__flush_buffer(YY_CURRENT_BUFFER ,yyscanner) 00299 00300 YY_BUFFER_STATE lobay_parser__scan_buffer (char *base,yy_size_t size ,yyscan_t yyscanner ); 00301 YY_BUFFER_STATE lobay_parser__scan_string (yyconst char *yy_str ,yyscan_t yyscanner ); 00302 YY_BUFFER_STATE lobay_parser__scan_bytes (yyconst char *bytes,int len ,yyscan_t yyscanner ); 00303 00304 void *lobay_parser_alloc (yy_size_t ,yyscan_t yyscanner ); 00305 void *lobay_parser_realloc (void *,yy_size_t ,yyscan_t yyscanner ); 00306 void lobay_parser_free (void * ,yyscan_t yyscanner ); 00307 00308 #define yy_new_buffer lobay_parser__create_buffer 00309 00310 #define yy_set_interactive(is_interactive) \ 00311 { \ 00312 if ( ! YY_CURRENT_BUFFER ){ \ 00313 lobay_parser_ensure_buffer_stack (yyscanner); \ 00314 YY_CURRENT_BUFFER_LVALUE = \ 00315 lobay_parser__create_buffer(yyin,YY_BUF_SIZE ,yyscanner); \ 00316 } \ 00317 YY_CURRENT_BUFFER_LVALUE->yy_is_interactive = is_interactive; \ 00318 } 00319 00320 #define yy_set_bol(at_bol) \ 00321 { \ 00322 if ( ! YY_CURRENT_BUFFER ){\ 00323 lobay_parser_ensure_buffer_stack (yyscanner); \ 00324 YY_CURRENT_BUFFER_LVALUE = \ 00325 lobay_parser__create_buffer(yyin,YY_BUF_SIZE ,yyscanner); \ 00326 } \ 00327 YY_CURRENT_BUFFER_LVALUE->yy_at_bol = at_bol; \ 00328 } 00329 00330 #define YY_AT_BOL() (YY_CURRENT_BUFFER_LVALUE->yy_at_bol) 00331 00332 #define lobay_parser_wrap(n) 1 00333 #define YY_SKIP_YYWRAP 00334 00335 typedef unsigned char YY_CHAR; 00336 00337 typedef int yy_state_type; 00338 00339 #define yytext_ptr yytext_r 00340 00341 static yy_state_type yy_get_previous_state (yyscan_t yyscanner ); 00342 static yy_state_type yy_try_NUL_trans (yy_state_type current_state ,yyscan_t yyscanner); 00343 static int yy_get_next_buffer (yyscan_t yyscanner ); 00344 static void yy_fatal_error (yyconst char msg[] ,yyscan_t yyscanner ); 00345 00346 /* Done after the current pattern has been matched and before the 00347 * corresponding action - sets up yytext. 00348 */ 00349 #define YY_DO_BEFORE_ACTION \ 00350 yyg->yytext_ptr = yy_bp; \ 00351 yyleng = (size_t) (yy_cp - yy_bp); \ 00352 yyg->yy_hold_char = *yy_cp; \ 00353 *yy_cp = '\0'; \ 00354 yyg->yy_c_buf_p = yy_cp; 00355 00356 #define YY_NUM_RULES 10 00357 #define YY_END_OF_BUFFER 11 00358 /* This struct is not used in this scanner, 00359 but its presence is necessary. */ 00360 struct yy_trans_info 00361 { 00362 flex_int32_t yy_verify; 00363 flex_int32_t yy_nxt; 00364 }; 00365 static yyconst flex_int16_t yy_accept[136] = 00366 { 0, 00367 0, 0, 0, 0, 0, 0, 11, 10, 10, 7, 00368 10, 7, 7, 7, 7, 9, 9, 8, 0, 0, 00369 6, 0, 0, 0, 8, 8, 0, 0, 0, 0, 00370 8, 0, 0, 0, 0, 0, 0, 0, 0, 0, 00371 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 00372 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 00373 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 00374 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 00375 0, 0, 0, 2, 0, 0, 0, 0, 0, 0, 00376 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 00377 00378 0, 0, 0, 0, 0, 0, 0, 0, 3, 0, 00379 5, 0, 0, 0, 0, 0, 4, 0, 0, 0, 00380 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 00381 0, 0, 0, 1, 0 00382 } ; 00383 00384 static yyconst flex_int32_t yy_ec[256] = 00385 { 0, 00386 1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 00387 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 00388 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 00389 1, 3, 1, 1, 1, 1, 1, 1, 1, 1, 00390 1, 1, 4, 1, 5, 6, 1, 7, 7, 7, 00391 7, 7, 7, 7, 7, 7, 7, 8, 1, 1, 00392 1, 1, 1, 1, 1, 1, 1, 9, 1, 1, 00393 10, 1, 11, 1, 1, 12, 13, 1, 1, 1, 00394 1, 1, 1, 14, 1, 1, 1, 1, 1, 1, 00395 1, 15, 1, 1, 16, 1, 17, 1, 18, 19, 00396 00397 20, 21, 22, 1, 23, 1, 24, 25, 26, 27, 00398 28, 29, 1, 30, 31, 32, 33, 1, 1, 34, 00399 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 00400 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 00401 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 00402 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 00403 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 00404 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 00405 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 00406 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 00407 00408 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 00409 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 00410 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 00411 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 00412 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 00413 1, 1, 1, 1, 1 00414 } ; 00415 00416 static yyconst flex_int32_t yy_meta[35] = 00417 { 0, 00418 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 00419 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 00420 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 00421 1, 1, 1, 1 00422 } ; 00423 00424 static yyconst flex_int16_t yy_base[139] = 00425 { 0, 00426 0, 142, 0, 1, 2, 17, 148, 150, 7, 145, 00427 144, 18, 150, 9, 3, 150, 138, 19, 119, 28, 00428 150, 130, 110, 121, 30, 133, 117, 129, 104, 117, 00429 128, 108, 130, 115, 108, 111, 98, 103, 109, 110, 00430 96, 121, 91, 102, 98, 88, 18, 85, 94, 94, 00431 97, 87, 82, 93, 86, 108, 83, 79, 105, 87, 00432 74, 102, 81, 73, 97, 78, 82, 81, 81, 65, 00433 70, 67, 77, 61, 64, 71, 63, 57, 68, 82, 00434 81, 64, 64, 150, 60, 50, 58, 64, 53, 50, 00435 58, 44, 46, 69, 53, 40, 54, 47, 42, 45, 00436 00437 49, 40, 47, 61, 31, 33, 41, 57, 150, 42, 00438 150, 44, 39, 42, 23, 43, 150, 50, 32, 20, 00439 18, 26, 22, 30, 14, 17, 14, 40, 19, 13, 00440 18, 6, 24, 150, 150, 22, 7, 0 00441 } ; 00442 00443 static yyconst flex_int16_t yy_def[139] = 00444 { 0, 00445 136, 136, 137, 137, 138, 138, 135, 135, 135, 135, 00446 135, 135, 135, 135, 135, 135, 135, 135, 135, 135, 00447 135, 135, 135, 135, 135, 135, 135, 135, 135, 135, 00448 135, 135, 135, 135, 135, 135, 135, 135, 135, 135, 00449 135, 135, 135, 135, 135, 135, 135, 135, 135, 135, 00450 135, 135, 135, 135, 135, 135, 135, 135, 135, 135, 00451 135, 135, 135, 135, 135, 135, 135, 135, 135, 135, 00452 135, 135, 135, 135, 135, 135, 135, 135, 135, 135, 00453 135, 135, 135, 135, 135, 135, 135, 135, 135, 135, 00454 135, 135, 135, 135, 135, 135, 135, 135, 135, 135, 00455 00456 135, 135, 135, 135, 135, 135, 135, 135, 135, 135, 00457 135, 135, 135, 135, 135, 135, 135, 135, 135, 135, 00458 135, 135, 135, 135, 135, 135, 135, 135, 135, 135, 00459 135, 135, 135, 135, 0, 135, 135, 135 00460 } ; 00461 00462 static yyconst flex_int16_t yy_nxt[185] = 00463 { 0, 00464 16, 11, 11, 8, 21, 17, 17, 10, 18, 19, 00465 21, 12, 12, 20, 13, 13, 14, 14, 8, 21, 00466 17, 17, 8, 18, 26, 25, 23, 22, 15, 15, 00467 19, 134, 24, 133, 20, 26, 25, 51, 132, 131, 00468 52, 130, 129, 128, 127, 126, 125, 124, 123, 122, 00469 121, 120, 119, 118, 117, 116, 115, 114, 113, 112, 00470 111, 110, 109, 108, 107, 106, 105, 104, 103, 102, 00471 101, 100, 99, 98, 97, 96, 95, 94, 93, 92, 00472 91, 90, 89, 88, 87, 86, 85, 84, 83, 82, 00473 81, 80, 79, 78, 77, 76, 75, 74, 73, 72, 00474 00475 71, 70, 69, 68, 67, 66, 65, 64, 63, 62, 00476 61, 60, 59, 58, 57, 56, 55, 54, 53, 50, 00477 49, 48, 47, 46, 45, 44, 43, 42, 41, 40, 00478 39, 38, 37, 36, 31, 35, 34, 33, 32, 31, 00479 30, 29, 28, 27, 25, 21, 21, 135, 9, 7, 00480 135, 135, 135, 135, 135, 135, 135, 135, 135, 135, 00481 135, 135, 135, 135, 135, 135, 135, 135, 135, 135, 00482 135, 135, 135, 135, 135, 135, 135, 135, 135, 135, 00483 135, 135, 135, 135 00484 } ; 00485 00486 static yyconst flex_int16_t yy_chk[185] = 00487 { 0, 00488 138, 3, 4, 5, 15, 5, 5, 137, 5, 9, 00489 14, 3, 4, 9, 3, 4, 3, 4, 6, 12, 00490 6, 6, 136, 6, 18, 18, 14, 12, 3, 4, 00491 20, 133, 15, 132, 20, 25, 25, 47, 131, 130, 00492 47, 129, 128, 127, 126, 125, 124, 123, 122, 121, 00493 120, 119, 118, 116, 115, 114, 113, 112, 110, 108, 00494 107, 106, 105, 104, 103, 102, 101, 100, 99, 98, 00495 97, 96, 95, 94, 93, 92, 91, 90, 89, 88, 00496 87, 86, 85, 83, 82, 81, 80, 79, 78, 77, 00497 76, 75, 74, 73, 72, 71, 70, 69, 68, 67, 00498 00499 66, 65, 64, 63, 62, 61, 60, 59, 58, 57, 00500 56, 55, 54, 53, 52, 51, 50, 49, 48, 46, 00501 45, 44, 43, 42, 41, 40, 39, 38, 37, 36, 00502 35, 34, 33, 32, 31, 30, 29, 28, 27, 26, 00503 24, 23, 22, 19, 17, 11, 10, 7, 2, 135, 00504 135, 135, 135, 135, 135, 135, 135, 135, 135, 135, 00505 135, 135, 135, 135, 135, 135, 135, 135, 135, 135, 00506 135, 135, 135, 135, 135, 135, 135, 135, 135, 135, 00507 135, 135, 135, 135 00508 } ; 00509 00510 /* The intent behind this definition is that it'll catch 00511 * any uses of REJECT which flex missed. 00512 */ 00513 #define REJECT reject_used_but_not_detected 00514 #define yymore() yymore_used_but_not_detected 00515 #define YY_MORE_ADJ 0 00516 #define YY_RESTORE_YY_MORE_OFFSET 00517 #line 1 "src/Robots/LoBot/baylog/LoBaylogParser.l" 00518 /* -*- mode: C;-*- */ 00519 #line 3 "src/Robots/LoBot/baylog/LoBaylogParser.l" 00520 /* 00521 LoBaylogParser.l -- parsing Bayesian TTI prediction experiments log files 00522 00523 This file defines various rules for parsing the metrics logs collected 00524 during the experiments designed to gauge the Bayesian time-to-impact 00525 prediction model used by Robolocust's TTI algorithm for LGMD-based 00526 obstacle avoidance. 00527 00528 Since these log files are fairly straightforward to parse, we don't 00529 really need a grammar and, therefore, yacc/bison. lex alone will do a 00530 fine job. That's why this "lexical analyzer" is referred to as a 00531 "parser." In fact, this lexer really is a parser because it isn't 00532 concerned with tokenization; instead, it simply looks for certain 00533 patterns in the input and immediately takes appropriate action to 00534 parse that input. 00535 00536 NOTE: This parser is designed specifically for the metlog files spit 00537 out by the Bayesian TTI prediction experiments concerned with 00538 measuring the performance of the time-to-impact state estimator used 00539 by the TTI algorithm for LGMD-based obstacle avoidance. It won't work 00540 with arbitrary metlog files. 00541 */ 00542 00543 // Primary maintainer for this file: mviswana usc edu 00544 // $HeadURL: svn://isvn.usc.edu/software/invt/trunk/saliency/src/Robots/LoBot/baylog/LoBaylogParser.C $ 00545 // $Id: LoBaylogParser.C 14083 2010-09-30 13:59:37Z mviswana $ 00546 00547 // lobot headers 00548 #include "Robots/LoBot/baylog/LoTTIMap.H" 00549 #include "Robots/LoBot/util/LoString.H" 00550 00551 // In the code generated by flex, the yy_get_next_buffer() function 00552 // performs a comparison between a signed and unsigned variable. This 00553 // produces a compiler warning, which results in an error because, by 00554 // default, INVT builds are setup to treat all warnings as errors. Since 00555 // we really can't fix the code generated by flex, we resort to turning 00556 // off this warning so that the .C file generated from this Lex source 00557 // builds without any hassles. 00558 // 00559 // DEVNOTE: On Debian etch, which has GCC 4.1.2, this works fine because, 00560 // apparently, the compiler does not care for the signed-unsigned match 00561 // in yy_get_next_buffer(). 00562 // 00563 // On Debian lenny, which comes with GCC 4.3.2, and on Ubuntu 10.04LTS 00564 // (Lucid Lynx), which comes with GCC 4.4.3, the diagnostic pragma is 00565 // supported. Thus, we test for at least version 4.3 of GCC. 00566 // 00567 // This may not work on other systems with other versions of GCC. An 00568 // alternative workaround is not known for this particular problem. 00569 #if __GNUC__ >= 4 && __GNUC_MINOR__ >= 3 00570 #pragma GCC diagnostic ignored "-Wsign-compare" 00571 #endif 00572 00573 // The lobot::BaylogAnalyzer object, which is responsible for loading and 00574 // parsing the log files generated during the Bayesian TTI prediction 00575 // experiments, uses this lex-generated scanner for the desired parsing 00576 // functionality. The parsing results are stored in an instance of the 00577 // lobot::TTIMap class. The analyzer object has to create the TTIMap that 00578 // will receive parsing results and pass it to this scanner module using 00579 // flex's extra data mechanism. 00580 // 00581 // By default, flex considers extra data to be a void* that should be 00582 // type-cast as required. However, we can use this macro to redefine the 00583 // extra data's type so as to avoid unnecessary casting. 00584 #define YY_EXTRA_TYPE lobot::TTIMap* 00585 00586 // When no rules match, flex's default action is to echo the input to 00587 // stdout. This can be quite annoying when we would like our program to 00588 // go about its work with minimal chatter. 00589 // 00590 // One way to suppress the echo action is to define a fallback rule at 00591 // the end of the rules section that applies when none of the other match 00592 // and have an empty action. However, for some strange reason, this does 00593 // not always work. 00594 // 00595 // As a workaround, we define the ECHO macro used by flex to be empty. 00596 // This seems to work fine. 00597 #define ECHO 00598 00599 /* 00600 These states are used by the scanner while parsing individual records 00601 in the metlogs. 00602 */ 00603 00604 /* 00605 Since this scanner will be used to parse multiple log files in 00606 parallel, we need it to be reentrant to ensure that it works properly 00607 in a multithreaded environment. 00608 */ 00609 /* 00610 The scanner is used to parse metrics logs stored on disk. It will 00611 never be used interactively by end users. 00612 */ 00613 /* 00614 The lobay program uses another lex-based scanner for tokenizing the 00615 config file. To ensure this one doesn't clash with that, we change the 00616 default function prefixes from "yy" to the following. 00617 */ 00618 /* 00619 Even though lex generates C code, this scanner is actually part of a 00620 C++ program. Therefore, we might as well have it generate the code in 00621 a file that the compiler and build system will readily recognize as 00622 C++. Furthermore, because of the way the INVT automatic dependency 00623 calculator works, we also need a corresponding header file that we can 00624 include in the client module's C++ source file to get the final link 00625 step to work properly. 00626 00627 DEVNOTE: The build takes place in the saliency root directory. 00628 Consequently, we must specify the full pathname relative to that 00629 directory to get flex to send the C source and header files to the 00630 proper location under the Robolocust root. If we were to use only the 00631 base file names, e.g., LoBaylogParser.C, the output would end up in 00632 the saliency root directory and would not be found by the other 00633 Robolocust modules that depend on this parser. 00634 */ 00635 /* 00636 For this parser to work properly, we need to be able to stack the 00637 start states. 00638 */ 00639 /* 00640 Instruct flex to suppress unnecessary functions so that we don't get 00641 any warnings (which can be show stoppers no thanks to INVT's use of 00642 -Werror in its build system). 00643 */ 00644 /*----------------------------- LEX RULES -----------------------------*/ 00645 #line 646 "src/Robots/LoBot/baylog/LoBaylogParser.C" 00646 00647 #define INITIAL 0 00648 #define LOBAY_PARSE_RECORD 1 00649 #define LOBAY_READ_NUMBER 2 00650 00651 #ifndef YY_NO_UNISTD_H 00652 /* Special case for "unistd.h", since it is non-ANSI. We include it way 00653 * down here because we want the user's section 1 to have been scanned first. 00654 * The user has a chance to override it with an option. 00655 */ 00656 #include <unistd.h> 00657 #endif 00658 00659 #ifndef YY_EXTRA_TYPE 00660 #define YY_EXTRA_TYPE void * 00661 #endif 00662 00663 /* Holds the entire state of the reentrant scanner. */ 00664 struct yyguts_t 00665 { 00666 00667 /* User-defined. Not touched by flex. */ 00668 YY_EXTRA_TYPE yyextra_r; 00669 00670 /* The rest are the same as the globals declared in the non-reentrant scanner. */ 00671 FILE *yyin_r, *yyout_r; 00672 size_t yy_buffer_stack_top; /**< index of top of stack. */ 00673 size_t yy_buffer_stack_max; /**< capacity of stack. */ 00674 YY_BUFFER_STATE * yy_buffer_stack; /**< Stack as an array. */ 00675 char yy_hold_char; 00676 int yy_n_chars; 00677 int yyleng_r; 00678 char *yy_c_buf_p; 00679 int yy_init; 00680 int yy_start; 00681 int yy_did_buffer_switch_on_eof; 00682 int yy_start_stack_ptr; 00683 int yy_start_stack_depth; 00684 int *yy_start_stack; 00685 yy_state_type yy_last_accepting_state; 00686 char* yy_last_accepting_cpos; 00687 00688 int yylineno_r; 00689 int yy_flex_debug_r; 00690 00691 char *yytext_r; 00692 int yy_more_flag; 00693 int yy_more_len; 00694 00695 }; /* end struct yyguts_t */ 00696 00697 static int yy_init_globals (yyscan_t yyscanner ); 00698 00699 /* Accessor methods to globals. 00700 These are made visible to non-reentrant scanners for convenience. */ 00701 00702 int lobay_parser_lex_destroy (yyscan_t yyscanner ); 00703 00704 int lobay_parser_get_debug (yyscan_t yyscanner ); 00705 00706 void lobay_parser_set_debug (int debug_flag ,yyscan_t yyscanner ); 00707 00708 YY_EXTRA_TYPE lobay_parser_get_extra (yyscan_t yyscanner ); 00709 00710 void lobay_parser_set_extra (YY_EXTRA_TYPE user_defined ,yyscan_t yyscanner ); 00711 00712 FILE *lobay_parser_get_in (yyscan_t yyscanner ); 00713 00714 void lobay_parser_set_in (FILE * in_str ,yyscan_t yyscanner ); 00715 00716 FILE *lobay_parser_get_out (yyscan_t yyscanner ); 00717 00718 void lobay_parser_set_out (FILE * out_str ,yyscan_t yyscanner ); 00719 00720 int lobay_parser_get_leng (yyscan_t yyscanner ); 00721 00722 char *lobay_parser_get_text (yyscan_t yyscanner ); 00723 00724 int lobay_parser_get_lineno (yyscan_t yyscanner ); 00725 00726 void lobay_parser_set_lineno (int line_number ,yyscan_t yyscanner ); 00727 00728 /* Macros after this point can all be overridden by user definitions in 00729 * section 1. 00730 */ 00731 00732 #ifndef YY_SKIP_YYWRAP 00733 #ifdef __cplusplus 00734 extern "C" int lobay_parser_wrap (yyscan_t yyscanner ); 00735 #else 00736 extern int lobay_parser_wrap (yyscan_t yyscanner ); 00737 #endif 00738 #endif 00739 00740 #ifndef yytext_ptr 00741 static void yy_flex_strncpy (char *,yyconst char *,int ,yyscan_t yyscanner); 00742 #endif 00743 00744 #ifdef YY_NEED_STRLEN 00745 static int yy_flex_strlen (yyconst char * ,yyscan_t yyscanner); 00746 #endif 00747 00748 #ifndef YY_NO_INPUT 00749 00750 #ifdef __cplusplus 00751 static int yyinput (yyscan_t yyscanner ); 00752 #else 00753 static int input (yyscan_t yyscanner ); 00754 #endif 00755 00756 #endif 00757 00758 static void yy_push_state (int new_state ,yyscan_t yyscanner); 00759 00760 static void yy_pop_state (yyscan_t yyscanner ); 00761 00762 /* Amount of stuff to slurp up with each read. */ 00763 #ifndef YY_READ_BUF_SIZE 00764 #define YY_READ_BUF_SIZE 8192 00765 #endif 00766 00767 /* Copy whatever the last rule matched to the standard output. */ 00768 #ifndef ECHO 00769 /* This used to be an fputs(), but since the string might contain NUL's, 00770 * we now use fwrite(). 00771 */ 00772 #define ECHO (void) fwrite( yytext, yyleng, 1, yyout ) 00773 #endif 00774 00775 /* Gets input and stuffs it into "buf". number of characters read, or YY_NULL, 00776 * is returned in "result". 00777 */ 00778 #ifndef YY_INPUT 00779 #define YY_INPUT(buf,result,max_size) \ 00780 if ( YY_CURRENT_BUFFER_LVALUE->yy_is_interactive ) \ 00781 { \ 00782 int c = '*'; \ 00783 size_t n; \ 00784 for ( n = 0; n < max_size && \ 00785 (c = getc( yyin )) != EOF && c != '\n'; ++n ) \ 00786 buf[n] = (char) c; \ 00787 if ( c == '\n' ) \ 00788 buf[n++] = (char) c; \ 00789 if ( c == EOF && ferror( yyin ) ) \ 00790 YY_FATAL_ERROR( "input in flex scanner failed" ); \ 00791 result = n; \ 00792 } \ 00793 else \ 00794 { \ 00795 errno=0; \ 00796 while ( (result = fread(buf, 1, max_size, yyin))==0 && ferror(yyin)) \ 00797 { \ 00798 if( errno != EINTR) \ 00799 { \ 00800 YY_FATAL_ERROR( "input in flex scanner failed" ); \ 00801 break; \ 00802 } \ 00803 errno=0; \ 00804 clearerr(yyin); \ 00805 } \ 00806 }\ 00807 \ 00808 00809 #endif 00810 00811 /* No semi-colon after return; correct usage is to write "yyterminate();" - 00812 * we don't want an extra ';' after the "return" because that will cause 00813 * some compilers to complain about unreachable statements. 00814 */ 00815 #ifndef yyterminate 00816 #define yyterminate() return YY_NULL 00817 #endif 00818 00819 /* Number of entries by which start-condition stack grows. */ 00820 #ifndef YY_START_STACK_INCR 00821 #define YY_START_STACK_INCR 25 00822 #endif 00823 00824 /* Report a fatal error. */ 00825 #ifndef YY_FATAL_ERROR 00826 #define YY_FATAL_ERROR(msg) yy_fatal_error( msg , yyscanner) 00827 #endif 00828 00829 /* end tables serialization structures and prototypes */ 00830 00831 /* Default declaration of generated scanner - a define so the user can 00832 * easily add parameters. 00833 */ 00834 #ifndef YY_DECL 00835 #define YY_DECL_IS_OURS 1 00836 00837 extern int lobay_parser_lex (yyscan_t yyscanner); 00838 00839 #define YY_DECL int lobay_parser_lex (yyscan_t yyscanner) 00840 #endif /* !YY_DECL */ 00841 00842 /* Code executed at the beginning of each rule, after yytext and yyleng 00843 * have been set up. 00844 */ 00845 #ifndef YY_USER_ACTION 00846 #define YY_USER_ACTION 00847 #endif 00848 00849 /* Code executed at the end of each rule. */ 00850 #ifndef YY_BREAK 00851 #define YY_BREAK break; 00852 #endif 00853 00854 #define YY_RULE_SETUP \ 00855 if ( yyleng > 0 ) \ 00856 YY_CURRENT_BUFFER_LVALUE->yy_at_bol = \ 00857 (yytext[yyleng - 1] == '\n'); \ 00858 YY_USER_ACTION 00859 00860 /** The main scanner function which does all the work. 00861 */ 00862 YY_DECL 00863 { 00864 register yy_state_type yy_current_state; 00865 register char *yy_cp, *yy_bp; 00866 register int yy_act; 00867 struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; 00868 00869 #line 145 "src/Robots/LoBot/baylog/LoBaylogParser.l" 00870 00871 00872 00873 // Each entry in a Bayesian time-to-impact prediction experiment's log 00874 // spans several lines with each line containing one piece of relevant 00875 // information. We are only interested in some of these pieces of 00876 // information. As we parse an entry, we store the differents pieces of 00877 // information in these local variables. Then, once the entire log entry 00878 // has been parsed, we will "send" the information stored in these locals 00879 // to the lobot::TTIMap object specified by lobot::BaylogAnalyzer. 00880 // 00881 // DEVNOTE: These variables are local to the lobay_parser_lex() function generated 00882 // by flex and are defined at the beginning of that function. 00883 float lobay_lgmd_spike_rate = 0, 00884 lobay_actual_tti = 0, 00885 lobay_predicted_tti = 0, 00886 lobay_confidence = 0; 00887 00888 // The informational lines making up a single log entry all follow the 00889 // same format, viz., an informational string followed by an equals sign 00890 // followed by a floating point number. 00891 // 00892 // To keep the parser's state machine simple, we use the following 00893 // pointer to keep track of which of the above variables should "receive" 00894 // the number in the informational line currently being parsed. 00895 float* lobay_target = 0 ; 00896 00897 00898 /* 00899 This rule recognizes the start of a multi-line log entry. Each such 00900 entry begins with a time-stamp (expressed as the number of 00901 milliseconds since the Unix epoch). After that comes an 00902 informational string spit out by the lgmd_extricate_tti behaviour. 00903 We don't really care much for this line except that it acts as a 00904 marker for the parser's internal state machine. 00905 */ 00906 #line 907 "src/Robots/LoBot/baylog/LoBaylogParser.C" 00907 00908 if ( !yyg->yy_init ) 00909 { 00910 yyg->yy_init = 1; 00911 00912 #ifdef YY_USER_INIT 00913 YY_USER_INIT; 00914 #endif 00915 00916 if ( ! yyg->yy_start ) 00917 yyg->yy_start = 1; /* first start state */ 00918 00919 if ( ! yyin ) 00920 yyin = stdin; 00921 00922 if ( ! yyout ) 00923 yyout = stdout; 00924 00925 if ( ! YY_CURRENT_BUFFER ) { 00926 lobay_parser_ensure_buffer_stack (yyscanner); 00927 YY_CURRENT_BUFFER_LVALUE = 00928 lobay_parser__create_buffer(yyin,YY_BUF_SIZE ,yyscanner); 00929 } 00930 00931 lobay_parser__load_buffer_state(yyscanner ); 00932 } 00933 00934 while ( 1 ) /* loops until end-of-file is reached */ 00935 { 00936 yy_cp = yyg->yy_c_buf_p; 00937 00938 /* Support of yytext. */ 00939 *yy_cp = yyg->yy_hold_char; 00940 00941 /* yy_bp points to the position in yy_ch_buf of the start of 00942 * the current run. 00943 */ 00944 yy_bp = yy_cp; 00945 00946 yy_current_state = yyg->yy_start; 00947 yy_current_state += YY_AT_BOL(); 00948 yy_match: 00949 do 00950 { 00951 register YY_CHAR yy_c = yy_ec[YY_SC_TO_UI(*yy_cp)]; 00952 if ( yy_accept[yy_current_state] ) 00953 { 00954 yyg->yy_last_accepting_state = yy_current_state; 00955 yyg->yy_last_accepting_cpos = yy_cp; 00956 } 00957 while ( yy_chk[yy_base[yy_current_state] + yy_c] != yy_current_state ) 00958 { 00959 yy_current_state = (int) yy_def[yy_current_state]; 00960 if ( yy_current_state >= 136 ) 00961 yy_c = yy_meta[(unsigned int) yy_c]; 00962 } 00963 yy_current_state = yy_nxt[yy_base[yy_current_state] + (unsigned int) yy_c]; 00964 ++yy_cp; 00965 } 00966 while ( yy_current_state != 135 ); 00967 yy_cp = yyg->yy_last_accepting_cpos; 00968 yy_current_state = yyg->yy_last_accepting_state; 00969 00970 yy_find_action: 00971 yy_act = yy_accept[yy_current_state]; 00972 00973 YY_DO_BEFORE_ACTION; 00974 00975 do_action: /* This label is used only to access EOF actions. */ 00976 00977 switch ( yy_act ) 00978 { /* beginning of action switch */ 00979 case 0: /* must back up */ 00980 /* undo the effects of YY_DO_BEFORE_ACTION */ 00981 *yy_cp = yyg->yy_hold_char; 00982 yy_cp = yyg->yy_last_accepting_cpos; 00983 yy_current_state = yyg->yy_last_accepting_state; 00984 goto yy_find_action; 00985 00986 case 1: 00987 YY_RULE_SETUP 00988 #line 181 "src/Robots/LoBot/baylog/LoBaylogParser.l" 00989 { 00990 BEGIN(LOBAY_PARSE_RECORD) ; 00991 } 00992 YY_BREAK 00993 /* 00994 These rules extract the numbers from the informational lines of a 00995 multi-line log entry and store them in the appropriate variable. 00996 */ 00997 case 2: 00998 YY_RULE_SETUP 00999 #line 189 "src/Robots/LoBot/baylog/LoBaylogParser.l" 01000 { 01001 lobay_target = &lobay_lgmd_spike_rate ; 01002 yy_push_state(LOBAY_READ_NUMBER, yyscanner) ; 01003 } 01004 YY_BREAK 01005 case 3: 01006 YY_RULE_SETUP 01007 #line 194 "src/Robots/LoBot/baylog/LoBaylogParser.l" 01008 { 01009 lobay_target = &lobay_actual_tti ; 01010 yy_push_state(LOBAY_READ_NUMBER, yyscanner) ; 01011 } 01012 YY_BREAK 01013 case 4: 01014 YY_RULE_SETUP 01015 #line 199 "src/Robots/LoBot/baylog/LoBaylogParser.l" 01016 { 01017 lobay_target = &lobay_predicted_tti ; 01018 yy_push_state(LOBAY_READ_NUMBER, yyscanner) ; 01019 } 01020 YY_BREAK 01021 case 5: 01022 YY_RULE_SETUP 01023 #line 204 "src/Robots/LoBot/baylog/LoBaylogParser.l" 01024 { 01025 lobay_target = &lobay_confidence ; 01026 yy_push_state(LOBAY_READ_NUMBER, yyscanner) ; 01027 } 01028 YY_BREAK 01029 /* 01030 This rule wraps up the parsing of a multi-line log entry and sends 01031 the information stored temporarily in the local variables to the 01032 lobot::TTIMap object being used to collect the various statistics 01033 of interest. 01034 */ 01035 case 6: 01036 /* rule 6 can match eol */ 01037 *yy_cp = yyg->yy_hold_char; /* undo effects of setting up yytext */ 01038 yyg->yy_c_buf_p = yy_cp -= 1; 01039 YY_DO_BEFORE_ACTION; /* set up yytext again */ 01040 YY_RULE_SETUP 01041 #line 215 "src/Robots/LoBot/baylog/LoBaylogParser.l" 01042 { 01043 yyextra->add(lobay_actual_tti, lobay_lgmd_spike_rate, 01044 lobay_predicted_tti, lobay_confidence) ; 01045 BEGIN(INITIAL) ; 01046 } 01047 YY_BREAK 01048 /* Ignore everything else when we are parsing a record... */ 01049 case 7: 01050 YY_RULE_SETUP 01051 #line 222 "src/Robots/LoBot/baylog/LoBaylogParser.l" 01052 {/* ignore */} 01053 YY_BREAK 01054 /* 01055 These rules will read a floating point number, store it in the 01056 current target variable, and then return to the previous state. 01057 */ 01058 case 8: 01059 YY_RULE_SETUP 01060 #line 228 "src/Robots/LoBot/baylog/LoBaylogParser.l" 01061 { 01062 *lobay_target = lobot::from_string<float>(yytext) ; 01063 yy_pop_state(yyscanner) ; 01064 } 01065 YY_BREAK 01066 case 9: 01067 YY_RULE_SETUP 01068 #line 233 "src/Robots/LoBot/baylog/LoBaylogParser.l" 01069 {/* ignore everything that doesn't look like a number */} 01070 YY_BREAK 01071 case 10: 01072 YY_RULE_SETUP 01073 #line 234 "src/Robots/LoBot/baylog/LoBaylogParser.l" 01074 ECHO; 01075 YY_BREAK 01076 #line 1077 "src/Robots/LoBot/baylog/LoBaylogParser.C" 01077 case YY_STATE_EOF(INITIAL): 01078 case YY_STATE_EOF(LOBAY_PARSE_RECORD): 01079 case YY_STATE_EOF(LOBAY_READ_NUMBER): 01080 yyterminate(); 01081 01082 case YY_END_OF_BUFFER: 01083 { 01084 /* Amount of text matched not including the EOB char. */ 01085 int yy_amount_of_matched_text = (int) (yy_cp - yyg->yytext_ptr) - 1; 01086 01087 /* Undo the effects of YY_DO_BEFORE_ACTION. */ 01088 *yy_cp = yyg->yy_hold_char; 01089 YY_RESTORE_YY_MORE_OFFSET 01090 01091 if ( YY_CURRENT_BUFFER_LVALUE->yy_buffer_status == YY_BUFFER_NEW ) 01092 { 01093 /* We're scanning a new file or input source. It's 01094 * possible that this happened because the user 01095 * just pointed yyin at a new source and called 01096 * lobay_parser_lex(). If so, then we have to assure 01097 * consistency between YY_CURRENT_BUFFER and our 01098 * globals. Here is the right place to do so, because 01099 * this is the first action (other than possibly a 01100 * back-up) that will match for the new input source. 01101 */ 01102 yyg->yy_n_chars = YY_CURRENT_BUFFER_LVALUE->yy_n_chars; 01103 YY_CURRENT_BUFFER_LVALUE->yy_input_file = yyin; 01104 YY_CURRENT_BUFFER_LVALUE->yy_buffer_status = YY_BUFFER_NORMAL; 01105 } 01106 01107 /* Note that here we test for yy_c_buf_p "<=" to the position 01108 * of the first EOB in the buffer, since yy_c_buf_p will 01109 * already have been incremented past the NUL character 01110 * (since all states make transitions on EOB to the 01111 * end-of-buffer state). Contrast this with the test 01112 * in input(). 01113 */ 01114 if ( yyg->yy_c_buf_p <= &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[yyg->yy_n_chars] ) 01115 { /* This was really a NUL. */ 01116 yy_state_type yy_next_state; 01117 01118 yyg->yy_c_buf_p = yyg->yytext_ptr + yy_amount_of_matched_text; 01119 01120 yy_current_state = yy_get_previous_state( yyscanner ); 01121 01122 /* Okay, we're now positioned to make the NUL 01123 * transition. We couldn't have 01124 * yy_get_previous_state() go ahead and do it 01125 * for us because it doesn't know how to deal 01126 * with the possibility of jamming (and we don't 01127 * want to build jamming into it because then it 01128 * will run more slowly). 01129 */ 01130 01131 yy_next_state = yy_try_NUL_trans( yy_current_state , yyscanner); 01132 01133 yy_bp = yyg->yytext_ptr + YY_MORE_ADJ; 01134 01135 if ( yy_next_state ) 01136 { 01137 /* Consume the NUL. */ 01138 yy_cp = ++yyg->yy_c_buf_p; 01139 yy_current_state = yy_next_state; 01140 goto yy_match; 01141 } 01142 01143 else 01144 { 01145 yy_cp = yyg->yy_last_accepting_cpos; 01146 yy_current_state = yyg->yy_last_accepting_state; 01147 goto yy_find_action; 01148 } 01149 } 01150 01151 else switch ( yy_get_next_buffer( yyscanner ) ) 01152 { 01153 case EOB_ACT_END_OF_FILE: 01154 { 01155 yyg->yy_did_buffer_switch_on_eof = 0; 01156 01157 if ( lobay_parser_wrap(yyscanner ) ) 01158 { 01159 /* Note: because we've taken care in 01160 * yy_get_next_buffer() to have set up 01161 * yytext, we can now set up 01162 * yy_c_buf_p so that if some total 01163 * hoser (like flex itself) wants to 01164 * call the scanner after we return the 01165 * YY_NULL, it'll still work - another 01166 * YY_NULL will get returned. 01167 */ 01168 yyg->yy_c_buf_p = yyg->yytext_ptr + YY_MORE_ADJ; 01169 01170 yy_act = YY_STATE_EOF(YY_START); 01171 goto do_action; 01172 } 01173 01174 else 01175 { 01176 if ( ! yyg->yy_did_buffer_switch_on_eof ) 01177 YY_NEW_FILE; 01178 } 01179 break; 01180 } 01181 01182 case EOB_ACT_CONTINUE_SCAN: 01183 yyg->yy_c_buf_p = 01184 yyg->yytext_ptr + yy_amount_of_matched_text; 01185 01186 yy_current_state = yy_get_previous_state( yyscanner ); 01187 01188 yy_cp = yyg->yy_c_buf_p; 01189 yy_bp = yyg->yytext_ptr + YY_MORE_ADJ; 01190 goto yy_match; 01191 01192 case EOB_ACT_LAST_MATCH: 01193 yyg->yy_c_buf_p = 01194 &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[yyg->yy_n_chars]; 01195 01196 yy_current_state = yy_get_previous_state( yyscanner ); 01197 01198 yy_cp = yyg->yy_c_buf_p; 01199 yy_bp = yyg->yytext_ptr + YY_MORE_ADJ; 01200 goto yy_find_action; 01201 } 01202 break; 01203 } 01204 01205 default: 01206 YY_FATAL_ERROR( 01207 "fatal flex scanner internal error--no action found" ); 01208 } /* end of action switch */ 01209 } /* end of scanning one token */ 01210 } /* end of lobay_parser_lex */ 01211 01212 /* yy_get_next_buffer - try to read in a new buffer 01213 * 01214 * Returns a code representing an action: 01215 * EOB_ACT_LAST_MATCH - 01216 * EOB_ACT_CONTINUE_SCAN - continue scanning from current position 01217 * EOB_ACT_END_OF_FILE - end of file 01218 */ 01219 static int yy_get_next_buffer (yyscan_t yyscanner) 01220 { 01221 struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; 01222 register char *dest = YY_CURRENT_BUFFER_LVALUE->yy_ch_buf; 01223 register char *source = yyg->yytext_ptr; 01224 register int number_to_move, i; 01225 int ret_val; 01226 01227 if ( yyg->yy_c_buf_p > &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[yyg->yy_n_chars + 1] ) 01228 YY_FATAL_ERROR( 01229 "fatal flex scanner internal error--end of buffer missed" ); 01230 01231 if ( YY_CURRENT_BUFFER_LVALUE->yy_fill_buffer == 0 ) 01232 { /* Don't try to fill the buffer, so this is an EOF. */ 01233 if ( yyg->yy_c_buf_p - yyg->yytext_ptr - YY_MORE_ADJ == 1 ) 01234 { 01235 /* We matched a single character, the EOB, so 01236 * treat this as a final EOF. 01237 */ 01238 return EOB_ACT_END_OF_FILE; 01239 } 01240 01241 else 01242 { 01243 /* We matched some text prior to the EOB, first 01244 * process it. 01245 */ 01246 return EOB_ACT_LAST_MATCH; 01247 } 01248 } 01249 01250 /* Try to read more data. */ 01251 01252 /* First move last chars to start of buffer. */ 01253 number_to_move = (int) (yyg->yy_c_buf_p - yyg->yytext_ptr) - 1; 01254 01255 for ( i = 0; i < number_to_move; ++i ) 01256 *(dest++) = *(source++); 01257 01258 if ( YY_CURRENT_BUFFER_LVALUE->yy_buffer_status == YY_BUFFER_EOF_PENDING ) 01259 /* don't do the read, it's not guaranteed to return an EOF, 01260 * just force an EOF 01261 */ 01262 YY_CURRENT_BUFFER_LVALUE->yy_n_chars = yyg->yy_n_chars = 0; 01263 01264 else 01265 { 01266 int num_to_read = 01267 YY_CURRENT_BUFFER_LVALUE->yy_buf_size - number_to_move - 1; 01268 01269 while ( num_to_read <= 0 ) 01270 { /* Not enough room in the buffer - grow it. */ 01271 01272 /* just a shorter name for the current buffer */ 01273 YY_BUFFER_STATE b = YY_CURRENT_BUFFER; 01274 01275 int yy_c_buf_p_offset = 01276 (int) (yyg->yy_c_buf_p - b->yy_ch_buf); 01277 01278 if ( b->yy_is_our_buffer ) 01279 { 01280 int new_size = b->yy_buf_size * 2; 01281 01282 if ( new_size <= 0 ) 01283 b->yy_buf_size += b->yy_buf_size / 8; 01284 else 01285 b->yy_buf_size *= 2; 01286 01287 b->yy_ch_buf = (char *) 01288 /* Include room in for 2 EOB chars. */ 01289 lobay_parser_realloc((void *) b->yy_ch_buf,b->yy_buf_size + 2 ,yyscanner ); 01290 } 01291 else 01292 /* Can't grow it, we don't own it. */ 01293 b->yy_ch_buf = 0; 01294 01295 if ( ! b->yy_ch_buf ) 01296 YY_FATAL_ERROR( 01297 "fatal error - scanner input buffer overflow" ); 01298 01299 yyg->yy_c_buf_p = &b->yy_ch_buf[yy_c_buf_p_offset]; 01300 01301 num_to_read = YY_CURRENT_BUFFER_LVALUE->yy_buf_size - 01302 number_to_move - 1; 01303 01304 } 01305 01306 if ( num_to_read > YY_READ_BUF_SIZE ) 01307 num_to_read = YY_READ_BUF_SIZE; 01308 01309 /* Read in more data. */ 01310 YY_INPUT( (&YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[number_to_move]), 01311 yyg->yy_n_chars, (size_t) num_to_read ); 01312 01313 YY_CURRENT_BUFFER_LVALUE->yy_n_chars = yyg->yy_n_chars; 01314 } 01315 01316 if ( yyg->yy_n_chars == 0 ) 01317 { 01318 if ( number_to_move == YY_MORE_ADJ ) 01319 { 01320 ret_val = EOB_ACT_END_OF_FILE; 01321 lobay_parser_restart(yyin ,yyscanner); 01322 } 01323 01324 else 01325 { 01326 ret_val = EOB_ACT_LAST_MATCH; 01327 YY_CURRENT_BUFFER_LVALUE->yy_buffer_status = 01328 YY_BUFFER_EOF_PENDING; 01329 } 01330 } 01331 01332 else 01333 ret_val = EOB_ACT_CONTINUE_SCAN; 01334 01335 yyg->yy_n_chars += number_to_move; 01336 YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[yyg->yy_n_chars] = YY_END_OF_BUFFER_CHAR; 01337 YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[yyg->yy_n_chars + 1] = YY_END_OF_BUFFER_CHAR; 01338 01339 yyg->yytext_ptr = &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[0]; 01340 01341 return ret_val; 01342 } 01343 01344 /* yy_get_previous_state - get the state just before the EOB char was reached */ 01345 01346 static yy_state_type yy_get_previous_state (yyscan_t yyscanner) 01347 { 01348 register yy_state_type yy_current_state; 01349 register char *yy_cp; 01350 struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; 01351 01352 yy_current_state = yyg->yy_start; 01353 yy_current_state += YY_AT_BOL(); 01354 01355 for ( yy_cp = yyg->yytext_ptr + YY_MORE_ADJ; yy_cp < yyg->yy_c_buf_p; ++yy_cp ) 01356 { 01357 register YY_CHAR yy_c = (*yy_cp ? yy_ec[YY_SC_TO_UI(*yy_cp)] : 1); 01358 if ( yy_accept[yy_current_state] ) 01359 { 01360 yyg->yy_last_accepting_state = yy_current_state; 01361 yyg->yy_last_accepting_cpos = yy_cp; 01362 } 01363 while ( yy_chk[yy_base[yy_current_state] + yy_c] != yy_current_state ) 01364 { 01365 yy_current_state = (int) yy_def[yy_current_state]; 01366 if ( yy_current_state >= 136 ) 01367 yy_c = yy_meta[(unsigned int) yy_c]; 01368 } 01369 yy_current_state = yy_nxt[yy_base[yy_current_state] + (unsigned int) yy_c]; 01370 } 01371 01372 return yy_current_state; 01373 } 01374 01375 /* yy_try_NUL_trans - try to make a transition on the NUL character 01376 * 01377 * synopsis 01378 * next_state = yy_try_NUL_trans( current_state ); 01379 */ 01380 static yy_state_type yy_try_NUL_trans (yy_state_type yy_current_state , yyscan_t yyscanner) 01381 { 01382 register int yy_is_jam; 01383 struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; /* This var may be unused depending upon options. */ 01384 register char *yy_cp = yyg->yy_c_buf_p; 01385 01386 register YY_CHAR yy_c = 1; 01387 if ( yy_accept[yy_current_state] ) 01388 { 01389 yyg->yy_last_accepting_state = yy_current_state; 01390 yyg->yy_last_accepting_cpos = yy_cp; 01391 } 01392 while ( yy_chk[yy_base[yy_current_state] + yy_c] != yy_current_state ) 01393 { 01394 yy_current_state = (int) yy_def[yy_current_state]; 01395 if ( yy_current_state >= 136 ) 01396 yy_c = yy_meta[(unsigned int) yy_c]; 01397 } 01398 yy_current_state = yy_nxt[yy_base[yy_current_state] + (unsigned int) yy_c]; 01399 yy_is_jam = (yy_current_state == 135); 01400 01401 return yy_is_jam ? 0 : yy_current_state; 01402 } 01403 01404 #ifndef YY_NO_INPUT 01405 #ifdef __cplusplus 01406 static int yyinput (yyscan_t yyscanner) 01407 #else 01408 static int input (yyscan_t yyscanner) 01409 #endif 01410 01411 { 01412 int c; 01413 struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; 01414 01415 *yyg->yy_c_buf_p = yyg->yy_hold_char; 01416 01417 if ( *yyg->yy_c_buf_p == YY_END_OF_BUFFER_CHAR ) 01418 { 01419 /* yy_c_buf_p now points to the character we want to return. 01420 * If this occurs *before* the EOB characters, then it's a 01421 * valid NUL; if not, then we've hit the end of the buffer. 01422 */ 01423 if ( yyg->yy_c_buf_p < &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[yyg->yy_n_chars] ) 01424 /* This was really a NUL. */ 01425 *yyg->yy_c_buf_p = '\0'; 01426 01427 else 01428 { /* need more input */ 01429 int offset = yyg->yy_c_buf_p - yyg->yytext_ptr; 01430 ++yyg->yy_c_buf_p; 01431 01432 switch ( yy_get_next_buffer( yyscanner ) ) 01433 { 01434 case EOB_ACT_LAST_MATCH: 01435 /* This happens because yy_g_n_b() 01436 * sees that we've accumulated a 01437 * token and flags that we need to 01438 * try matching the token before 01439 * proceeding. But for input(), 01440 * there's no matching to consider. 01441 * So convert the EOB_ACT_LAST_MATCH 01442 * to EOB_ACT_END_OF_FILE. 01443 */ 01444 01445 /* Reset buffer status. */ 01446 lobay_parser_restart(yyin ,yyscanner); 01447 01448 /*FALLTHROUGH*/ 01449 01450 case EOB_ACT_END_OF_FILE: 01451 { 01452 if ( lobay_parser_wrap(yyscanner ) ) 01453 return EOF; 01454 01455 if ( ! yyg->yy_did_buffer_switch_on_eof ) 01456 YY_NEW_FILE; 01457 #ifdef __cplusplus 01458 return yyinput(yyscanner); 01459 #else 01460 return input(yyscanner); 01461 #endif 01462 } 01463 01464 case EOB_ACT_CONTINUE_SCAN: 01465 yyg->yy_c_buf_p = yyg->yytext_ptr + offset; 01466 break; 01467 } 01468 } 01469 } 01470 01471 c = *(unsigned char *) yyg->yy_c_buf_p; /* cast for 8-bit char's */ 01472 *yyg->yy_c_buf_p = '\0'; /* preserve yytext */ 01473 yyg->yy_hold_char = *++yyg->yy_c_buf_p; 01474 01475 YY_CURRENT_BUFFER_LVALUE->yy_at_bol = (c == '\n'); 01476 01477 return c; 01478 } 01479 #endif /* ifndef YY_NO_INPUT */ 01480 01481 /** Immediately switch to a different input stream. 01482 * @param input_file A readable stream. 01483 * @param yyscanner The scanner object. 01484 * @note This function does not reset the start condition to @c INITIAL . 01485 */ 01486 void lobay_parser_restart (FILE * input_file , yyscan_t yyscanner) 01487 { 01488 struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; 01489 01490 if ( ! YY_CURRENT_BUFFER ){ 01491 lobay_parser_ensure_buffer_stack (yyscanner); 01492 YY_CURRENT_BUFFER_LVALUE = 01493 lobay_parser__create_buffer(yyin,YY_BUF_SIZE ,yyscanner); 01494 } 01495 01496 lobay_parser__init_buffer(YY_CURRENT_BUFFER,input_file ,yyscanner); 01497 lobay_parser__load_buffer_state(yyscanner ); 01498 } 01499 01500 /** Switch to a different input buffer. 01501 * @param new_buffer The new input buffer. 01502 * @param yyscanner The scanner object. 01503 */ 01504 void lobay_parser__switch_to_buffer (YY_BUFFER_STATE new_buffer , yyscan_t yyscanner) 01505 { 01506 struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; 01507 01508 /* TODO. We should be able to replace this entire function body 01509 * with 01510 * lobay_parser_pop_buffer_state(); 01511 * lobay_parser_push_buffer_state(new_buffer); 01512 */ 01513 lobay_parser_ensure_buffer_stack (yyscanner); 01514 if ( YY_CURRENT_BUFFER == new_buffer ) 01515 return; 01516 01517 if ( YY_CURRENT_BUFFER ) 01518 { 01519 /* Flush out information for old buffer. */ 01520 *yyg->yy_c_buf_p = yyg->yy_hold_char; 01521 YY_CURRENT_BUFFER_LVALUE->yy_buf_pos = yyg->yy_c_buf_p; 01522 YY_CURRENT_BUFFER_LVALUE->yy_n_chars = yyg->yy_n_chars; 01523 } 01524 01525 YY_CURRENT_BUFFER_LVALUE = new_buffer; 01526 lobay_parser__load_buffer_state(yyscanner ); 01527 01528 /* We don't actually know whether we did this switch during 01529 * EOF (lobay_parser_wrap()) processing, but the only time this flag 01530 * is looked at is after lobay_parser_wrap() is called, so it's safe 01531 * to go ahead and always set it. 01532 */ 01533 yyg->yy_did_buffer_switch_on_eof = 1; 01534 } 01535 01536 static void lobay_parser__load_buffer_state (yyscan_t yyscanner) 01537 { 01538 struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; 01539 yyg->yy_n_chars = YY_CURRENT_BUFFER_LVALUE->yy_n_chars; 01540 yyg->yytext_ptr = yyg->yy_c_buf_p = YY_CURRENT_BUFFER_LVALUE->yy_buf_pos; 01541 yyin = YY_CURRENT_BUFFER_LVALUE->yy_input_file; 01542 yyg->yy_hold_char = *yyg->yy_c_buf_p; 01543 } 01544 01545 /** Allocate and initialize an input buffer state. 01546 * @param file A readable stream. 01547 * @param size The character buffer size in bytes. When in doubt, use @c YY_BUF_SIZE. 01548 * @param yyscanner The scanner object. 01549 * @return the allocated buffer state. 01550 */ 01551 YY_BUFFER_STATE lobay_parser__create_buffer (FILE * file, int size , yyscan_t yyscanner) 01552 { 01553 YY_BUFFER_STATE b; 01554 01555 b = (YY_BUFFER_STATE) lobay_parser_alloc(sizeof( struct yy_buffer_state ) ,yyscanner ); 01556 if ( ! b ) 01557 YY_FATAL_ERROR( "out of dynamic memory in lobay_parser__create_buffer()" ); 01558 01559 b->yy_buf_size = size; 01560 01561 /* yy_ch_buf has to be 2 characters longer than the size given because 01562 * we need to put in 2 end-of-buffer characters. 01563 */ 01564 b->yy_ch_buf = (char *) lobay_parser_alloc(b->yy_buf_size + 2 ,yyscanner ); 01565 if ( ! b->yy_ch_buf ) 01566 YY_FATAL_ERROR( "out of dynamic memory in lobay_parser__create_buffer()" ); 01567 01568 b->yy_is_our_buffer = 1; 01569 01570 lobay_parser__init_buffer(b,file ,yyscanner); 01571 01572 return b; 01573 } 01574 01575 /** Destroy the buffer. 01576 * @param b a buffer created with lobay_parser__create_buffer() 01577 * @param yyscanner The scanner object. 01578 */ 01579 void lobay_parser__delete_buffer (YY_BUFFER_STATE b , yyscan_t yyscanner) 01580 { 01581 struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; 01582 01583 if ( ! b ) 01584 return; 01585 01586 if ( b == YY_CURRENT_BUFFER ) /* Not sure if we should pop here. */ 01587 YY_CURRENT_BUFFER_LVALUE = (YY_BUFFER_STATE) 0; 01588 01589 if ( b->yy_is_our_buffer ) 01590 lobay_parser_free((void *) b->yy_ch_buf ,yyscanner ); 01591 01592 lobay_parser_free((void *) b ,yyscanner ); 01593 } 01594 01595 /* Initializes or reinitializes a buffer. 01596 * This function is sometimes called more than once on the same buffer, 01597 * such as during a lobay_parser_restart() or at EOF. 01598 */ 01599 static void lobay_parser__init_buffer (YY_BUFFER_STATE b, FILE * file , yyscan_t yyscanner) 01600 01601 { 01602 int oerrno = errno; 01603 struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; 01604 01605 lobay_parser__flush_buffer(b ,yyscanner); 01606 01607 b->yy_input_file = file; 01608 b->yy_fill_buffer = 1; 01609 01610 /* If b is the current buffer, then lobay_parser__init_buffer was _probably_ 01611 * called from lobay_parser_restart() or through yy_get_next_buffer. 01612 * In that case, we don't want to reset the lineno or column. 01613 */ 01614 if (b != YY_CURRENT_BUFFER){ 01615 b->yy_bs_lineno = 1; 01616 b->yy_bs_column = 0; 01617 } 01618 01619 b->yy_is_interactive = 0; 01620 01621 errno = oerrno; 01622 } 01623 01624 /** Discard all buffered characters. On the next scan, YY_INPUT will be called. 01625 * @param b the buffer state to be flushed, usually @c YY_CURRENT_BUFFER. 01626 * @param yyscanner The scanner object. 01627 */ 01628 void lobay_parser__flush_buffer (YY_BUFFER_STATE b , yyscan_t yyscanner) 01629 { 01630 struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; 01631 if ( ! b ) 01632 return; 01633 01634 b->yy_n_chars = 0; 01635 01636 /* We always need two end-of-buffer characters. The first causes 01637 * a transition to the end-of-buffer state. The second causes 01638 * a jam in that state. 01639 */ 01640 b->yy_ch_buf[0] = YY_END_OF_BUFFER_CHAR; 01641 b->yy_ch_buf[1] = YY_END_OF_BUFFER_CHAR; 01642 01643 b->yy_buf_pos = &b->yy_ch_buf[0]; 01644 01645 b->yy_at_bol = 1; 01646 b->yy_buffer_status = YY_BUFFER_NEW; 01647 01648 if ( b == YY_CURRENT_BUFFER ) 01649 lobay_parser__load_buffer_state(yyscanner ); 01650 } 01651 01652 /** Pushes the new state onto the stack. The new state becomes 01653 * the current state. This function will allocate the stack 01654 * if necessary. 01655 * @param new_buffer The new state. 01656 * @param yyscanner The scanner object. 01657 */ 01658 void lobay_parser_push_buffer_state (YY_BUFFER_STATE new_buffer , yyscan_t yyscanner) 01659 { 01660 struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; 01661 if (new_buffer == NULL) 01662 return; 01663 01664 lobay_parser_ensure_buffer_stack(yyscanner); 01665 01666 /* This block is copied from lobay_parser__switch_to_buffer. */ 01667 if ( YY_CURRENT_BUFFER ) 01668 { 01669 /* Flush out information for old buffer. */ 01670 *yyg->yy_c_buf_p = yyg->yy_hold_char; 01671 YY_CURRENT_BUFFER_LVALUE->yy_buf_pos = yyg->yy_c_buf_p; 01672 YY_CURRENT_BUFFER_LVALUE->yy_n_chars = yyg->yy_n_chars; 01673 } 01674 01675 /* Only push if top exists. Otherwise, replace top. */ 01676 if (YY_CURRENT_BUFFER) 01677 yyg->yy_buffer_stack_top++; 01678 YY_CURRENT_BUFFER_LVALUE = new_buffer; 01679 01680 /* copied from lobay_parser__switch_to_buffer. */ 01681 lobay_parser__load_buffer_state(yyscanner ); 01682 yyg->yy_did_buffer_switch_on_eof = 1; 01683 } 01684 01685 /** Removes and deletes the top of the stack, if present. 01686 * The next element becomes the new top. 01687 * @param yyscanner The scanner object. 01688 */ 01689 void lobay_parser_pop_buffer_state (yyscan_t yyscanner) 01690 { 01691 struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; 01692 if (!YY_CURRENT_BUFFER) 01693 return; 01694 01695 lobay_parser__delete_buffer(YY_CURRENT_BUFFER ,yyscanner); 01696 YY_CURRENT_BUFFER_LVALUE = NULL; 01697 if (yyg->yy_buffer_stack_top > 0) 01698 --yyg->yy_buffer_stack_top; 01699 01700 if (YY_CURRENT_BUFFER) { 01701 lobay_parser__load_buffer_state(yyscanner ); 01702 yyg->yy_did_buffer_switch_on_eof = 1; 01703 } 01704 } 01705 01706 /* Allocates the stack if it does not exist. 01707 * Guarantees space for at least one push. 01708 */ 01709 static void lobay_parser_ensure_buffer_stack (yyscan_t yyscanner) 01710 { 01711 int num_to_alloc; 01712 struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; 01713 01714 if (!yyg->yy_buffer_stack) { 01715 01716 /* First allocation is just for 2 elements, since we don't know if this 01717 * scanner will even need a stack. We use 2 instead of 1 to avoid an 01718 * immediate realloc on the next call. 01719 */ 01720 num_to_alloc = 1; 01721 yyg->yy_buffer_stack = (struct yy_buffer_state**)lobay_parser_alloc 01722 (num_to_alloc * sizeof(struct yy_buffer_state*) 01723 , yyscanner); 01724 01725 memset(yyg->yy_buffer_stack, 0, num_to_alloc * sizeof(struct yy_buffer_state*)); 01726 01727 yyg->yy_buffer_stack_max = num_to_alloc; 01728 yyg->yy_buffer_stack_top = 0; 01729 return; 01730 } 01731 01732 if (yyg->yy_buffer_stack_top >= (yyg->yy_buffer_stack_max) - 1){ 01733 01734 /* Increase the buffer to prepare for a possible push. */ 01735 int grow_size = 8 /* arbitrary grow size */; 01736 01737 num_to_alloc = yyg->yy_buffer_stack_max + grow_size; 01738 yyg->yy_buffer_stack = (struct yy_buffer_state**)lobay_parser_realloc 01739 (yyg->yy_buffer_stack, 01740 num_to_alloc * sizeof(struct yy_buffer_state*) 01741 , yyscanner); 01742 01743 /* zero only the new slots.*/ 01744 memset(yyg->yy_buffer_stack + yyg->yy_buffer_stack_max, 0, grow_size * sizeof(struct yy_buffer_state*)); 01745 yyg->yy_buffer_stack_max = num_to_alloc; 01746 } 01747 } 01748 01749 /** Setup the input buffer state to scan directly from a user-specified character buffer. 01750 * @param base the character buffer 01751 * @param size the size in bytes of the character buffer 01752 * @param yyscanner The scanner object. 01753 * @return the newly allocated buffer state object. 01754 */ 01755 YY_BUFFER_STATE lobay_parser__scan_buffer (char * base, yy_size_t size , yyscan_t yyscanner) 01756 { 01757 YY_BUFFER_STATE b; 01758 01759 if ( size < 2 || 01760 base[size-2] != YY_END_OF_BUFFER_CHAR || 01761 base[size-1] != YY_END_OF_BUFFER_CHAR ) 01762 /* They forgot to leave room for the EOB's. */ 01763 return 0; 01764 01765 b = (YY_BUFFER_STATE) lobay_parser_alloc(sizeof( struct yy_buffer_state ) ,yyscanner ); 01766 if ( ! b ) 01767 YY_FATAL_ERROR( "out of dynamic memory in lobay_parser__scan_buffer()" ); 01768 01769 b->yy_buf_size = size - 2; /* "- 2" to take care of EOB's */ 01770 b->yy_buf_pos = b->yy_ch_buf = base; 01771 b->yy_is_our_buffer = 0; 01772 b->yy_input_file = 0; 01773 b->yy_n_chars = b->yy_buf_size; 01774 b->yy_is_interactive = 0; 01775 b->yy_at_bol = 1; 01776 b->yy_fill_buffer = 0; 01777 b->yy_buffer_status = YY_BUFFER_NEW; 01778 01779 lobay_parser__switch_to_buffer(b ,yyscanner ); 01780 01781 return b; 01782 } 01783 01784 /** Setup the input buffer state to scan a string. The next call to lobay_parser_lex() will 01785 * scan from a @e copy of @a str. 01786 * @param yystr a NUL-terminated string to scan 01787 * @param yyscanner The scanner object. 01788 * @return the newly allocated buffer state object. 01789 * @note If you want to scan bytes that may contain NUL values, then use 01790 * lobay_parser__scan_bytes() instead. 01791 */ 01792 YY_BUFFER_STATE lobay_parser__scan_string (yyconst char * yystr , yyscan_t yyscanner) 01793 { 01794 01795 return lobay_parser__scan_bytes(yystr,strlen(yystr) ,yyscanner); 01796 } 01797 01798 /** Setup the input buffer state to scan the given bytes. The next call to lobay_parser_lex() will 01799 * scan from a @e copy of @a bytes. 01800 * @param bytes the byte buffer to scan 01801 * @param len the number of bytes in the buffer pointed to by @a bytes. 01802 * @param yyscanner The scanner object. 01803 * @return the newly allocated buffer state object. 01804 */ 01805 YY_BUFFER_STATE lobay_parser__scan_bytes (yyconst char * yybytes, int _yybytes_len , yyscan_t yyscanner) 01806 { 01807 YY_BUFFER_STATE b; 01808 char *buf; 01809 yy_size_t n; 01810 int i; 01811 01812 /* Get memory for full buffer, including space for trailing EOB's. */ 01813 n = _yybytes_len + 2; 01814 buf = (char *) lobay_parser_alloc(n ,yyscanner ); 01815 if ( ! buf ) 01816 YY_FATAL_ERROR( "out of dynamic memory in lobay_parser__scan_bytes()" ); 01817 01818 for ( i = 0; i < _yybytes_len; ++i ) 01819 buf[i] = yybytes[i]; 01820 01821 buf[_yybytes_len] = buf[_yybytes_len+1] = YY_END_OF_BUFFER_CHAR; 01822 01823 b = lobay_parser__scan_buffer(buf,n ,yyscanner); 01824 if ( ! b ) 01825 YY_FATAL_ERROR( "bad buffer in lobay_parser__scan_bytes()" ); 01826 01827 /* It's okay to grow etc. this buffer, and we should throw it 01828 * away when we're done. 01829 */ 01830 b->yy_is_our_buffer = 1; 01831 01832 return b; 01833 } 01834 01835 static void yy_push_state (int new_state , yyscan_t yyscanner) 01836 { 01837 struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; 01838 if ( yyg->yy_start_stack_ptr >= yyg->yy_start_stack_depth ) 01839 { 01840 yy_size_t new_size; 01841 01842 yyg->yy_start_stack_depth += YY_START_STACK_INCR; 01843 new_size = yyg->yy_start_stack_depth * sizeof( int ); 01844 01845 if ( ! yyg->yy_start_stack ) 01846 yyg->yy_start_stack = (int *) lobay_parser_alloc(new_size ,yyscanner ); 01847 01848 else 01849 yyg->yy_start_stack = (int *) lobay_parser_realloc((void *) yyg->yy_start_stack,new_size ,yyscanner ); 01850 01851 if ( ! yyg->yy_start_stack ) 01852 YY_FATAL_ERROR( 01853 "out of memory expanding start-condition stack" ); 01854 } 01855 01856 yyg->yy_start_stack[yyg->yy_start_stack_ptr++] = YY_START; 01857 01858 BEGIN(new_state); 01859 } 01860 01861 static void yy_pop_state (yyscan_t yyscanner) 01862 { 01863 struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; 01864 if ( --yyg->yy_start_stack_ptr < 0 ) 01865 YY_FATAL_ERROR( "start-condition stack underflow" ); 01866 01867 BEGIN(yyg->yy_start_stack[yyg->yy_start_stack_ptr]); 01868 } 01869 01870 #ifndef YY_EXIT_FAILURE 01871 #define YY_EXIT_FAILURE 2 01872 #endif 01873 01874 static void yy_fatal_error (yyconst char* msg , yyscan_t yyscanner) 01875 { 01876 (void) fprintf( stderr, "%s\n", msg ); 01877 exit( YY_EXIT_FAILURE ); 01878 } 01879 01880 /* Redefine yyless() so it works in section 3 code. */ 01881 01882 #undef yyless 01883 #define yyless(n) \ 01884 do \ 01885 { \ 01886 /* Undo effects of setting up yytext. */ \ 01887 int yyless_macro_arg = (n); \ 01888 YY_LESS_LINENO(yyless_macro_arg);\ 01889 yytext[yyleng] = yyg->yy_hold_char; \ 01890 yyg->yy_c_buf_p = yytext + yyless_macro_arg; \ 01891 yyg->yy_hold_char = *yyg->yy_c_buf_p; \ 01892 *yyg->yy_c_buf_p = '\0'; \ 01893 yyleng = yyless_macro_arg; \ 01894 } \ 01895 while ( 0 ) 01896 01897 /* Accessor methods (get/set functions) to struct members. */ 01898 01899 /** Get the user-defined data for this scanner. 01900 * @param yyscanner The scanner object. 01901 */ 01902 YY_EXTRA_TYPE lobay_parser_get_extra (yyscan_t yyscanner) 01903 { 01904 struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; 01905 return yyextra; 01906 } 01907 01908 /** Get the current line number. 01909 * @param yyscanner The scanner object. 01910 */ 01911 int lobay_parser_get_lineno (yyscan_t yyscanner) 01912 { 01913 struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; 01914 01915 if (! YY_CURRENT_BUFFER) 01916 return 0; 01917 01918 return yylineno; 01919 } 01920 01921 /** Get the current column number. 01922 * @param yyscanner The scanner object. 01923 */ 01924 int lobay_parser_get_column (yyscan_t yyscanner) 01925 { 01926 struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; 01927 01928 if (! YY_CURRENT_BUFFER) 01929 return 0; 01930 01931 return yycolumn; 01932 } 01933 01934 /** Get the input stream. 01935 * @param yyscanner The scanner object. 01936 */ 01937 FILE *lobay_parser_get_in (yyscan_t yyscanner) 01938 { 01939 struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; 01940 return yyin; 01941 } 01942 01943 /** Get the output stream. 01944 * @param yyscanner The scanner object. 01945 */ 01946 FILE *lobay_parser_get_out (yyscan_t yyscanner) 01947 { 01948 struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; 01949 return yyout; 01950 } 01951 01952 /** Get the length of the current token. 01953 * @param yyscanner The scanner object. 01954 */ 01955 int lobay_parser_get_leng (yyscan_t yyscanner) 01956 { 01957 struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; 01958 return yyleng; 01959 } 01960 01961 /** Get the current token. 01962 * @param yyscanner The scanner object. 01963 */ 01964 01965 char *lobay_parser_get_text (yyscan_t yyscanner) 01966 { 01967 struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; 01968 return yytext; 01969 } 01970 01971 /** Set the user-defined data. This data is never touched by the scanner. 01972 * @param user_defined The data to be associated with this scanner. 01973 * @param yyscanner The scanner object. 01974 */ 01975 void lobay_parser_set_extra (YY_EXTRA_TYPE user_defined , yyscan_t yyscanner) 01976 { 01977 struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; 01978 yyextra = user_defined ; 01979 } 01980 01981 /** Set the current line number. 01982 * @param line_number 01983 * @param yyscanner The scanner object. 01984 */ 01985 void lobay_parser_set_lineno (int line_number , yyscan_t yyscanner) 01986 { 01987 struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; 01988 01989 /* lineno is only valid if an input buffer exists. */ 01990 if (! YY_CURRENT_BUFFER ) 01991 yy_fatal_error( "lobay_parser_set_lineno called with no buffer" , yyscanner); 01992 01993 yylineno = line_number; 01994 } 01995 01996 /** Set the current column. 01997 * @param line_number 01998 * @param yyscanner The scanner object. 01999 */ 02000 void lobay_parser_set_column (int column_no , yyscan_t yyscanner) 02001 { 02002 struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; 02003 02004 /* column is only valid if an input buffer exists. */ 02005 if (! YY_CURRENT_BUFFER ) 02006 yy_fatal_error( "lobay_parser_set_column called with no buffer" , yyscanner); 02007 02008 yycolumn = column_no; 02009 } 02010 02011 /** Set the input stream. This does not discard the current 02012 * input buffer. 02013 * @param in_str A readable stream. 02014 * @param yyscanner The scanner object. 02015 * @see lobay_parser__switch_to_buffer 02016 */ 02017 void lobay_parser_set_in (FILE * in_str , yyscan_t yyscanner) 02018 { 02019 struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; 02020 yyin = in_str ; 02021 } 02022 02023 void lobay_parser_set_out (FILE * out_str , yyscan_t yyscanner) 02024 { 02025 struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; 02026 yyout = out_str ; 02027 } 02028 02029 int lobay_parser_get_debug (yyscan_t yyscanner) 02030 { 02031 struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; 02032 return yy_flex_debug; 02033 } 02034 02035 void lobay_parser_set_debug (int bdebug , yyscan_t yyscanner) 02036 { 02037 struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; 02038 yy_flex_debug = bdebug ; 02039 } 02040 02041 /* Accessor methods for yylval and yylloc */ 02042 02043 /* User-visible API */ 02044 02045 /* lobay_parser_lex_init is special because it creates the scanner itself, so it is 02046 * the ONLY reentrant function that doesn't take the scanner as the last argument. 02047 * That's why we explicitly handle the declaration, instead of using our macros. 02048 */ 02049 02050 int lobay_parser_lex_init(yyscan_t* ptr_yy_globals) 02051 02052 { 02053 if (ptr_yy_globals == NULL){ 02054 errno = EINVAL; 02055 return 1; 02056 } 02057 02058 *ptr_yy_globals = (yyscan_t) lobay_parser_alloc ( sizeof( struct yyguts_t ), NULL ); 02059 02060 if (*ptr_yy_globals == NULL){ 02061 errno = ENOMEM; 02062 return 1; 02063 } 02064 02065 /* By setting to 0xAA, we expose bugs in yy_init_globals. Leave at 0x00 for releases. */ 02066 memset(*ptr_yy_globals,0x00,sizeof(struct yyguts_t)); 02067 02068 return yy_init_globals ( *ptr_yy_globals ); 02069 } 02070 02071 static int yy_init_globals (yyscan_t yyscanner) 02072 { 02073 struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; 02074 /* Initialization is the same as for the non-reentrant scanner. 02075 * This function is called from lobay_parser_lex_destroy(), so don't allocate here. 02076 */ 02077 02078 yyg->yy_buffer_stack = 0; 02079 yyg->yy_buffer_stack_top = 0; 02080 yyg->yy_buffer_stack_max = 0; 02081 yyg->yy_c_buf_p = (char *) 0; 02082 yyg->yy_init = 0; 02083 yyg->yy_start = 0; 02084 02085 yyg->yy_start_stack_ptr = 0; 02086 yyg->yy_start_stack_depth = 0; 02087 yyg->yy_start_stack = NULL; 02088 02089 /* Defined in main.c */ 02090 #ifdef YY_STDINIT 02091 yyin = stdin; 02092 yyout = stdout; 02093 #else 02094 yyin = (FILE *) 0; 02095 yyout = (FILE *) 0; 02096 #endif 02097 02098 /* For future reference: Set errno on error, since we are called by 02099 * lobay_parser_lex_init() 02100 */ 02101 return 0; 02102 } 02103 02104 /* lobay_parser_lex_destroy is for both reentrant and non-reentrant scanners. */ 02105 int lobay_parser_lex_destroy (yyscan_t yyscanner) 02106 { 02107 struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; 02108 02109 /* Pop the buffer stack, destroying each element. */ 02110 while(YY_CURRENT_BUFFER){ 02111 lobay_parser__delete_buffer(YY_CURRENT_BUFFER ,yyscanner ); 02112 YY_CURRENT_BUFFER_LVALUE = NULL; 02113 lobay_parser_pop_buffer_state(yyscanner); 02114 } 02115 02116 /* Destroy the stack itself. */ 02117 lobay_parser_free(yyg->yy_buffer_stack ,yyscanner); 02118 yyg->yy_buffer_stack = NULL; 02119 02120 /* Destroy the start condition stack. */ 02121 lobay_parser_free(yyg->yy_start_stack ,yyscanner ); 02122 yyg->yy_start_stack = NULL; 02123 02124 /* Reset the globals. This is important in a non-reentrant scanner so the next time 02125 * lobay_parser_lex() is called, initialization will occur. */ 02126 yy_init_globals( yyscanner); 02127 02128 /* Destroy the main struct (reentrant only). */ 02129 lobay_parser_free ( yyscanner , yyscanner ); 02130 yyscanner = NULL; 02131 return 0; 02132 } 02133 02134 /* 02135 * Internal utility routines. 02136 */ 02137 02138 #ifndef yytext_ptr 02139 static void yy_flex_strncpy (char* s1, yyconst char * s2, int n , yyscan_t yyscanner) 02140 { 02141 register int i; 02142 for ( i = 0; i < n; ++i ) 02143 s1[i] = s2[i]; 02144 } 02145 #endif 02146 02147 #ifdef YY_NEED_STRLEN 02148 static int yy_flex_strlen (yyconst char * s , yyscan_t yyscanner) 02149 { 02150 register int n; 02151 for ( n = 0; s[n]; ++n ) 02152 ; 02153 02154 return n; 02155 } 02156 #endif 02157 02158 void *lobay_parser_alloc (yy_size_t size , yyscan_t yyscanner) 02159 { 02160 return (void *) malloc( size ); 02161 } 02162 02163 void *lobay_parser_realloc (void * ptr, yy_size_t size , yyscan_t yyscanner) 02164 { 02165 /* The cast to (char *) in the following accommodates both 02166 * implementations that use char* generic pointers, and those 02167 * that use void* generic pointers. It works with the latter 02168 * because both ANSI C and C++ allow castless assignment from 02169 * any pointer type to void*, and deal with argument conversions 02170 * as though doing an assignment. 02171 */ 02172 return (void *) realloc( (char *) ptr, size ); 02173 } 02174 02175 void lobay_parser_free (void * ptr , yyscan_t yyscanner) 02176 { 02177 free( (char *) ptr ); /* see lobay_parser_realloc() for (char *) cast */ 02178 } 02179 02180 #define YYTABLES_NAME "yytables" 02181 02182 #line 234 "src/Robots/LoBot/baylog/LoBaylogParser.l"