Wed, 31 Dec 2014 06:09:35 +0100
Cloned upstream origin tor-browser at tor-browser-31.3.0esr-4.5-1-build1
revision ID fc1c9ff7c1b2defdbc039f12214767608f46423f for hacking purpose.
michael@0 | 1 | #line 16 "./Tokenizer.l" |
michael@0 | 2 | // |
michael@0 | 3 | // Copyright (c) 2011-2013 The ANGLE Project Authors. All rights reserved. |
michael@0 | 4 | // Use of this source code is governed by a BSD-style license that can be |
michael@0 | 5 | // found in the LICENSE file. |
michael@0 | 6 | // |
michael@0 | 7 | |
michael@0 | 8 | // This file is auto-generated by generate_parser.sh. DO NOT EDIT! |
michael@0 | 9 | |
michael@0 | 10 | |
michael@0 | 11 | |
michael@0 | 12 | #line 13 "./Tokenizer.cpp" |
michael@0 | 13 | |
michael@0 | 14 | #define YY_INT_ALIGNED short int |
michael@0 | 15 | |
michael@0 | 16 | /* A lexical scanner generated by flex */ |
michael@0 | 17 | |
michael@0 | 18 | #define FLEX_SCANNER |
michael@0 | 19 | #define YY_FLEX_MAJOR_VERSION 2 |
michael@0 | 20 | #define YY_FLEX_MINOR_VERSION 5 |
michael@0 | 21 | #define YY_FLEX_SUBMINOR_VERSION 35 |
michael@0 | 22 | #if YY_FLEX_SUBMINOR_VERSION > 0 |
michael@0 | 23 | #define FLEX_BETA |
michael@0 | 24 | #endif |
michael@0 | 25 | |
michael@0 | 26 | /* First, we deal with platform-specific or compiler-specific issues. */ |
michael@0 | 27 | |
michael@0 | 28 | /* begin standard C headers. */ |
michael@0 | 29 | #include <stdio.h> |
michael@0 | 30 | #include <string.h> |
michael@0 | 31 | #include <errno.h> |
michael@0 | 32 | #include <stdlib.h> |
michael@0 | 33 | |
michael@0 | 34 | /* end standard C headers. */ |
michael@0 | 35 | |
michael@0 | 36 | /* flex integer type definitions */ |
michael@0 | 37 | |
michael@0 | 38 | #ifndef FLEXINT_H |
michael@0 | 39 | #define FLEXINT_H |
michael@0 | 40 | |
michael@0 | 41 | /* C99 systems have <inttypes.h>. Non-C99 systems may or may not. */ |
michael@0 | 42 | |
michael@0 | 43 | #if defined (__STDC_VERSION__) && __STDC_VERSION__ >= 199901L |
michael@0 | 44 | |
michael@0 | 45 | /* C99 says to define __STDC_LIMIT_MACROS before including stdint.h, |
michael@0 | 46 | * if you want the limit (max/min) macros for int types. |
michael@0 | 47 | */ |
michael@0 | 48 | #ifndef __STDC_LIMIT_MACROS |
michael@0 | 49 | #define __STDC_LIMIT_MACROS 1 |
michael@0 | 50 | #endif |
michael@0 | 51 | |
michael@0 | 52 | #include <inttypes.h> |
michael@0 | 53 | typedef int8_t flex_int8_t; |
michael@0 | 54 | typedef uint8_t flex_uint8_t; |
michael@0 | 55 | typedef int16_t flex_int16_t; |
michael@0 | 56 | typedef uint16_t flex_uint16_t; |
michael@0 | 57 | typedef int32_t flex_int32_t; |
michael@0 | 58 | typedef uint32_t flex_uint32_t; |
michael@0 | 59 | typedef uint64_t flex_uint64_t; |
michael@0 | 60 | #else |
michael@0 | 61 | typedef signed char flex_int8_t; |
michael@0 | 62 | typedef short int flex_int16_t; |
michael@0 | 63 | typedef int flex_int32_t; |
michael@0 | 64 | typedef unsigned char flex_uint8_t; |
michael@0 | 65 | typedef unsigned short int flex_uint16_t; |
michael@0 | 66 | typedef unsigned int flex_uint32_t; |
michael@0 | 67 | #endif /* ! C99 */ |
michael@0 | 68 | |
michael@0 | 69 | /* Limits of integral types. */ |
michael@0 | 70 | #ifndef INT8_MIN |
michael@0 | 71 | #define INT8_MIN (-128) |
michael@0 | 72 | #endif |
michael@0 | 73 | #ifndef INT16_MIN |
michael@0 | 74 | #define INT16_MIN (-32767-1) |
michael@0 | 75 | #endif |
michael@0 | 76 | #ifndef INT32_MIN |
michael@0 | 77 | #define INT32_MIN (-2147483647-1) |
michael@0 | 78 | #endif |
michael@0 | 79 | #ifndef INT8_MAX |
michael@0 | 80 | #define INT8_MAX (127) |
michael@0 | 81 | #endif |
michael@0 | 82 | #ifndef INT16_MAX |
michael@0 | 83 | #define INT16_MAX (32767) |
michael@0 | 84 | #endif |
michael@0 | 85 | #ifndef INT32_MAX |
michael@0 | 86 | #define INT32_MAX (2147483647) |
michael@0 | 87 | #endif |
michael@0 | 88 | #ifndef UINT8_MAX |
michael@0 | 89 | #define UINT8_MAX (255U) |
michael@0 | 90 | #endif |
michael@0 | 91 | #ifndef UINT16_MAX |
michael@0 | 92 | #define UINT16_MAX (65535U) |
michael@0 | 93 | #endif |
michael@0 | 94 | #ifndef UINT32_MAX |
michael@0 | 95 | #define UINT32_MAX (4294967295U) |
michael@0 | 96 | #endif |
michael@0 | 97 | |
michael@0 | 98 | #endif /* ! FLEXINT_H */ |
michael@0 | 99 | |
michael@0 | 100 | #ifdef __cplusplus |
michael@0 | 101 | |
michael@0 | 102 | /* The "const" storage-class-modifier is valid. */ |
michael@0 | 103 | #define YY_USE_CONST |
michael@0 | 104 | |
michael@0 | 105 | #else /* ! __cplusplus */ |
michael@0 | 106 | |
michael@0 | 107 | /* C99 requires __STDC__ to be defined as 1. */ |
michael@0 | 108 | #if defined (__STDC__) |
michael@0 | 109 | |
michael@0 | 110 | #define YY_USE_CONST |
michael@0 | 111 | |
michael@0 | 112 | #endif /* defined (__STDC__) */ |
michael@0 | 113 | #endif /* ! __cplusplus */ |
michael@0 | 114 | |
michael@0 | 115 | #ifdef YY_USE_CONST |
michael@0 | 116 | #define yyconst const |
michael@0 | 117 | #else |
michael@0 | 118 | #define yyconst |
michael@0 | 119 | #endif |
michael@0 | 120 | |
michael@0 | 121 | /* Returned upon end-of-file. */ |
michael@0 | 122 | #define YY_NULL 0 |
michael@0 | 123 | |
michael@0 | 124 | /* Promotes a possibly negative, possibly signed char to an unsigned |
michael@0 | 125 | * integer for use as an array index. If the signed char is negative, |
michael@0 | 126 | * we want to instead treat it as an 8-bit unsigned char, hence the |
michael@0 | 127 | * double cast. |
michael@0 | 128 | */ |
michael@0 | 129 | #define YY_SC_TO_UI(c) ((unsigned int) (unsigned char) c) |
michael@0 | 130 | |
michael@0 | 131 | /* An opaque pointer. */ |
michael@0 | 132 | #ifndef YY_TYPEDEF_YY_SCANNER_T |
michael@0 | 133 | #define YY_TYPEDEF_YY_SCANNER_T |
michael@0 | 134 | typedef void* yyscan_t; |
michael@0 | 135 | #endif |
michael@0 | 136 | |
michael@0 | 137 | /* For convenience, these vars (plus the bison vars far below) |
michael@0 | 138 | are macros in the reentrant scanner. */ |
michael@0 | 139 | #define yyin yyg->yyin_r |
michael@0 | 140 | #define yyout yyg->yyout_r |
michael@0 | 141 | #define yyextra yyg->yyextra_r |
michael@0 | 142 | #define yyleng yyg->yyleng_r |
michael@0 | 143 | #define yytext yyg->yytext_r |
michael@0 | 144 | #define yylineno (YY_CURRENT_BUFFER_LVALUE->yy_bs_lineno) |
michael@0 | 145 | #define yycolumn (YY_CURRENT_BUFFER_LVALUE->yy_bs_column) |
michael@0 | 146 | #define yy_flex_debug yyg->yy_flex_debug_r |
michael@0 | 147 | |
michael@0 | 148 | /* Enter a start condition. This macro really ought to take a parameter, |
michael@0 | 149 | * but we do it the disgusting crufty way forced on us by the ()-less |
michael@0 | 150 | * definition of BEGIN. |
michael@0 | 151 | */ |
michael@0 | 152 | #define BEGIN yyg->yy_start = 1 + 2 * |
michael@0 | 153 | |
michael@0 | 154 | /* Translate the current start state into a value that can be later handed |
michael@0 | 155 | * to BEGIN to return to the state. The YYSTATE alias is for lex |
michael@0 | 156 | * compatibility. |
michael@0 | 157 | */ |
michael@0 | 158 | #define YY_START ((yyg->yy_start - 1) / 2) |
michael@0 | 159 | #define YYSTATE YY_START |
michael@0 | 160 | |
michael@0 | 161 | /* Action number for EOF rule of a given start state. */ |
michael@0 | 162 | #define YY_STATE_EOF(state) (YY_END_OF_BUFFER + state + 1) |
michael@0 | 163 | |
michael@0 | 164 | /* Special action meaning "start processing a new file". */ |
michael@0 | 165 | #define YY_NEW_FILE pprestart(yyin ,yyscanner ) |
michael@0 | 166 | |
michael@0 | 167 | #define YY_END_OF_BUFFER_CHAR 0 |
michael@0 | 168 | |
michael@0 | 169 | /* Size of default input buffer. */ |
michael@0 | 170 | #ifndef YY_BUF_SIZE |
michael@0 | 171 | #define YY_BUF_SIZE 16384 |
michael@0 | 172 | #endif |
michael@0 | 173 | |
michael@0 | 174 | /* The state buf must be large enough to hold one state per character in the main buffer. |
michael@0 | 175 | */ |
michael@0 | 176 | #define YY_STATE_BUF_SIZE ((YY_BUF_SIZE + 2) * sizeof(yy_state_type)) |
michael@0 | 177 | |
michael@0 | 178 | #ifndef YY_TYPEDEF_YY_BUFFER_STATE |
michael@0 | 179 | #define YY_TYPEDEF_YY_BUFFER_STATE |
michael@0 | 180 | typedef struct yy_buffer_state *YY_BUFFER_STATE; |
michael@0 | 181 | #endif |
michael@0 | 182 | |
michael@0 | 183 | #ifndef YY_TYPEDEF_YY_SIZE_T |
michael@0 | 184 | #define YY_TYPEDEF_YY_SIZE_T |
michael@0 | 185 | typedef size_t yy_size_t; |
michael@0 | 186 | #endif |
michael@0 | 187 | |
michael@0 | 188 | #define EOB_ACT_CONTINUE_SCAN 0 |
michael@0 | 189 | #define EOB_ACT_END_OF_FILE 1 |
michael@0 | 190 | #define EOB_ACT_LAST_MATCH 2 |
michael@0 | 191 | |
michael@0 | 192 | #define YY_LESS_LINENO(n) |
michael@0 | 193 | |
michael@0 | 194 | /* Return all but the first "n" matched characters back to the input stream. */ |
michael@0 | 195 | #define yyless(n) \ |
michael@0 | 196 | do \ |
michael@0 | 197 | { \ |
michael@0 | 198 | /* Undo effects of setting up yytext. */ \ |
michael@0 | 199 | int yyless_macro_arg = (n); \ |
michael@0 | 200 | YY_LESS_LINENO(yyless_macro_arg);\ |
michael@0 | 201 | *yy_cp = yyg->yy_hold_char; \ |
michael@0 | 202 | YY_RESTORE_YY_MORE_OFFSET \ |
michael@0 | 203 | yyg->yy_c_buf_p = yy_cp = yy_bp + yyless_macro_arg - YY_MORE_ADJ; \ |
michael@0 | 204 | YY_DO_BEFORE_ACTION; /* set up yytext again */ \ |
michael@0 | 205 | } \ |
michael@0 | 206 | while ( 0 ) |
michael@0 | 207 | |
michael@0 | 208 | #define unput(c) yyunput( c, yyg->yytext_ptr , yyscanner ) |
michael@0 | 209 | |
michael@0 | 210 | #ifndef YY_STRUCT_YY_BUFFER_STATE |
michael@0 | 211 | #define YY_STRUCT_YY_BUFFER_STATE |
michael@0 | 212 | struct yy_buffer_state |
michael@0 | 213 | { |
michael@0 | 214 | FILE *yy_input_file; |
michael@0 | 215 | |
michael@0 | 216 | char *yy_ch_buf; /* input buffer */ |
michael@0 | 217 | char *yy_buf_pos; /* current position in input buffer */ |
michael@0 | 218 | |
michael@0 | 219 | /* Size of input buffer in bytes, not including room for EOB |
michael@0 | 220 | * characters. |
michael@0 | 221 | */ |
michael@0 | 222 | yy_size_t yy_buf_size; |
michael@0 | 223 | |
michael@0 | 224 | /* Number of characters read into yy_ch_buf, not including EOB |
michael@0 | 225 | * characters. |
michael@0 | 226 | */ |
michael@0 | 227 | yy_size_t yy_n_chars; |
michael@0 | 228 | |
michael@0 | 229 | /* Whether we "own" the buffer - i.e., we know we created it, |
michael@0 | 230 | * and can realloc() it to grow it, and should free() it to |
michael@0 | 231 | * delete it. |
michael@0 | 232 | */ |
michael@0 | 233 | int yy_is_our_buffer; |
michael@0 | 234 | |
michael@0 | 235 | /* Whether this is an "interactive" input source; if so, and |
michael@0 | 236 | * if we're using stdio for input, then we want to use getc() |
michael@0 | 237 | * instead of fread(), to make sure we stop fetching input after |
michael@0 | 238 | * each newline. |
michael@0 | 239 | */ |
michael@0 | 240 | int yy_is_interactive; |
michael@0 | 241 | |
michael@0 | 242 | /* Whether we're considered to be at the beginning of a line. |
michael@0 | 243 | * If so, '^' rules will be active on the next match, otherwise |
michael@0 | 244 | * not. |
michael@0 | 245 | */ |
michael@0 | 246 | int yy_at_bol; |
michael@0 | 247 | |
michael@0 | 248 | int yy_bs_lineno; /**< The line count. */ |
michael@0 | 249 | int yy_bs_column; /**< The column count. */ |
michael@0 | 250 | |
michael@0 | 251 | /* Whether to try to fill the input buffer when we reach the |
michael@0 | 252 | * end of it. |
michael@0 | 253 | */ |
michael@0 | 254 | int yy_fill_buffer; |
michael@0 | 255 | |
michael@0 | 256 | int yy_buffer_status; |
michael@0 | 257 | |
michael@0 | 258 | #define YY_BUFFER_NEW 0 |
michael@0 | 259 | #define YY_BUFFER_NORMAL 1 |
michael@0 | 260 | /* When an EOF's been seen but there's still some text to process |
michael@0 | 261 | * then we mark the buffer as YY_EOF_PENDING, to indicate that we |
michael@0 | 262 | * shouldn't try reading from the input source any more. We might |
michael@0 | 263 | * still have a bunch of tokens to match, though, because of |
michael@0 | 264 | * possible backing-up. |
michael@0 | 265 | * |
michael@0 | 266 | * When we actually see the EOF, we change the status to "new" |
michael@0 | 267 | * (via pprestart()), so that the user can continue scanning by |
michael@0 | 268 | * just pointing yyin at a new input file. |
michael@0 | 269 | */ |
michael@0 | 270 | #define YY_BUFFER_EOF_PENDING 2 |
michael@0 | 271 | |
michael@0 | 272 | }; |
michael@0 | 273 | #endif /* !YY_STRUCT_YY_BUFFER_STATE */ |
michael@0 | 274 | |
michael@0 | 275 | /* We provide macros for accessing buffer states in case in the |
michael@0 | 276 | * future we want to put the buffer states in a more general |
michael@0 | 277 | * "scanner state". |
michael@0 | 278 | * |
michael@0 | 279 | * Returns the top of the stack, or NULL. |
michael@0 | 280 | */ |
michael@0 | 281 | #define YY_CURRENT_BUFFER ( yyg->yy_buffer_stack \ |
michael@0 | 282 | ? yyg->yy_buffer_stack[yyg->yy_buffer_stack_top] \ |
michael@0 | 283 | : NULL) |
michael@0 | 284 | |
michael@0 | 285 | /* Same as previous macro, but useful when we know that the buffer stack is not |
michael@0 | 286 | * NULL or when we need an lvalue. For internal use only. |
michael@0 | 287 | */ |
michael@0 | 288 | #define YY_CURRENT_BUFFER_LVALUE yyg->yy_buffer_stack[yyg->yy_buffer_stack_top] |
michael@0 | 289 | |
michael@0 | 290 | void pprestart (FILE *input_file ,yyscan_t yyscanner ); |
michael@0 | 291 | void pp_switch_to_buffer (YY_BUFFER_STATE new_buffer ,yyscan_t yyscanner ); |
michael@0 | 292 | YY_BUFFER_STATE pp_create_buffer (FILE *file,int size ,yyscan_t yyscanner ); |
michael@0 | 293 | void pp_delete_buffer (YY_BUFFER_STATE b ,yyscan_t yyscanner ); |
michael@0 | 294 | void pp_flush_buffer (YY_BUFFER_STATE b ,yyscan_t yyscanner ); |
michael@0 | 295 | void pppush_buffer_state (YY_BUFFER_STATE new_buffer ,yyscan_t yyscanner ); |
michael@0 | 296 | void pppop_buffer_state (yyscan_t yyscanner ); |
michael@0 | 297 | |
michael@0 | 298 | static void ppensure_buffer_stack (yyscan_t yyscanner ); |
michael@0 | 299 | static void pp_load_buffer_state (yyscan_t yyscanner ); |
michael@0 | 300 | static void pp_init_buffer (YY_BUFFER_STATE b,FILE *file ,yyscan_t yyscanner ); |
michael@0 | 301 | |
michael@0 | 302 | #define YY_FLUSH_BUFFER pp_flush_buffer(YY_CURRENT_BUFFER ,yyscanner) |
michael@0 | 303 | |
michael@0 | 304 | YY_BUFFER_STATE pp_scan_buffer (char *base,yy_size_t size ,yyscan_t yyscanner ); |
michael@0 | 305 | YY_BUFFER_STATE pp_scan_string (yyconst char *yy_str ,yyscan_t yyscanner ); |
michael@0 | 306 | YY_BUFFER_STATE pp_scan_bytes (yyconst char *bytes,yy_size_t len ,yyscan_t yyscanner ); |
michael@0 | 307 | |
michael@0 | 308 | void *ppalloc (yy_size_t ,yyscan_t yyscanner ); |
michael@0 | 309 | void *pprealloc (void *,yy_size_t ,yyscan_t yyscanner ); |
michael@0 | 310 | void ppfree (void * ,yyscan_t yyscanner ); |
michael@0 | 311 | |
michael@0 | 312 | #define yy_new_buffer pp_create_buffer |
michael@0 | 313 | |
michael@0 | 314 | #define yy_set_interactive(is_interactive) \ |
michael@0 | 315 | { \ |
michael@0 | 316 | if ( ! YY_CURRENT_BUFFER ){ \ |
michael@0 | 317 | ppensure_buffer_stack (yyscanner); \ |
michael@0 | 318 | YY_CURRENT_BUFFER_LVALUE = \ |
michael@0 | 319 | pp_create_buffer(yyin,YY_BUF_SIZE ,yyscanner); \ |
michael@0 | 320 | } \ |
michael@0 | 321 | YY_CURRENT_BUFFER_LVALUE->yy_is_interactive = is_interactive; \ |
michael@0 | 322 | } |
michael@0 | 323 | |
michael@0 | 324 | #define yy_set_bol(at_bol) \ |
michael@0 | 325 | { \ |
michael@0 | 326 | if ( ! YY_CURRENT_BUFFER ){\ |
michael@0 | 327 | ppensure_buffer_stack (yyscanner); \ |
michael@0 | 328 | YY_CURRENT_BUFFER_LVALUE = \ |
michael@0 | 329 | pp_create_buffer(yyin,YY_BUF_SIZE ,yyscanner); \ |
michael@0 | 330 | } \ |
michael@0 | 331 | YY_CURRENT_BUFFER_LVALUE->yy_at_bol = at_bol; \ |
michael@0 | 332 | } |
michael@0 | 333 | |
michael@0 | 334 | #define YY_AT_BOL() (YY_CURRENT_BUFFER_LVALUE->yy_at_bol) |
michael@0 | 335 | |
michael@0 | 336 | /* Begin user sect3 */ |
michael@0 | 337 | |
michael@0 | 338 | #define ppwrap(n) 1 |
michael@0 | 339 | #define YY_SKIP_YYWRAP |
michael@0 | 340 | |
michael@0 | 341 | typedef unsigned char YY_CHAR; |
michael@0 | 342 | |
michael@0 | 343 | typedef int yy_state_type; |
michael@0 | 344 | |
michael@0 | 345 | #define yytext_ptr yytext_r |
michael@0 | 346 | |
michael@0 | 347 | static yy_state_type yy_get_previous_state (yyscan_t yyscanner ); |
michael@0 | 348 | static yy_state_type yy_try_NUL_trans (yy_state_type current_state ,yyscan_t yyscanner); |
michael@0 | 349 | static int yy_get_next_buffer (yyscan_t yyscanner ); |
michael@0 | 350 | static void yy_fatal_error (yyconst char msg[] ,yyscan_t yyscanner ); |
michael@0 | 351 | |
michael@0 | 352 | /* Done after the current pattern has been matched and before the |
michael@0 | 353 | * corresponding action - sets up yytext. |
michael@0 | 354 | */ |
michael@0 | 355 | #define YY_DO_BEFORE_ACTION \ |
michael@0 | 356 | yyg->yytext_ptr = yy_bp; \ |
michael@0 | 357 | yyleng = (yy_size_t) (yy_cp - yy_bp); \ |
michael@0 | 358 | yyg->yy_hold_char = *yy_cp; \ |
michael@0 | 359 | *yy_cp = '\0'; \ |
michael@0 | 360 | yyg->yy_c_buf_p = yy_cp; |
michael@0 | 361 | |
michael@0 | 362 | #define YY_NUM_RULES 38 |
michael@0 | 363 | #define YY_END_OF_BUFFER 39 |
michael@0 | 364 | /* This struct is not used in this scanner, |
michael@0 | 365 | but its presence is necessary. */ |
michael@0 | 366 | struct yy_trans_info |
michael@0 | 367 | { |
michael@0 | 368 | flex_int32_t yy_verify; |
michael@0 | 369 | flex_int32_t yy_nxt; |
michael@0 | 370 | }; |
michael@0 | 371 | static yyconst flex_int16_t yy_accept[87] = |
michael@0 | 372 | { 0, |
michael@0 | 373 | 0, 0, 0, 0, 39, 37, 34, 35, 35, 33, |
michael@0 | 374 | 7, 33, 33, 33, 33, 33, 33, 33, 33, 9, |
michael@0 | 375 | 9, 33, 33, 33, 8, 37, 33, 33, 3, 5, |
michael@0 | 376 | 5, 4, 34, 35, 19, 27, 20, 30, 25, 12, |
michael@0 | 377 | 23, 13, 24, 10, 2, 1, 26, 10, 9, 11, |
michael@0 | 378 | 11, 11, 11, 9, 14, 16, 18, 17, 15, 8, |
michael@0 | 379 | 36, 36, 31, 21, 32, 22, 3, 5, 6, 11, |
michael@0 | 380 | 10, 11, 1, 10, 11, 0, 10, 9, 28, 29, |
michael@0 | 381 | 0, 10, 10, 10, 10, 0 |
michael@0 | 382 | } ; |
michael@0 | 383 | |
michael@0 | 384 | static yyconst flex_int32_t yy_ec[256] = |
michael@0 | 385 | { 0, |
michael@0 | 386 | 1, 1, 1, 1, 1, 1, 1, 1, 2, 3, |
michael@0 | 387 | 2, 2, 4, 1, 1, 1, 1, 1, 1, 1, |
michael@0 | 388 | 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, |
michael@0 | 389 | 1, 2, 5, 1, 6, 1, 7, 8, 1, 9, |
michael@0 | 390 | 9, 10, 11, 9, 12, 13, 14, 15, 16, 16, |
michael@0 | 391 | 16, 16, 16, 16, 16, 17, 17, 9, 9, 18, |
michael@0 | 392 | 19, 20, 9, 1, 21, 21, 21, 21, 22, 21, |
michael@0 | 393 | 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, |
michael@0 | 394 | 23, 23, 23, 23, 23, 23, 23, 24, 23, 23, |
michael@0 | 395 | 9, 25, 9, 26, 23, 1, 21, 21, 21, 21, |
michael@0 | 396 | |
michael@0 | 397 | 22, 21, 23, 23, 23, 23, 23, 23, 23, 23, |
michael@0 | 398 | 23, 23, 23, 23, 23, 23, 23, 23, 23, 24, |
michael@0 | 399 | 23, 23, 9, 27, 9, 9, 1, 1, 1, 1, |
michael@0 | 400 | 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, |
michael@0 | 401 | 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, |
michael@0 | 402 | 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, |
michael@0 | 403 | 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, |
michael@0 | 404 | 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, |
michael@0 | 405 | 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, |
michael@0 | 406 | 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, |
michael@0 | 407 | |
michael@0 | 408 | 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, |
michael@0 | 409 | 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, |
michael@0 | 410 | 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, |
michael@0 | 411 | 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, |
michael@0 | 412 | 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, |
michael@0 | 413 | 1, 1, 1, 1, 1 |
michael@0 | 414 | } ; |
michael@0 | 415 | |
michael@0 | 416 | static yyconst flex_int32_t yy_meta[28] = |
michael@0 | 417 | { 0, |
michael@0 | 418 | 1, 1, 2, 2, 1, 1, 1, 1, 1, 3, |
michael@0 | 419 | 1, 1, 4, 1, 5, 5, 5, 1, 1, 1, |
michael@0 | 420 | 5, 5, 5, 5, 1, 1, 1 |
michael@0 | 421 | } ; |
michael@0 | 422 | |
michael@0 | 423 | static yyconst flex_int16_t yy_base[92] = |
michael@0 | 424 | { 0, |
michael@0 | 425 | 0, 0, 25, 27, 162, 163, 159, 163, 152, 132, |
michael@0 | 426 | 163, 131, 24, 163, 116, 22, 26, 31, 30, 37, |
michael@0 | 427 | 40, 44, 115, 46, 0, 64, 50, 15, 0, 163, |
michael@0 | 428 | 124, 91, 88, 163, 163, 163, 163, 163, 163, 163, |
michael@0 | 429 | 163, 163, 163, 64, 163, 0, 163, 76, 54, 58, |
michael@0 | 430 | 79, 91, 91, 0, 56, 163, 163, 163, 32, 0, |
michael@0 | 431 | 163, 36, 163, 163, 163, 163, 0, 163, 163, 94, |
michael@0 | 432 | 0, 106, 0, 0, 113, 55, 72, 113, 163, 163, |
michael@0 | 433 | 116, 101, 108, 123, 126, 163, 143, 31, 148, 153, |
michael@0 | 434 | 155 |
michael@0 | 435 | |
michael@0 | 436 | } ; |
michael@0 | 437 | |
michael@0 | 438 | static yyconst flex_int16_t yy_def[92] = |
michael@0 | 439 | { 0, |
michael@0 | 440 | 86, 1, 87, 87, 86, 86, 86, 86, 86, 86, |
michael@0 | 441 | 86, 86, 86, 86, 86, 86, 86, 86, 86, 86, |
michael@0 | 442 | 20, 86, 86, 86, 88, 86, 86, 86, 89, 86, |
michael@0 | 443 | 86, 86, 86, 86, 86, 86, 86, 86, 86, 86, |
michael@0 | 444 | 86, 86, 86, 86, 86, 90, 86, 86, 20, 20, |
michael@0 | 445 | 48, 51, 91, 21, 86, 86, 86, 86, 86, 88, |
michael@0 | 446 | 86, 86, 86, 86, 86, 86, 89, 86, 86, 44, |
michael@0 | 447 | 44, 70, 90, 48, 51, 86, 52, 91, 86, 86, |
michael@0 | 448 | 86, 72, 75, 86, 86, 0, 86, 86, 86, 86, |
michael@0 | 449 | 86 |
michael@0 | 450 | |
michael@0 | 451 | } ; |
michael@0 | 452 | |
michael@0 | 453 | static yyconst flex_int16_t yy_nxt[191] = |
michael@0 | 454 | { 0, |
michael@0 | 455 | 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, |
michael@0 | 456 | 16, 17, 18, 19, 20, 21, 21, 22, 23, 24, |
michael@0 | 457 | 25, 25, 25, 25, 26, 27, 28, 30, 31, 30, |
michael@0 | 458 | 31, 37, 40, 65, 32, 60, 32, 42, 61, 45, |
michael@0 | 459 | 41, 66, 38, 46, 43, 44, 44, 44, 47, 48, |
michael@0 | 460 | 80, 49, 49, 50, 54, 54, 54, 51, 52, 51, |
michael@0 | 461 | 53, 55, 56, 51, 58, 59, 61, 62, 63, 84, |
michael@0 | 462 | 84, 84, 50, 50, 79, 64, 70, 51, 71, 71, |
michael@0 | 463 | 71, 51, 86, 86, 70, 72, 70, 70, 51, 33, |
michael@0 | 464 | 74, 74, 74, 51, 51, 51, 51, 75, 51, 51, |
michael@0 | 465 | |
michael@0 | 466 | 51, 76, 76, 51, 69, 77, 77, 77, 70, 70, |
michael@0 | 467 | 70, 86, 86, 51, 51, 70, 81, 81, 86, 86, |
michael@0 | 468 | 82, 82, 82, 81, 81, 51, 68, 83, 83, 83, |
michael@0 | 469 | 85, 85, 85, 57, 39, 51, 51, 84, 84, 84, |
michael@0 | 470 | 85, 85, 85, 29, 29, 29, 29, 29, 67, 36, |
michael@0 | 471 | 35, 67, 67, 73, 34, 73, 73, 73, 78, 78, |
michael@0 | 472 | 33, 86, 5, 86, 86, 86, 86, 86, 86, 86, |
michael@0 | 473 | 86, 86, 86, 86, 86, 86, 86, 86, 86, 86, |
michael@0 | 474 | 86, 86, 86, 86, 86, 86, 86, 86, 86, 86 |
michael@0 | 475 | } ; |
michael@0 | 476 | |
michael@0 | 477 | static yyconst flex_int16_t yy_chk[191] = |
michael@0 | 478 | { 0, |
michael@0 | 479 | 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, |
michael@0 | 480 | 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, |
michael@0 | 481 | 1, 1, 1, 1, 1, 1, 1, 3, 3, 4, |
michael@0 | 482 | 4, 13, 16, 28, 3, 88, 4, 17, 62, 19, |
michael@0 | 483 | 16, 28, 13, 19, 17, 18, 18, 18, 19, 20, |
michael@0 | 484 | 59, 20, 20, 20, 21, 21, 21, 20, 20, 20, |
michael@0 | 485 | 20, 22, 22, 21, 24, 24, 26, 26, 27, 76, |
michael@0 | 486 | 76, 76, 50, 50, 55, 27, 44, 49, 44, 44, |
michael@0 | 487 | 44, 50, 77, 77, 44, 44, 44, 44, 48, 33, |
michael@0 | 488 | 48, 48, 48, 51, 51, 51, 48, 48, 48, 48, |
michael@0 | 489 | |
michael@0 | 490 | 51, 52, 52, 53, 32, 52, 52, 52, 70, 70, |
michael@0 | 491 | 70, 82, 82, 53, 53, 70, 72, 72, 83, 83, |
michael@0 | 492 | 72, 72, 72, 75, 75, 78, 31, 75, 75, 75, |
michael@0 | 493 | 81, 81, 81, 23, 15, 78, 78, 84, 84, 84, |
michael@0 | 494 | 85, 85, 85, 87, 87, 87, 87, 87, 89, 12, |
michael@0 | 495 | 10, 89, 89, 90, 9, 90, 90, 90, 91, 91, |
michael@0 | 496 | 7, 5, 86, 86, 86, 86, 86, 86, 86, 86, |
michael@0 | 497 | 86, 86, 86, 86, 86, 86, 86, 86, 86, 86, |
michael@0 | 498 | 86, 86, 86, 86, 86, 86, 86, 86, 86, 86 |
michael@0 | 499 | } ; |
michael@0 | 500 | |
michael@0 | 501 | /* The intent behind this definition is that it'll catch |
michael@0 | 502 | * any uses of REJECT which flex missed. |
michael@0 | 503 | */ |
michael@0 | 504 | #define REJECT reject_used_but_not_detected |
michael@0 | 505 | #define yymore() yymore_used_but_not_detected |
michael@0 | 506 | #define YY_MORE_ADJ 0 |
michael@0 | 507 | #define YY_RESTORE_YY_MORE_OFFSET |
michael@0 | 508 | /* |
michael@0 | 509 | // |
michael@0 | 510 | // Copyright (c) 2002-2013 The ANGLE Project Authors. All rights reserved. |
michael@0 | 511 | // Use of this source code is governed by a BSD-style license that can be |
michael@0 | 512 | // found in the LICENSE file. |
michael@0 | 513 | // |
michael@0 | 514 | |
michael@0 | 515 | This file contains the Lex specification for GLSL ES preprocessor. |
michael@0 | 516 | Based on Microsoft Visual Studio 2010 Preprocessor Grammar: |
michael@0 | 517 | http://msdn.microsoft.com/en-us/library/2scxys89.aspx |
michael@0 | 518 | |
michael@0 | 519 | IF YOU MODIFY THIS FILE YOU ALSO NEED TO RUN generate_parser.sh. |
michael@0 | 520 | */ |
michael@0 | 521 | |
michael@0 | 522 | #include "Tokenizer.h" |
michael@0 | 523 | |
michael@0 | 524 | #include "DiagnosticsBase.h" |
michael@0 | 525 | #include "Token.h" |
michael@0 | 526 | |
michael@0 | 527 | #if defined(__GNUC__) |
michael@0 | 528 | // Triggered by the auto-generated yy_fatal_error function. |
michael@0 | 529 | #pragma GCC diagnostic ignored "-Wmissing-noreturn" |
michael@0 | 530 | #endif |
michael@0 | 531 | |
michael@0 | 532 | typedef std::string YYSTYPE; |
michael@0 | 533 | typedef pp::SourceLocation YYLTYPE; |
michael@0 | 534 | |
michael@0 | 535 | // Use the unused yycolumn variable to track file (string) number. |
michael@0 | 536 | #define yyfileno yycolumn |
michael@0 | 537 | |
michael@0 | 538 | #define YY_USER_INIT \ |
michael@0 | 539 | do { \ |
michael@0 | 540 | yyfileno = 0; \ |
michael@0 | 541 | yylineno = 1; \ |
michael@0 | 542 | yyextra->leadingSpace = false; \ |
michael@0 | 543 | yyextra->lineStart = true; \ |
michael@0 | 544 | } while(0); |
michael@0 | 545 | |
michael@0 | 546 | #define YY_USER_ACTION \ |
michael@0 | 547 | do \ |
michael@0 | 548 | { \ |
michael@0 | 549 | pp::Input* input = &yyextra->input; \ |
michael@0 | 550 | pp::Input::Location* scanLoc = &yyextra->scanLoc; \ |
michael@0 | 551 | while ((scanLoc->sIndex < input->count()) && \ |
michael@0 | 552 | (scanLoc->cIndex >= input->length(scanLoc->sIndex))) \ |
michael@0 | 553 | { \ |
michael@0 | 554 | scanLoc->cIndex -= input->length(scanLoc->sIndex++); \ |
michael@0 | 555 | ++yyfileno; yylineno = 1; \ |
michael@0 | 556 | } \ |
michael@0 | 557 | yylloc->file = yyfileno; \ |
michael@0 | 558 | yylloc->line = yylineno; \ |
michael@0 | 559 | scanLoc->cIndex += yyleng; \ |
michael@0 | 560 | } while(0); |
michael@0 | 561 | |
michael@0 | 562 | #define YY_INPUT(buf, result, maxSize) \ |
michael@0 | 563 | result = yyextra->input.read(buf, maxSize); |
michael@0 | 564 | |
michael@0 | 565 | #define INITIAL 0 |
michael@0 | 566 | #define COMMENT 1 |
michael@0 | 567 | |
michael@0 | 568 | #define YY_EXTRA_TYPE pp::Tokenizer::Context* |
michael@0 | 569 | |
michael@0 | 570 | /* Holds the entire state of the reentrant scanner. */ |
michael@0 | 571 | struct yyguts_t |
michael@0 | 572 | { |
michael@0 | 573 | |
michael@0 | 574 | /* User-defined. Not touched by flex. */ |
michael@0 | 575 | YY_EXTRA_TYPE yyextra_r; |
michael@0 | 576 | |
michael@0 | 577 | /* The rest are the same as the globals declared in the non-reentrant scanner. */ |
michael@0 | 578 | FILE *yyin_r, *yyout_r; |
michael@0 | 579 | size_t yy_buffer_stack_top; /**< index of top of stack. */ |
michael@0 | 580 | size_t yy_buffer_stack_max; /**< capacity of stack. */ |
michael@0 | 581 | YY_BUFFER_STATE * yy_buffer_stack; /**< Stack as an array. */ |
michael@0 | 582 | char yy_hold_char; |
michael@0 | 583 | yy_size_t yy_n_chars; |
michael@0 | 584 | yy_size_t yyleng_r; |
michael@0 | 585 | char *yy_c_buf_p; |
michael@0 | 586 | int yy_init; |
michael@0 | 587 | int yy_start; |
michael@0 | 588 | int yy_did_buffer_switch_on_eof; |
michael@0 | 589 | int yy_start_stack_ptr; |
michael@0 | 590 | int yy_start_stack_depth; |
michael@0 | 591 | int *yy_start_stack; |
michael@0 | 592 | yy_state_type yy_last_accepting_state; |
michael@0 | 593 | char* yy_last_accepting_cpos; |
michael@0 | 594 | |
michael@0 | 595 | int yylineno_r; |
michael@0 | 596 | int yy_flex_debug_r; |
michael@0 | 597 | |
michael@0 | 598 | char *yytext_r; |
michael@0 | 599 | int yy_more_flag; |
michael@0 | 600 | int yy_more_len; |
michael@0 | 601 | |
michael@0 | 602 | YYSTYPE * yylval_r; |
michael@0 | 603 | |
michael@0 | 604 | YYLTYPE * yylloc_r; |
michael@0 | 605 | |
michael@0 | 606 | }; /* end struct yyguts_t */ |
michael@0 | 607 | |
michael@0 | 608 | static int yy_init_globals (yyscan_t yyscanner ); |
michael@0 | 609 | |
michael@0 | 610 | /* This must go here because YYSTYPE and YYLTYPE are included |
michael@0 | 611 | * from bison output in section 1.*/ |
michael@0 | 612 | # define yylval yyg->yylval_r |
michael@0 | 613 | |
michael@0 | 614 | # define yylloc yyg->yylloc_r |
michael@0 | 615 | |
michael@0 | 616 | int pplex_init (yyscan_t* scanner); |
michael@0 | 617 | |
michael@0 | 618 | int pplex_init_extra (YY_EXTRA_TYPE user_defined,yyscan_t* scanner); |
michael@0 | 619 | |
michael@0 | 620 | /* Accessor methods to globals. |
michael@0 | 621 | These are made visible to non-reentrant scanners for convenience. */ |
michael@0 | 622 | |
michael@0 | 623 | int pplex_destroy (yyscan_t yyscanner ); |
michael@0 | 624 | |
michael@0 | 625 | int ppget_debug (yyscan_t yyscanner ); |
michael@0 | 626 | |
michael@0 | 627 | void ppset_debug (int debug_flag ,yyscan_t yyscanner ); |
michael@0 | 628 | |
michael@0 | 629 | YY_EXTRA_TYPE ppget_extra (yyscan_t yyscanner ); |
michael@0 | 630 | |
michael@0 | 631 | void ppset_extra (YY_EXTRA_TYPE user_defined ,yyscan_t yyscanner ); |
michael@0 | 632 | |
michael@0 | 633 | FILE *ppget_in (yyscan_t yyscanner ); |
michael@0 | 634 | |
michael@0 | 635 | void ppset_in (FILE * in_str ,yyscan_t yyscanner ); |
michael@0 | 636 | |
michael@0 | 637 | FILE *ppget_out (yyscan_t yyscanner ); |
michael@0 | 638 | |
michael@0 | 639 | void ppset_out (FILE * out_str ,yyscan_t yyscanner ); |
michael@0 | 640 | |
michael@0 | 641 | yy_size_t ppget_leng (yyscan_t yyscanner ); |
michael@0 | 642 | |
michael@0 | 643 | char *ppget_text (yyscan_t yyscanner ); |
michael@0 | 644 | |
michael@0 | 645 | int ppget_lineno (yyscan_t yyscanner ); |
michael@0 | 646 | |
michael@0 | 647 | void ppset_lineno (int line_number ,yyscan_t yyscanner ); |
michael@0 | 648 | |
michael@0 | 649 | YYSTYPE * ppget_lval (yyscan_t yyscanner ); |
michael@0 | 650 | |
michael@0 | 651 | void ppset_lval (YYSTYPE * yylval_param ,yyscan_t yyscanner ); |
michael@0 | 652 | |
michael@0 | 653 | YYLTYPE *ppget_lloc (yyscan_t yyscanner ); |
michael@0 | 654 | |
michael@0 | 655 | void ppset_lloc (YYLTYPE * yylloc_param ,yyscan_t yyscanner ); |
michael@0 | 656 | |
michael@0 | 657 | /* Macros after this point can all be overridden by user definitions in |
michael@0 | 658 | * section 1. |
michael@0 | 659 | */ |
michael@0 | 660 | |
michael@0 | 661 | #ifndef YY_SKIP_YYWRAP |
michael@0 | 662 | #ifdef __cplusplus |
michael@0 | 663 | extern "C" int ppwrap (yyscan_t yyscanner ); |
michael@0 | 664 | #else |
michael@0 | 665 | extern int ppwrap (yyscan_t yyscanner ); |
michael@0 | 666 | #endif |
michael@0 | 667 | #endif |
michael@0 | 668 | |
michael@0 | 669 | #ifndef yytext_ptr |
michael@0 | 670 | static void yy_flex_strncpy (char *,yyconst char *,int ,yyscan_t yyscanner); |
michael@0 | 671 | #endif |
michael@0 | 672 | |
michael@0 | 673 | #ifdef YY_NEED_STRLEN |
michael@0 | 674 | static int yy_flex_strlen (yyconst char * ,yyscan_t yyscanner); |
michael@0 | 675 | #endif |
michael@0 | 676 | |
michael@0 | 677 | #ifndef YY_NO_INPUT |
michael@0 | 678 | |
michael@0 | 679 | #ifdef __cplusplus |
michael@0 | 680 | static int yyinput (yyscan_t yyscanner ); |
michael@0 | 681 | #else |
michael@0 | 682 | static int input (yyscan_t yyscanner ); |
michael@0 | 683 | #endif |
michael@0 | 684 | |
michael@0 | 685 | #endif |
michael@0 | 686 | |
michael@0 | 687 | /* Amount of stuff to slurp up with each read. */ |
michael@0 | 688 | #ifndef YY_READ_BUF_SIZE |
michael@0 | 689 | #define YY_READ_BUF_SIZE 8192 |
michael@0 | 690 | #endif |
michael@0 | 691 | |
michael@0 | 692 | /* Copy whatever the last rule matched to the standard output. */ |
michael@0 | 693 | #ifndef ECHO |
michael@0 | 694 | /* This used to be an fputs(), but since the string might contain NUL's, |
michael@0 | 695 | * we now use fwrite(). |
michael@0 | 696 | */ |
michael@0 | 697 | #define ECHO fwrite( yytext, yyleng, 1, yyout ) |
michael@0 | 698 | #endif |
michael@0 | 699 | |
michael@0 | 700 | /* Gets input and stuffs it into "buf". number of characters read, or YY_NULL, |
michael@0 | 701 | * is returned in "result". |
michael@0 | 702 | */ |
michael@0 | 703 | #ifndef YY_INPUT |
michael@0 | 704 | #define YY_INPUT(buf,result,max_size) \ |
michael@0 | 705 | if ( YY_CURRENT_BUFFER_LVALUE->yy_is_interactive ) \ |
michael@0 | 706 | { \ |
michael@0 | 707 | int c = '*'; \ |
michael@0 | 708 | yy_size_t n; \ |
michael@0 | 709 | for ( n = 0; n < max_size && \ |
michael@0 | 710 | (c = getc( yyin )) != EOF && c != '\n'; ++n ) \ |
michael@0 | 711 | buf[n] = (char) c; \ |
michael@0 | 712 | if ( c == '\n' ) \ |
michael@0 | 713 | buf[n++] = (char) c; \ |
michael@0 | 714 | if ( c == EOF && ferror( yyin ) ) \ |
michael@0 | 715 | YY_FATAL_ERROR( "input in flex scanner failed" ); \ |
michael@0 | 716 | result = n; \ |
michael@0 | 717 | } \ |
michael@0 | 718 | else \ |
michael@0 | 719 | { \ |
michael@0 | 720 | errno=0; \ |
michael@0 | 721 | while ( (result = fread(buf, 1, max_size, yyin))==0 && ferror(yyin)) \ |
michael@0 | 722 | { \ |
michael@0 | 723 | if( errno != EINTR) \ |
michael@0 | 724 | { \ |
michael@0 | 725 | YY_FATAL_ERROR( "input in flex scanner failed" ); \ |
michael@0 | 726 | break; \ |
michael@0 | 727 | } \ |
michael@0 | 728 | errno=0; \ |
michael@0 | 729 | clearerr(yyin); \ |
michael@0 | 730 | } \ |
michael@0 | 731 | }\ |
michael@0 | 732 | \ |
michael@0 | 733 | |
michael@0 | 734 | #endif |
michael@0 | 735 | |
michael@0 | 736 | /* No semi-colon after return; correct usage is to write "yyterminate();" - |
michael@0 | 737 | * we don't want an extra ';' after the "return" because that will cause |
michael@0 | 738 | * some compilers to complain about unreachable statements. |
michael@0 | 739 | */ |
michael@0 | 740 | #ifndef yyterminate |
michael@0 | 741 | #define yyterminate() return YY_NULL |
michael@0 | 742 | #endif |
michael@0 | 743 | |
michael@0 | 744 | /* Number of entries by which start-condition stack grows. */ |
michael@0 | 745 | #ifndef YY_START_STACK_INCR |
michael@0 | 746 | #define YY_START_STACK_INCR 25 |
michael@0 | 747 | #endif |
michael@0 | 748 | |
michael@0 | 749 | /* Report a fatal error. */ |
michael@0 | 750 | #ifndef YY_FATAL_ERROR |
michael@0 | 751 | #define YY_FATAL_ERROR(msg) yy_fatal_error( msg , yyscanner) |
michael@0 | 752 | #endif |
michael@0 | 753 | |
michael@0 | 754 | /* end tables serialization structures and prototypes */ |
michael@0 | 755 | |
michael@0 | 756 | /* Default declaration of generated scanner - a define so the user can |
michael@0 | 757 | * easily add parameters. |
michael@0 | 758 | */ |
michael@0 | 759 | #ifndef YY_DECL |
michael@0 | 760 | #define YY_DECL_IS_OURS 1 |
michael@0 | 761 | |
michael@0 | 762 | extern int pplex \ |
michael@0 | 763 | (YYSTYPE * yylval_param,YYLTYPE * yylloc_param ,yyscan_t yyscanner); |
michael@0 | 764 | |
michael@0 | 765 | #define YY_DECL int pplex \ |
michael@0 | 766 | (YYSTYPE * yylval_param, YYLTYPE * yylloc_param , yyscan_t yyscanner) |
michael@0 | 767 | #endif /* !YY_DECL */ |
michael@0 | 768 | |
michael@0 | 769 | /* Code executed at the beginning of each rule, after yytext and yyleng |
michael@0 | 770 | * have been set up. |
michael@0 | 771 | */ |
michael@0 | 772 | #ifndef YY_USER_ACTION |
michael@0 | 773 | #define YY_USER_ACTION |
michael@0 | 774 | #endif |
michael@0 | 775 | |
michael@0 | 776 | /* Code executed at the end of each rule. */ |
michael@0 | 777 | #ifndef YY_BREAK |
michael@0 | 778 | #define YY_BREAK break; |
michael@0 | 779 | #endif |
michael@0 | 780 | |
michael@0 | 781 | #define YY_RULE_SETUP \ |
michael@0 | 782 | YY_USER_ACTION |
michael@0 | 783 | |
michael@0 | 784 | /** The main scanner function which does all the work. |
michael@0 | 785 | */ |
michael@0 | 786 | YY_DECL |
michael@0 | 787 | { |
michael@0 | 788 | register yy_state_type yy_current_state; |
michael@0 | 789 | register char *yy_cp, *yy_bp; |
michael@0 | 790 | register int yy_act; |
michael@0 | 791 | struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; |
michael@0 | 792 | |
michael@0 | 793 | /* Line comment */ |
michael@0 | 794 | |
michael@0 | 795 | yylval = yylval_param; |
michael@0 | 796 | |
michael@0 | 797 | yylloc = yylloc_param; |
michael@0 | 798 | |
michael@0 | 799 | if ( !yyg->yy_init ) |
michael@0 | 800 | { |
michael@0 | 801 | yyg->yy_init = 1; |
michael@0 | 802 | |
michael@0 | 803 | #ifdef YY_USER_INIT |
michael@0 | 804 | YY_USER_INIT; |
michael@0 | 805 | #endif |
michael@0 | 806 | |
michael@0 | 807 | if ( ! yyg->yy_start ) |
michael@0 | 808 | yyg->yy_start = 1; /* first start state */ |
michael@0 | 809 | |
michael@0 | 810 | if ( ! yyin ) |
michael@0 | 811 | yyin = stdin; |
michael@0 | 812 | |
michael@0 | 813 | if ( ! yyout ) |
michael@0 | 814 | yyout = stdout; |
michael@0 | 815 | |
michael@0 | 816 | if ( ! YY_CURRENT_BUFFER ) { |
michael@0 | 817 | ppensure_buffer_stack (yyscanner); |
michael@0 | 818 | YY_CURRENT_BUFFER_LVALUE = |
michael@0 | 819 | pp_create_buffer(yyin,YY_BUF_SIZE ,yyscanner); |
michael@0 | 820 | } |
michael@0 | 821 | |
michael@0 | 822 | pp_load_buffer_state(yyscanner ); |
michael@0 | 823 | } |
michael@0 | 824 | |
michael@0 | 825 | while ( 1 ) /* loops until end-of-file is reached */ |
michael@0 | 826 | { |
michael@0 | 827 | yy_cp = yyg->yy_c_buf_p; |
michael@0 | 828 | |
michael@0 | 829 | /* Support of yytext. */ |
michael@0 | 830 | *yy_cp = yyg->yy_hold_char; |
michael@0 | 831 | |
michael@0 | 832 | /* yy_bp points to the position in yy_ch_buf of the start of |
michael@0 | 833 | * the current run. |
michael@0 | 834 | */ |
michael@0 | 835 | yy_bp = yy_cp; |
michael@0 | 836 | |
michael@0 | 837 | yy_current_state = yyg->yy_start; |
michael@0 | 838 | yy_match: |
michael@0 | 839 | do |
michael@0 | 840 | { |
michael@0 | 841 | register YY_CHAR yy_c = yy_ec[YY_SC_TO_UI(*yy_cp)]; |
michael@0 | 842 | if ( yy_accept[yy_current_state] ) |
michael@0 | 843 | { |
michael@0 | 844 | yyg->yy_last_accepting_state = yy_current_state; |
michael@0 | 845 | yyg->yy_last_accepting_cpos = yy_cp; |
michael@0 | 846 | } |
michael@0 | 847 | while ( yy_chk[yy_base[yy_current_state] + yy_c] != yy_current_state ) |
michael@0 | 848 | { |
michael@0 | 849 | yy_current_state = (int) yy_def[yy_current_state]; |
michael@0 | 850 | if ( yy_current_state >= 87 ) |
michael@0 | 851 | yy_c = yy_meta[(unsigned int) yy_c]; |
michael@0 | 852 | } |
michael@0 | 853 | yy_current_state = yy_nxt[yy_base[yy_current_state] + (unsigned int) yy_c]; |
michael@0 | 854 | ++yy_cp; |
michael@0 | 855 | } |
michael@0 | 856 | while ( yy_current_state != 86 ); |
michael@0 | 857 | yy_cp = yyg->yy_last_accepting_cpos; |
michael@0 | 858 | yy_current_state = yyg->yy_last_accepting_state; |
michael@0 | 859 | |
michael@0 | 860 | yy_find_action: |
michael@0 | 861 | yy_act = yy_accept[yy_current_state]; |
michael@0 | 862 | |
michael@0 | 863 | YY_DO_BEFORE_ACTION; |
michael@0 | 864 | |
michael@0 | 865 | do_action: /* This label is used only to access EOF actions. */ |
michael@0 | 866 | |
michael@0 | 867 | switch ( yy_act ) |
michael@0 | 868 | { /* beginning of action switch */ |
michael@0 | 869 | case 0: /* must back up */ |
michael@0 | 870 | /* undo the effects of YY_DO_BEFORE_ACTION */ |
michael@0 | 871 | *yy_cp = yyg->yy_hold_char; |
michael@0 | 872 | yy_cp = yyg->yy_last_accepting_cpos; |
michael@0 | 873 | yy_current_state = yyg->yy_last_accepting_state; |
michael@0 | 874 | goto yy_find_action; |
michael@0 | 875 | |
michael@0 | 876 | case 1: |
michael@0 | 877 | YY_RULE_SETUP |
michael@0 | 878 | |
michael@0 | 879 | YY_BREAK |
michael@0 | 880 | /* Block comment */ |
michael@0 | 881 | /* Line breaks are just counted - not returned. */ |
michael@0 | 882 | /* The comment is replaced by a single space. */ |
michael@0 | 883 | case 2: |
michael@0 | 884 | YY_RULE_SETUP |
michael@0 | 885 | { BEGIN(COMMENT); } |
michael@0 | 886 | YY_BREAK |
michael@0 | 887 | case 3: |
michael@0 | 888 | YY_RULE_SETUP |
michael@0 | 889 | |
michael@0 | 890 | YY_BREAK |
michael@0 | 891 | case 4: |
michael@0 | 892 | YY_RULE_SETUP |
michael@0 | 893 | |
michael@0 | 894 | YY_BREAK |
michael@0 | 895 | case 5: |
michael@0 | 896 | /* rule 5 can match eol */ |
michael@0 | 897 | YY_RULE_SETUP |
michael@0 | 898 | { ++yylineno; } |
michael@0 | 899 | YY_BREAK |
michael@0 | 900 | case 6: |
michael@0 | 901 | YY_RULE_SETUP |
michael@0 | 902 | { |
michael@0 | 903 | yyextra->leadingSpace = true; |
michael@0 | 904 | BEGIN(INITIAL); |
michael@0 | 905 | } |
michael@0 | 906 | YY_BREAK |
michael@0 | 907 | case 7: |
michael@0 | 908 | YY_RULE_SETUP |
michael@0 | 909 | { |
michael@0 | 910 | // # is only valid at start of line for preprocessor directives. |
michael@0 | 911 | yylval->assign(1, yytext[0]); |
michael@0 | 912 | return yyextra->lineStart ? pp::Token::PP_HASH : pp::Token::PP_OTHER; |
michael@0 | 913 | } |
michael@0 | 914 | YY_BREAK |
michael@0 | 915 | case 8: |
michael@0 | 916 | YY_RULE_SETUP |
michael@0 | 917 | { |
michael@0 | 918 | yylval->assign(yytext, yyleng); |
michael@0 | 919 | return pp::Token::IDENTIFIER; |
michael@0 | 920 | } |
michael@0 | 921 | YY_BREAK |
michael@0 | 922 | case 9: |
michael@0 | 923 | YY_RULE_SETUP |
michael@0 | 924 | { |
michael@0 | 925 | yylval->assign(yytext, yyleng); |
michael@0 | 926 | return pp::Token::CONST_INT; |
michael@0 | 927 | } |
michael@0 | 928 | YY_BREAK |
michael@0 | 929 | case 10: |
michael@0 | 930 | YY_RULE_SETUP |
michael@0 | 931 | { |
michael@0 | 932 | yylval->assign(yytext, yyleng); |
michael@0 | 933 | return pp::Token::CONST_FLOAT; |
michael@0 | 934 | } |
michael@0 | 935 | YY_BREAK |
michael@0 | 936 | /* Anything that starts with a {DIGIT} or .{DIGIT} must be a number. */ |
michael@0 | 937 | /* Rule to catch all invalid integers and floats. */ |
michael@0 | 938 | case 11: |
michael@0 | 939 | YY_RULE_SETUP |
michael@0 | 940 | { |
michael@0 | 941 | yylval->assign(yytext, yyleng); |
michael@0 | 942 | return pp::Token::PP_NUMBER; |
michael@0 | 943 | } |
michael@0 | 944 | YY_BREAK |
michael@0 | 945 | case 12: |
michael@0 | 946 | YY_RULE_SETUP |
michael@0 | 947 | { |
michael@0 | 948 | yylval->assign(yytext, yyleng); |
michael@0 | 949 | return pp::Token::OP_INC; |
michael@0 | 950 | } |
michael@0 | 951 | YY_BREAK |
michael@0 | 952 | case 13: |
michael@0 | 953 | YY_RULE_SETUP |
michael@0 | 954 | { |
michael@0 | 955 | yylval->assign(yytext, yyleng); |
michael@0 | 956 | return pp::Token::OP_DEC; |
michael@0 | 957 | } |
michael@0 | 958 | YY_BREAK |
michael@0 | 959 | case 14: |
michael@0 | 960 | YY_RULE_SETUP |
michael@0 | 961 | { |
michael@0 | 962 | yylval->assign(yytext, yyleng); |
michael@0 | 963 | return pp::Token::OP_LEFT; |
michael@0 | 964 | } |
michael@0 | 965 | YY_BREAK |
michael@0 | 966 | case 15: |
michael@0 | 967 | YY_RULE_SETUP |
michael@0 | 968 | { |
michael@0 | 969 | yylval->assign(yytext, yyleng); |
michael@0 | 970 | return pp::Token::OP_RIGHT; |
michael@0 | 971 | } |
michael@0 | 972 | YY_BREAK |
michael@0 | 973 | case 16: |
michael@0 | 974 | YY_RULE_SETUP |
michael@0 | 975 | { |
michael@0 | 976 | yylval->assign(yytext, yyleng); |
michael@0 | 977 | return pp::Token::OP_LE; |
michael@0 | 978 | } |
michael@0 | 979 | YY_BREAK |
michael@0 | 980 | case 17: |
michael@0 | 981 | YY_RULE_SETUP |
michael@0 | 982 | { |
michael@0 | 983 | yylval->assign(yytext, yyleng); |
michael@0 | 984 | return pp::Token::OP_GE; |
michael@0 | 985 | } |
michael@0 | 986 | YY_BREAK |
michael@0 | 987 | case 18: |
michael@0 | 988 | YY_RULE_SETUP |
michael@0 | 989 | { |
michael@0 | 990 | yylval->assign(yytext, yyleng); |
michael@0 | 991 | return pp::Token::OP_EQ; |
michael@0 | 992 | } |
michael@0 | 993 | YY_BREAK |
michael@0 | 994 | case 19: |
michael@0 | 995 | YY_RULE_SETUP |
michael@0 | 996 | { |
michael@0 | 997 | yylval->assign(yytext, yyleng); |
michael@0 | 998 | return pp::Token::OP_NE; |
michael@0 | 999 | } |
michael@0 | 1000 | YY_BREAK |
michael@0 | 1001 | case 20: |
michael@0 | 1002 | YY_RULE_SETUP |
michael@0 | 1003 | { |
michael@0 | 1004 | yylval->assign(yytext, yyleng); |
michael@0 | 1005 | return pp::Token::OP_AND; |
michael@0 | 1006 | } |
michael@0 | 1007 | YY_BREAK |
michael@0 | 1008 | case 21: |
michael@0 | 1009 | YY_RULE_SETUP |
michael@0 | 1010 | { |
michael@0 | 1011 | yylval->assign(yytext, yyleng); |
michael@0 | 1012 | return pp::Token::OP_XOR; |
michael@0 | 1013 | } |
michael@0 | 1014 | YY_BREAK |
michael@0 | 1015 | case 22: |
michael@0 | 1016 | YY_RULE_SETUP |
michael@0 | 1017 | { |
michael@0 | 1018 | yylval->assign(yytext, yyleng); |
michael@0 | 1019 | return pp::Token::OP_OR; |
michael@0 | 1020 | } |
michael@0 | 1021 | YY_BREAK |
michael@0 | 1022 | case 23: |
michael@0 | 1023 | YY_RULE_SETUP |
michael@0 | 1024 | { |
michael@0 | 1025 | yylval->assign(yytext, yyleng); |
michael@0 | 1026 | return pp::Token::OP_ADD_ASSIGN; |
michael@0 | 1027 | } |
michael@0 | 1028 | YY_BREAK |
michael@0 | 1029 | case 24: |
michael@0 | 1030 | YY_RULE_SETUP |
michael@0 | 1031 | { |
michael@0 | 1032 | yylval->assign(yytext, yyleng); |
michael@0 | 1033 | return pp::Token::OP_SUB_ASSIGN; |
michael@0 | 1034 | } |
michael@0 | 1035 | YY_BREAK |
michael@0 | 1036 | case 25: |
michael@0 | 1037 | YY_RULE_SETUP |
michael@0 | 1038 | { |
michael@0 | 1039 | yylval->assign(yytext, yyleng); |
michael@0 | 1040 | return pp::Token::OP_MUL_ASSIGN; |
michael@0 | 1041 | } |
michael@0 | 1042 | YY_BREAK |
michael@0 | 1043 | case 26: |
michael@0 | 1044 | YY_RULE_SETUP |
michael@0 | 1045 | { |
michael@0 | 1046 | yylval->assign(yytext, yyleng); |
michael@0 | 1047 | return pp::Token::OP_DIV_ASSIGN; |
michael@0 | 1048 | } |
michael@0 | 1049 | YY_BREAK |
michael@0 | 1050 | case 27: |
michael@0 | 1051 | YY_RULE_SETUP |
michael@0 | 1052 | { |
michael@0 | 1053 | yylval->assign(yytext, yyleng); |
michael@0 | 1054 | return pp::Token::OP_MOD_ASSIGN; |
michael@0 | 1055 | } |
michael@0 | 1056 | YY_BREAK |
michael@0 | 1057 | case 28: |
michael@0 | 1058 | YY_RULE_SETUP |
michael@0 | 1059 | { |
michael@0 | 1060 | yylval->assign(yytext, yyleng); |
michael@0 | 1061 | return pp::Token::OP_LEFT_ASSIGN; |
michael@0 | 1062 | } |
michael@0 | 1063 | YY_BREAK |
michael@0 | 1064 | case 29: |
michael@0 | 1065 | YY_RULE_SETUP |
michael@0 | 1066 | { |
michael@0 | 1067 | yylval->assign(yytext, yyleng); |
michael@0 | 1068 | return pp::Token::OP_RIGHT_ASSIGN; |
michael@0 | 1069 | } |
michael@0 | 1070 | YY_BREAK |
michael@0 | 1071 | case 30: |
michael@0 | 1072 | YY_RULE_SETUP |
michael@0 | 1073 | { |
michael@0 | 1074 | yylval->assign(yytext, yyleng); |
michael@0 | 1075 | return pp::Token::OP_AND_ASSIGN; |
michael@0 | 1076 | } |
michael@0 | 1077 | YY_BREAK |
michael@0 | 1078 | case 31: |
michael@0 | 1079 | YY_RULE_SETUP |
michael@0 | 1080 | { |
michael@0 | 1081 | yylval->assign(yytext, yyleng); |
michael@0 | 1082 | return pp::Token::OP_XOR_ASSIGN; |
michael@0 | 1083 | } |
michael@0 | 1084 | YY_BREAK |
michael@0 | 1085 | case 32: |
michael@0 | 1086 | YY_RULE_SETUP |
michael@0 | 1087 | { |
michael@0 | 1088 | yylval->assign(yytext, yyleng); |
michael@0 | 1089 | return pp::Token::OP_OR_ASSIGN; |
michael@0 | 1090 | } |
michael@0 | 1091 | YY_BREAK |
michael@0 | 1092 | case 33: |
michael@0 | 1093 | YY_RULE_SETUP |
michael@0 | 1094 | { |
michael@0 | 1095 | yylval->assign(1, yytext[0]); |
michael@0 | 1096 | return yytext[0]; |
michael@0 | 1097 | } |
michael@0 | 1098 | YY_BREAK |
michael@0 | 1099 | case 34: |
michael@0 | 1100 | YY_RULE_SETUP |
michael@0 | 1101 | { yyextra->leadingSpace = true; } |
michael@0 | 1102 | YY_BREAK |
michael@0 | 1103 | case 35: |
michael@0 | 1104 | /* rule 35 can match eol */ |
michael@0 | 1105 | YY_RULE_SETUP |
michael@0 | 1106 | { |
michael@0 | 1107 | ++yylineno; |
michael@0 | 1108 | yylval->assign(1, '\n'); |
michael@0 | 1109 | return '\n'; |
michael@0 | 1110 | } |
michael@0 | 1111 | YY_BREAK |
michael@0 | 1112 | case 36: |
michael@0 | 1113 | /* rule 36 can match eol */ |
michael@0 | 1114 | YY_RULE_SETUP |
michael@0 | 1115 | { ++yylineno; } |
michael@0 | 1116 | YY_BREAK |
michael@0 | 1117 | case 37: |
michael@0 | 1118 | YY_RULE_SETUP |
michael@0 | 1119 | { |
michael@0 | 1120 | yylval->assign(1, yytext[0]); |
michael@0 | 1121 | return pp::Token::PP_OTHER; |
michael@0 | 1122 | } |
michael@0 | 1123 | YY_BREAK |
michael@0 | 1124 | case YY_STATE_EOF(INITIAL): |
michael@0 | 1125 | case YY_STATE_EOF(COMMENT): |
michael@0 | 1126 | { |
michael@0 | 1127 | // YY_USER_ACTION is not invoked for handling EOF. |
michael@0 | 1128 | // Set the location for EOF token manually. |
michael@0 | 1129 | pp::Input* input = &yyextra->input; |
michael@0 | 1130 | pp::Input::Location* scanLoc = &yyextra->scanLoc; |
michael@0 | 1131 | yy_size_t sIndexMax = input->count() ? input->count() - 1 : 0; |
michael@0 | 1132 | if (scanLoc->sIndex != sIndexMax) |
michael@0 | 1133 | { |
michael@0 | 1134 | // We can only reach here if there are empty strings at the |
michael@0 | 1135 | // end of the input. |
michael@0 | 1136 | scanLoc->sIndex = sIndexMax; scanLoc->cIndex = 0; |
michael@0 | 1137 | // FIXME: this is not 64-bit clean. |
michael@0 | 1138 | yyfileno = static_cast<int>(sIndexMax); yylineno = 1; |
michael@0 | 1139 | } |
michael@0 | 1140 | yylloc->file = yyfileno; |
michael@0 | 1141 | yylloc->line = yylineno; |
michael@0 | 1142 | yylval->clear(); |
michael@0 | 1143 | |
michael@0 | 1144 | if (YY_START == COMMENT) |
michael@0 | 1145 | { |
michael@0 | 1146 | yyextra->diagnostics->report(pp::Diagnostics::EOF_IN_COMMENT, |
michael@0 | 1147 | pp::SourceLocation(yyfileno, yylineno), |
michael@0 | 1148 | ""); |
michael@0 | 1149 | } |
michael@0 | 1150 | yyterminate(); |
michael@0 | 1151 | } |
michael@0 | 1152 | YY_BREAK |
michael@0 | 1153 | case 38: |
michael@0 | 1154 | YY_RULE_SETUP |
michael@0 | 1155 | ECHO; |
michael@0 | 1156 | YY_BREAK |
michael@0 | 1157 | |
michael@0 | 1158 | case YY_END_OF_BUFFER: |
michael@0 | 1159 | { |
michael@0 | 1160 | /* Amount of text matched not including the EOB char. */ |
michael@0 | 1161 | int yy_amount_of_matched_text = (int) (yy_cp - yyg->yytext_ptr) - 1; |
michael@0 | 1162 | |
michael@0 | 1163 | /* Undo the effects of YY_DO_BEFORE_ACTION. */ |
michael@0 | 1164 | *yy_cp = yyg->yy_hold_char; |
michael@0 | 1165 | YY_RESTORE_YY_MORE_OFFSET |
michael@0 | 1166 | |
michael@0 | 1167 | if ( YY_CURRENT_BUFFER_LVALUE->yy_buffer_status == YY_BUFFER_NEW ) |
michael@0 | 1168 | { |
michael@0 | 1169 | /* We're scanning a new file or input source. It's |
michael@0 | 1170 | * possible that this happened because the user |
michael@0 | 1171 | * just pointed yyin at a new source and called |
michael@0 | 1172 | * pplex(). If so, then we have to assure |
michael@0 | 1173 | * consistency between YY_CURRENT_BUFFER and our |
michael@0 | 1174 | * globals. Here is the right place to do so, because |
michael@0 | 1175 | * this is the first action (other than possibly a |
michael@0 | 1176 | * back-up) that will match for the new input source. |
michael@0 | 1177 | */ |
michael@0 | 1178 | yyg->yy_n_chars = YY_CURRENT_BUFFER_LVALUE->yy_n_chars; |
michael@0 | 1179 | YY_CURRENT_BUFFER_LVALUE->yy_input_file = yyin; |
michael@0 | 1180 | YY_CURRENT_BUFFER_LVALUE->yy_buffer_status = YY_BUFFER_NORMAL; |
michael@0 | 1181 | } |
michael@0 | 1182 | |
michael@0 | 1183 | /* Note that here we test for yy_c_buf_p "<=" to the position |
michael@0 | 1184 | * of the first EOB in the buffer, since yy_c_buf_p will |
michael@0 | 1185 | * already have been incremented past the NUL character |
michael@0 | 1186 | * (since all states make transitions on EOB to the |
michael@0 | 1187 | * end-of-buffer state). Contrast this with the test |
michael@0 | 1188 | * in input(). |
michael@0 | 1189 | */ |
michael@0 | 1190 | if ( yyg->yy_c_buf_p <= &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[yyg->yy_n_chars] ) |
michael@0 | 1191 | { /* This was really a NUL. */ |
michael@0 | 1192 | yy_state_type yy_next_state; |
michael@0 | 1193 | |
michael@0 | 1194 | yyg->yy_c_buf_p = yyg->yytext_ptr + yy_amount_of_matched_text; |
michael@0 | 1195 | |
michael@0 | 1196 | yy_current_state = yy_get_previous_state( yyscanner ); |
michael@0 | 1197 | |
michael@0 | 1198 | /* Okay, we're now positioned to make the NUL |
michael@0 | 1199 | * transition. We couldn't have |
michael@0 | 1200 | * yy_get_previous_state() go ahead and do it |
michael@0 | 1201 | * for us because it doesn't know how to deal |
michael@0 | 1202 | * with the possibility of jamming (and we don't |
michael@0 | 1203 | * want to build jamming into it because then it |
michael@0 | 1204 | * will run more slowly). |
michael@0 | 1205 | */ |
michael@0 | 1206 | |
michael@0 | 1207 | yy_next_state = yy_try_NUL_trans( yy_current_state , yyscanner); |
michael@0 | 1208 | |
michael@0 | 1209 | yy_bp = yyg->yytext_ptr + YY_MORE_ADJ; |
michael@0 | 1210 | |
michael@0 | 1211 | if ( yy_next_state ) |
michael@0 | 1212 | { |
michael@0 | 1213 | /* Consume the NUL. */ |
michael@0 | 1214 | yy_cp = ++yyg->yy_c_buf_p; |
michael@0 | 1215 | yy_current_state = yy_next_state; |
michael@0 | 1216 | goto yy_match; |
michael@0 | 1217 | } |
michael@0 | 1218 | |
michael@0 | 1219 | else |
michael@0 | 1220 | { |
michael@0 | 1221 | yy_cp = yyg->yy_last_accepting_cpos; |
michael@0 | 1222 | yy_current_state = yyg->yy_last_accepting_state; |
michael@0 | 1223 | goto yy_find_action; |
michael@0 | 1224 | } |
michael@0 | 1225 | } |
michael@0 | 1226 | |
michael@0 | 1227 | else switch ( yy_get_next_buffer( yyscanner ) ) |
michael@0 | 1228 | { |
michael@0 | 1229 | case EOB_ACT_END_OF_FILE: |
michael@0 | 1230 | { |
michael@0 | 1231 | yyg->yy_did_buffer_switch_on_eof = 0; |
michael@0 | 1232 | |
michael@0 | 1233 | if ( ppwrap(yyscanner ) ) |
michael@0 | 1234 | { |
michael@0 | 1235 | /* Note: because we've taken care in |
michael@0 | 1236 | * yy_get_next_buffer() to have set up |
michael@0 | 1237 | * yytext, we can now set up |
michael@0 | 1238 | * yy_c_buf_p so that if some total |
michael@0 | 1239 | * hoser (like flex itself) wants to |
michael@0 | 1240 | * call the scanner after we return the |
michael@0 | 1241 | * YY_NULL, it'll still work - another |
michael@0 | 1242 | * YY_NULL will get returned. |
michael@0 | 1243 | */ |
michael@0 | 1244 | yyg->yy_c_buf_p = yyg->yytext_ptr + YY_MORE_ADJ; |
michael@0 | 1245 | |
michael@0 | 1246 | yy_act = YY_STATE_EOF(YY_START); |
michael@0 | 1247 | goto do_action; |
michael@0 | 1248 | } |
michael@0 | 1249 | |
michael@0 | 1250 | else |
michael@0 | 1251 | { |
michael@0 | 1252 | if ( ! yyg->yy_did_buffer_switch_on_eof ) |
michael@0 | 1253 | YY_NEW_FILE; |
michael@0 | 1254 | } |
michael@0 | 1255 | break; |
michael@0 | 1256 | } |
michael@0 | 1257 | |
michael@0 | 1258 | case EOB_ACT_CONTINUE_SCAN: |
michael@0 | 1259 | yyg->yy_c_buf_p = |
michael@0 | 1260 | yyg->yytext_ptr + yy_amount_of_matched_text; |
michael@0 | 1261 | |
michael@0 | 1262 | yy_current_state = yy_get_previous_state( yyscanner ); |
michael@0 | 1263 | |
michael@0 | 1264 | yy_cp = yyg->yy_c_buf_p; |
michael@0 | 1265 | yy_bp = yyg->yytext_ptr + YY_MORE_ADJ; |
michael@0 | 1266 | goto yy_match; |
michael@0 | 1267 | |
michael@0 | 1268 | case EOB_ACT_LAST_MATCH: |
michael@0 | 1269 | yyg->yy_c_buf_p = |
michael@0 | 1270 | &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[yyg->yy_n_chars]; |
michael@0 | 1271 | |
michael@0 | 1272 | yy_current_state = yy_get_previous_state( yyscanner ); |
michael@0 | 1273 | |
michael@0 | 1274 | yy_cp = yyg->yy_c_buf_p; |
michael@0 | 1275 | yy_bp = yyg->yytext_ptr + YY_MORE_ADJ; |
michael@0 | 1276 | goto yy_find_action; |
michael@0 | 1277 | } |
michael@0 | 1278 | break; |
michael@0 | 1279 | } |
michael@0 | 1280 | |
michael@0 | 1281 | default: |
michael@0 | 1282 | YY_FATAL_ERROR( |
michael@0 | 1283 | "fatal flex scanner internal error--no action found" ); |
michael@0 | 1284 | } /* end of action switch */ |
michael@0 | 1285 | } /* end of scanning one token */ |
michael@0 | 1286 | } /* end of pplex */ |
michael@0 | 1287 | |
michael@0 | 1288 | /* yy_get_next_buffer - try to read in a new buffer |
michael@0 | 1289 | * |
michael@0 | 1290 | * Returns a code representing an action: |
michael@0 | 1291 | * EOB_ACT_LAST_MATCH - |
michael@0 | 1292 | * EOB_ACT_CONTINUE_SCAN - continue scanning from current position |
michael@0 | 1293 | * EOB_ACT_END_OF_FILE - end of file |
michael@0 | 1294 | */ |
michael@0 | 1295 | static int yy_get_next_buffer (yyscan_t yyscanner) |
michael@0 | 1296 | { |
michael@0 | 1297 | struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; |
michael@0 | 1298 | register char *dest = YY_CURRENT_BUFFER_LVALUE->yy_ch_buf; |
michael@0 | 1299 | register char *source = yyg->yytext_ptr; |
michael@0 | 1300 | register int number_to_move, i; |
michael@0 | 1301 | int ret_val; |
michael@0 | 1302 | |
michael@0 | 1303 | if ( yyg->yy_c_buf_p > &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[yyg->yy_n_chars + 1] ) |
michael@0 | 1304 | YY_FATAL_ERROR( |
michael@0 | 1305 | "fatal flex scanner internal error--end of buffer missed" ); |
michael@0 | 1306 | |
michael@0 | 1307 | if ( YY_CURRENT_BUFFER_LVALUE->yy_fill_buffer == 0 ) |
michael@0 | 1308 | { /* Don't try to fill the buffer, so this is an EOF. */ |
michael@0 | 1309 | if ( yyg->yy_c_buf_p - yyg->yytext_ptr - YY_MORE_ADJ == 1 ) |
michael@0 | 1310 | { |
michael@0 | 1311 | /* We matched a single character, the EOB, so |
michael@0 | 1312 | * treat this as a final EOF. |
michael@0 | 1313 | */ |
michael@0 | 1314 | return EOB_ACT_END_OF_FILE; |
michael@0 | 1315 | } |
michael@0 | 1316 | |
michael@0 | 1317 | else |
michael@0 | 1318 | { |
michael@0 | 1319 | /* We matched some text prior to the EOB, first |
michael@0 | 1320 | * process it. |
michael@0 | 1321 | */ |
michael@0 | 1322 | return EOB_ACT_LAST_MATCH; |
michael@0 | 1323 | } |
michael@0 | 1324 | } |
michael@0 | 1325 | |
michael@0 | 1326 | /* Try to read more data. */ |
michael@0 | 1327 | |
michael@0 | 1328 | /* First move last chars to start of buffer. */ |
michael@0 | 1329 | number_to_move = (int) (yyg->yy_c_buf_p - yyg->yytext_ptr) - 1; |
michael@0 | 1330 | |
michael@0 | 1331 | for ( i = 0; i < number_to_move; ++i ) |
michael@0 | 1332 | *(dest++) = *(source++); |
michael@0 | 1333 | |
michael@0 | 1334 | if ( YY_CURRENT_BUFFER_LVALUE->yy_buffer_status == YY_BUFFER_EOF_PENDING ) |
michael@0 | 1335 | /* don't do the read, it's not guaranteed to return an EOF, |
michael@0 | 1336 | * just force an EOF |
michael@0 | 1337 | */ |
michael@0 | 1338 | YY_CURRENT_BUFFER_LVALUE->yy_n_chars = yyg->yy_n_chars = 0; |
michael@0 | 1339 | |
michael@0 | 1340 | else |
michael@0 | 1341 | { |
michael@0 | 1342 | yy_size_t num_to_read = |
michael@0 | 1343 | YY_CURRENT_BUFFER_LVALUE->yy_buf_size - number_to_move - 1; |
michael@0 | 1344 | |
michael@0 | 1345 | while ( num_to_read <= 0 ) |
michael@0 | 1346 | { /* Not enough room in the buffer - grow it. */ |
michael@0 | 1347 | |
michael@0 | 1348 | /* just a shorter name for the current buffer */ |
michael@0 | 1349 | YY_BUFFER_STATE b = YY_CURRENT_BUFFER; |
michael@0 | 1350 | |
michael@0 | 1351 | int yy_c_buf_p_offset = |
michael@0 | 1352 | (int) (yyg->yy_c_buf_p - b->yy_ch_buf); |
michael@0 | 1353 | |
michael@0 | 1354 | if ( b->yy_is_our_buffer ) |
michael@0 | 1355 | { |
michael@0 | 1356 | yy_size_t new_size = b->yy_buf_size * 2; |
michael@0 | 1357 | |
michael@0 | 1358 | if ( new_size <= 0 ) |
michael@0 | 1359 | b->yy_buf_size += b->yy_buf_size / 8; |
michael@0 | 1360 | else |
michael@0 | 1361 | b->yy_buf_size *= 2; |
michael@0 | 1362 | |
michael@0 | 1363 | b->yy_ch_buf = (char *) |
michael@0 | 1364 | /* Include room in for 2 EOB chars. */ |
michael@0 | 1365 | pprealloc((void *) b->yy_ch_buf,b->yy_buf_size + 2 ,yyscanner ); |
michael@0 | 1366 | } |
michael@0 | 1367 | else |
michael@0 | 1368 | /* Can't grow it, we don't own it. */ |
michael@0 | 1369 | b->yy_ch_buf = 0; |
michael@0 | 1370 | |
michael@0 | 1371 | if ( ! b->yy_ch_buf ) |
michael@0 | 1372 | YY_FATAL_ERROR( |
michael@0 | 1373 | "fatal error - scanner input buffer overflow" ); |
michael@0 | 1374 | |
michael@0 | 1375 | yyg->yy_c_buf_p = &b->yy_ch_buf[yy_c_buf_p_offset]; |
michael@0 | 1376 | |
michael@0 | 1377 | num_to_read = YY_CURRENT_BUFFER_LVALUE->yy_buf_size - |
michael@0 | 1378 | number_to_move - 1; |
michael@0 | 1379 | |
michael@0 | 1380 | } |
michael@0 | 1381 | |
michael@0 | 1382 | if ( num_to_read > YY_READ_BUF_SIZE ) |
michael@0 | 1383 | num_to_read = YY_READ_BUF_SIZE; |
michael@0 | 1384 | |
michael@0 | 1385 | /* Read in more data. */ |
michael@0 | 1386 | YY_INPUT( (&YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[number_to_move]), |
michael@0 | 1387 | yyg->yy_n_chars, num_to_read ); |
michael@0 | 1388 | |
michael@0 | 1389 | YY_CURRENT_BUFFER_LVALUE->yy_n_chars = yyg->yy_n_chars; |
michael@0 | 1390 | } |
michael@0 | 1391 | |
michael@0 | 1392 | if ( yyg->yy_n_chars == 0 ) |
michael@0 | 1393 | { |
michael@0 | 1394 | if ( number_to_move == YY_MORE_ADJ ) |
michael@0 | 1395 | { |
michael@0 | 1396 | ret_val = EOB_ACT_END_OF_FILE; |
michael@0 | 1397 | pprestart(yyin ,yyscanner); |
michael@0 | 1398 | } |
michael@0 | 1399 | |
michael@0 | 1400 | else |
michael@0 | 1401 | { |
michael@0 | 1402 | ret_val = EOB_ACT_LAST_MATCH; |
michael@0 | 1403 | YY_CURRENT_BUFFER_LVALUE->yy_buffer_status = |
michael@0 | 1404 | YY_BUFFER_EOF_PENDING; |
michael@0 | 1405 | } |
michael@0 | 1406 | } |
michael@0 | 1407 | |
michael@0 | 1408 | else |
michael@0 | 1409 | ret_val = EOB_ACT_CONTINUE_SCAN; |
michael@0 | 1410 | |
michael@0 | 1411 | if ((yy_size_t) (yyg->yy_n_chars + number_to_move) > YY_CURRENT_BUFFER_LVALUE->yy_buf_size) { |
michael@0 | 1412 | /* Extend the array by 50%, plus the number we really need. */ |
michael@0 | 1413 | yy_size_t new_size = yyg->yy_n_chars + number_to_move + (yyg->yy_n_chars >> 1); |
michael@0 | 1414 | YY_CURRENT_BUFFER_LVALUE->yy_ch_buf = (char *) pprealloc((void *) YY_CURRENT_BUFFER_LVALUE->yy_ch_buf,new_size ,yyscanner ); |
michael@0 | 1415 | if ( ! YY_CURRENT_BUFFER_LVALUE->yy_ch_buf ) |
michael@0 | 1416 | YY_FATAL_ERROR( "out of dynamic memory in yy_get_next_buffer()" ); |
michael@0 | 1417 | } |
michael@0 | 1418 | |
michael@0 | 1419 | yyg->yy_n_chars += number_to_move; |
michael@0 | 1420 | YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[yyg->yy_n_chars] = YY_END_OF_BUFFER_CHAR; |
michael@0 | 1421 | YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[yyg->yy_n_chars + 1] = YY_END_OF_BUFFER_CHAR; |
michael@0 | 1422 | |
michael@0 | 1423 | yyg->yytext_ptr = &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[0]; |
michael@0 | 1424 | |
michael@0 | 1425 | return ret_val; |
michael@0 | 1426 | } |
michael@0 | 1427 | |
michael@0 | 1428 | /* yy_get_previous_state - get the state just before the EOB char was reached */ |
michael@0 | 1429 | |
michael@0 | 1430 | static yy_state_type yy_get_previous_state (yyscan_t yyscanner) |
michael@0 | 1431 | { |
michael@0 | 1432 | register yy_state_type yy_current_state; |
michael@0 | 1433 | register char *yy_cp; |
michael@0 | 1434 | struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; |
michael@0 | 1435 | |
michael@0 | 1436 | yy_current_state = yyg->yy_start; |
michael@0 | 1437 | |
michael@0 | 1438 | for ( yy_cp = yyg->yytext_ptr + YY_MORE_ADJ; yy_cp < yyg->yy_c_buf_p; ++yy_cp ) |
michael@0 | 1439 | { |
michael@0 | 1440 | register YY_CHAR yy_c = (*yy_cp ? yy_ec[YY_SC_TO_UI(*yy_cp)] : 1); |
michael@0 | 1441 | if ( yy_accept[yy_current_state] ) |
michael@0 | 1442 | { |
michael@0 | 1443 | yyg->yy_last_accepting_state = yy_current_state; |
michael@0 | 1444 | yyg->yy_last_accepting_cpos = yy_cp; |
michael@0 | 1445 | } |
michael@0 | 1446 | while ( yy_chk[yy_base[yy_current_state] + yy_c] != yy_current_state ) |
michael@0 | 1447 | { |
michael@0 | 1448 | yy_current_state = (int) yy_def[yy_current_state]; |
michael@0 | 1449 | if ( yy_current_state >= 87 ) |
michael@0 | 1450 | yy_c = yy_meta[(unsigned int) yy_c]; |
michael@0 | 1451 | } |
michael@0 | 1452 | yy_current_state = yy_nxt[yy_base[yy_current_state] + (unsigned int) yy_c]; |
michael@0 | 1453 | } |
michael@0 | 1454 | |
michael@0 | 1455 | return yy_current_state; |
michael@0 | 1456 | } |
michael@0 | 1457 | |
michael@0 | 1458 | /* yy_try_NUL_trans - try to make a transition on the NUL character |
michael@0 | 1459 | * |
michael@0 | 1460 | * synopsis |
michael@0 | 1461 | * next_state = yy_try_NUL_trans( current_state ); |
michael@0 | 1462 | */ |
michael@0 | 1463 | static yy_state_type yy_try_NUL_trans (yy_state_type yy_current_state , yyscan_t yyscanner) |
michael@0 | 1464 | { |
michael@0 | 1465 | register int yy_is_jam; |
michael@0 | 1466 | struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; /* This var may be unused depending upon options. */ |
michael@0 | 1467 | register char *yy_cp = yyg->yy_c_buf_p; |
michael@0 | 1468 | |
michael@0 | 1469 | register YY_CHAR yy_c = 1; |
michael@0 | 1470 | if ( yy_accept[yy_current_state] ) |
michael@0 | 1471 | { |
michael@0 | 1472 | yyg->yy_last_accepting_state = yy_current_state; |
michael@0 | 1473 | yyg->yy_last_accepting_cpos = yy_cp; |
michael@0 | 1474 | } |
michael@0 | 1475 | while ( yy_chk[yy_base[yy_current_state] + yy_c] != yy_current_state ) |
michael@0 | 1476 | { |
michael@0 | 1477 | yy_current_state = (int) yy_def[yy_current_state]; |
michael@0 | 1478 | if ( yy_current_state >= 87 ) |
michael@0 | 1479 | yy_c = yy_meta[(unsigned int) yy_c]; |
michael@0 | 1480 | } |
michael@0 | 1481 | yy_current_state = yy_nxt[yy_base[yy_current_state] + (unsigned int) yy_c]; |
michael@0 | 1482 | yy_is_jam = (yy_current_state == 86); |
michael@0 | 1483 | |
michael@0 | 1484 | return yy_is_jam ? 0 : yy_current_state; |
michael@0 | 1485 | } |
michael@0 | 1486 | |
michael@0 | 1487 | #ifndef YY_NO_INPUT |
michael@0 | 1488 | #ifdef __cplusplus |
michael@0 | 1489 | static int yyinput (yyscan_t yyscanner) |
michael@0 | 1490 | #else |
michael@0 | 1491 | static int input (yyscan_t yyscanner) |
michael@0 | 1492 | #endif |
michael@0 | 1493 | |
michael@0 | 1494 | { |
michael@0 | 1495 | int c; |
michael@0 | 1496 | struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; |
michael@0 | 1497 | |
michael@0 | 1498 | *yyg->yy_c_buf_p = yyg->yy_hold_char; |
michael@0 | 1499 | |
michael@0 | 1500 | if ( *yyg->yy_c_buf_p == YY_END_OF_BUFFER_CHAR ) |
michael@0 | 1501 | { |
michael@0 | 1502 | /* yy_c_buf_p now points to the character we want to return. |
michael@0 | 1503 | * If this occurs *before* the EOB characters, then it's a |
michael@0 | 1504 | * valid NUL; if not, then we've hit the end of the buffer. |
michael@0 | 1505 | */ |
michael@0 | 1506 | if ( yyg->yy_c_buf_p < &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[yyg->yy_n_chars] ) |
michael@0 | 1507 | /* This was really a NUL. */ |
michael@0 | 1508 | *yyg->yy_c_buf_p = '\0'; |
michael@0 | 1509 | |
michael@0 | 1510 | else |
michael@0 | 1511 | { /* need more input */ |
michael@0 | 1512 | yy_size_t offset = yyg->yy_c_buf_p - yyg->yytext_ptr; |
michael@0 | 1513 | ++yyg->yy_c_buf_p; |
michael@0 | 1514 | |
michael@0 | 1515 | switch ( yy_get_next_buffer( yyscanner ) ) |
michael@0 | 1516 | { |
michael@0 | 1517 | case EOB_ACT_LAST_MATCH: |
michael@0 | 1518 | /* This happens because yy_g_n_b() |
michael@0 | 1519 | * sees that we've accumulated a |
michael@0 | 1520 | * token and flags that we need to |
michael@0 | 1521 | * try matching the token before |
michael@0 | 1522 | * proceeding. But for input(), |
michael@0 | 1523 | * there's no matching to consider. |
michael@0 | 1524 | * So convert the EOB_ACT_LAST_MATCH |
michael@0 | 1525 | * to EOB_ACT_END_OF_FILE. |
michael@0 | 1526 | */ |
michael@0 | 1527 | |
michael@0 | 1528 | /* Reset buffer status. */ |
michael@0 | 1529 | pprestart(yyin ,yyscanner); |
michael@0 | 1530 | |
michael@0 | 1531 | /*FALLTHROUGH*/ |
michael@0 | 1532 | |
michael@0 | 1533 | case EOB_ACT_END_OF_FILE: |
michael@0 | 1534 | { |
michael@0 | 1535 | if ( ppwrap(yyscanner ) ) |
michael@0 | 1536 | return EOF; |
michael@0 | 1537 | |
michael@0 | 1538 | if ( ! yyg->yy_did_buffer_switch_on_eof ) |
michael@0 | 1539 | YY_NEW_FILE; |
michael@0 | 1540 | #ifdef __cplusplus |
michael@0 | 1541 | return yyinput(yyscanner); |
michael@0 | 1542 | #else |
michael@0 | 1543 | return input(yyscanner); |
michael@0 | 1544 | #endif |
michael@0 | 1545 | } |
michael@0 | 1546 | |
michael@0 | 1547 | case EOB_ACT_CONTINUE_SCAN: |
michael@0 | 1548 | yyg->yy_c_buf_p = yyg->yytext_ptr + offset; |
michael@0 | 1549 | break; |
michael@0 | 1550 | } |
michael@0 | 1551 | } |
michael@0 | 1552 | } |
michael@0 | 1553 | |
michael@0 | 1554 | c = *(unsigned char *) yyg->yy_c_buf_p; /* cast for 8-bit char's */ |
michael@0 | 1555 | *yyg->yy_c_buf_p = '\0'; /* preserve yytext */ |
michael@0 | 1556 | yyg->yy_hold_char = *++yyg->yy_c_buf_p; |
michael@0 | 1557 | |
michael@0 | 1558 | return c; |
michael@0 | 1559 | } |
michael@0 | 1560 | #endif /* ifndef YY_NO_INPUT */ |
michael@0 | 1561 | |
michael@0 | 1562 | /** Immediately switch to a different input stream. |
michael@0 | 1563 | * @param input_file A readable stream. |
michael@0 | 1564 | * @param yyscanner The scanner object. |
michael@0 | 1565 | * @note This function does not reset the start condition to @c INITIAL . |
michael@0 | 1566 | */ |
michael@0 | 1567 | void pprestart (FILE * input_file , yyscan_t yyscanner) |
michael@0 | 1568 | { |
michael@0 | 1569 | struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; |
michael@0 | 1570 | |
michael@0 | 1571 | if ( ! YY_CURRENT_BUFFER ){ |
michael@0 | 1572 | ppensure_buffer_stack (yyscanner); |
michael@0 | 1573 | YY_CURRENT_BUFFER_LVALUE = |
michael@0 | 1574 | pp_create_buffer(yyin,YY_BUF_SIZE ,yyscanner); |
michael@0 | 1575 | } |
michael@0 | 1576 | |
michael@0 | 1577 | pp_init_buffer(YY_CURRENT_BUFFER,input_file ,yyscanner); |
michael@0 | 1578 | pp_load_buffer_state(yyscanner ); |
michael@0 | 1579 | } |
michael@0 | 1580 | |
michael@0 | 1581 | /** Switch to a different input buffer. |
michael@0 | 1582 | * @param new_buffer The new input buffer. |
michael@0 | 1583 | * @param yyscanner The scanner object. |
michael@0 | 1584 | */ |
michael@0 | 1585 | void pp_switch_to_buffer (YY_BUFFER_STATE new_buffer , yyscan_t yyscanner) |
michael@0 | 1586 | { |
michael@0 | 1587 | struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; |
michael@0 | 1588 | |
michael@0 | 1589 | /* TODO. We should be able to replace this entire function body |
michael@0 | 1590 | * with |
michael@0 | 1591 | * pppop_buffer_state(); |
michael@0 | 1592 | * pppush_buffer_state(new_buffer); |
michael@0 | 1593 | */ |
michael@0 | 1594 | ppensure_buffer_stack (yyscanner); |
michael@0 | 1595 | if ( YY_CURRENT_BUFFER == new_buffer ) |
michael@0 | 1596 | return; |
michael@0 | 1597 | |
michael@0 | 1598 | if ( YY_CURRENT_BUFFER ) |
michael@0 | 1599 | { |
michael@0 | 1600 | /* Flush out information for old buffer. */ |
michael@0 | 1601 | *yyg->yy_c_buf_p = yyg->yy_hold_char; |
michael@0 | 1602 | YY_CURRENT_BUFFER_LVALUE->yy_buf_pos = yyg->yy_c_buf_p; |
michael@0 | 1603 | YY_CURRENT_BUFFER_LVALUE->yy_n_chars = yyg->yy_n_chars; |
michael@0 | 1604 | } |
michael@0 | 1605 | |
michael@0 | 1606 | YY_CURRENT_BUFFER_LVALUE = new_buffer; |
michael@0 | 1607 | pp_load_buffer_state(yyscanner ); |
michael@0 | 1608 | |
michael@0 | 1609 | /* We don't actually know whether we did this switch during |
michael@0 | 1610 | * EOF (ppwrap()) processing, but the only time this flag |
michael@0 | 1611 | * is looked at is after ppwrap() is called, so it's safe |
michael@0 | 1612 | * to go ahead and always set it. |
michael@0 | 1613 | */ |
michael@0 | 1614 | yyg->yy_did_buffer_switch_on_eof = 1; |
michael@0 | 1615 | } |
michael@0 | 1616 | |
michael@0 | 1617 | static void pp_load_buffer_state (yyscan_t yyscanner) |
michael@0 | 1618 | { |
michael@0 | 1619 | struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; |
michael@0 | 1620 | yyg->yy_n_chars = YY_CURRENT_BUFFER_LVALUE->yy_n_chars; |
michael@0 | 1621 | yyg->yytext_ptr = yyg->yy_c_buf_p = YY_CURRENT_BUFFER_LVALUE->yy_buf_pos; |
michael@0 | 1622 | yyin = YY_CURRENT_BUFFER_LVALUE->yy_input_file; |
michael@0 | 1623 | yyg->yy_hold_char = *yyg->yy_c_buf_p; |
michael@0 | 1624 | } |
michael@0 | 1625 | |
michael@0 | 1626 | /** Allocate and initialize an input buffer state. |
michael@0 | 1627 | * @param file A readable stream. |
michael@0 | 1628 | * @param size The character buffer size in bytes. When in doubt, use @c YY_BUF_SIZE. |
michael@0 | 1629 | * @param yyscanner The scanner object. |
michael@0 | 1630 | * @return the allocated buffer state. |
michael@0 | 1631 | */ |
michael@0 | 1632 | YY_BUFFER_STATE pp_create_buffer (FILE * file, int size , yyscan_t yyscanner) |
michael@0 | 1633 | { |
michael@0 | 1634 | YY_BUFFER_STATE b; |
michael@0 | 1635 | |
michael@0 | 1636 | b = (YY_BUFFER_STATE) ppalloc(sizeof( struct yy_buffer_state ) ,yyscanner ); |
michael@0 | 1637 | if ( ! b ) |
michael@0 | 1638 | YY_FATAL_ERROR( "out of dynamic memory in pp_create_buffer()" ); |
michael@0 | 1639 | |
michael@0 | 1640 | b->yy_buf_size = size; |
michael@0 | 1641 | |
michael@0 | 1642 | /* yy_ch_buf has to be 2 characters longer than the size given because |
michael@0 | 1643 | * we need to put in 2 end-of-buffer characters. |
michael@0 | 1644 | */ |
michael@0 | 1645 | b->yy_ch_buf = (char *) ppalloc(b->yy_buf_size + 2 ,yyscanner ); |
michael@0 | 1646 | if ( ! b->yy_ch_buf ) |
michael@0 | 1647 | YY_FATAL_ERROR( "out of dynamic memory in pp_create_buffer()" ); |
michael@0 | 1648 | |
michael@0 | 1649 | b->yy_is_our_buffer = 1; |
michael@0 | 1650 | |
michael@0 | 1651 | pp_init_buffer(b,file ,yyscanner); |
michael@0 | 1652 | |
michael@0 | 1653 | return b; |
michael@0 | 1654 | } |
michael@0 | 1655 | |
michael@0 | 1656 | /** Destroy the buffer. |
michael@0 | 1657 | * @param b a buffer created with pp_create_buffer() |
michael@0 | 1658 | * @param yyscanner The scanner object. |
michael@0 | 1659 | */ |
michael@0 | 1660 | void pp_delete_buffer (YY_BUFFER_STATE b , yyscan_t yyscanner) |
michael@0 | 1661 | { |
michael@0 | 1662 | struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; |
michael@0 | 1663 | |
michael@0 | 1664 | if ( ! b ) |
michael@0 | 1665 | return; |
michael@0 | 1666 | |
michael@0 | 1667 | if ( b == YY_CURRENT_BUFFER ) /* Not sure if we should pop here. */ |
michael@0 | 1668 | YY_CURRENT_BUFFER_LVALUE = (YY_BUFFER_STATE) 0; |
michael@0 | 1669 | |
michael@0 | 1670 | if ( b->yy_is_our_buffer ) |
michael@0 | 1671 | ppfree((void *) b->yy_ch_buf ,yyscanner ); |
michael@0 | 1672 | |
michael@0 | 1673 | ppfree((void *) b ,yyscanner ); |
michael@0 | 1674 | } |
michael@0 | 1675 | |
michael@0 | 1676 | /* Initializes or reinitializes a buffer. |
michael@0 | 1677 | * This function is sometimes called more than once on the same buffer, |
michael@0 | 1678 | * such as during a pprestart() or at EOF. |
michael@0 | 1679 | */ |
michael@0 | 1680 | static void pp_init_buffer (YY_BUFFER_STATE b, FILE * file , yyscan_t yyscanner) |
michael@0 | 1681 | |
michael@0 | 1682 | { |
michael@0 | 1683 | int oerrno = errno; |
michael@0 | 1684 | struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; |
michael@0 | 1685 | |
michael@0 | 1686 | pp_flush_buffer(b ,yyscanner); |
michael@0 | 1687 | |
michael@0 | 1688 | b->yy_input_file = file; |
michael@0 | 1689 | b->yy_fill_buffer = 1; |
michael@0 | 1690 | |
michael@0 | 1691 | /* If b is the current buffer, then pp_init_buffer was _probably_ |
michael@0 | 1692 | * called from pprestart() or through yy_get_next_buffer. |
michael@0 | 1693 | * In that case, we don't want to reset the lineno or column. |
michael@0 | 1694 | */ |
michael@0 | 1695 | if (b != YY_CURRENT_BUFFER){ |
michael@0 | 1696 | b->yy_bs_lineno = 1; |
michael@0 | 1697 | b->yy_bs_column = 0; |
michael@0 | 1698 | } |
michael@0 | 1699 | |
michael@0 | 1700 | b->yy_is_interactive = 0; |
michael@0 | 1701 | |
michael@0 | 1702 | errno = oerrno; |
michael@0 | 1703 | } |
michael@0 | 1704 | |
michael@0 | 1705 | /** Discard all buffered characters. On the next scan, YY_INPUT will be called. |
michael@0 | 1706 | * @param b the buffer state to be flushed, usually @c YY_CURRENT_BUFFER. |
michael@0 | 1707 | * @param yyscanner The scanner object. |
michael@0 | 1708 | */ |
michael@0 | 1709 | void pp_flush_buffer (YY_BUFFER_STATE b , yyscan_t yyscanner) |
michael@0 | 1710 | { |
michael@0 | 1711 | struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; |
michael@0 | 1712 | if ( ! b ) |
michael@0 | 1713 | return; |
michael@0 | 1714 | |
michael@0 | 1715 | b->yy_n_chars = 0; |
michael@0 | 1716 | |
michael@0 | 1717 | /* We always need two end-of-buffer characters. The first causes |
michael@0 | 1718 | * a transition to the end-of-buffer state. The second causes |
michael@0 | 1719 | * a jam in that state. |
michael@0 | 1720 | */ |
michael@0 | 1721 | b->yy_ch_buf[0] = YY_END_OF_BUFFER_CHAR; |
michael@0 | 1722 | b->yy_ch_buf[1] = YY_END_OF_BUFFER_CHAR; |
michael@0 | 1723 | |
michael@0 | 1724 | b->yy_buf_pos = &b->yy_ch_buf[0]; |
michael@0 | 1725 | |
michael@0 | 1726 | b->yy_at_bol = 1; |
michael@0 | 1727 | b->yy_buffer_status = YY_BUFFER_NEW; |
michael@0 | 1728 | |
michael@0 | 1729 | if ( b == YY_CURRENT_BUFFER ) |
michael@0 | 1730 | pp_load_buffer_state(yyscanner ); |
michael@0 | 1731 | } |
michael@0 | 1732 | |
michael@0 | 1733 | /** Pushes the new state onto the stack. The new state becomes |
michael@0 | 1734 | * the current state. This function will allocate the stack |
michael@0 | 1735 | * if necessary. |
michael@0 | 1736 | * @param new_buffer The new state. |
michael@0 | 1737 | * @param yyscanner The scanner object. |
michael@0 | 1738 | */ |
michael@0 | 1739 | void pppush_buffer_state (YY_BUFFER_STATE new_buffer , yyscan_t yyscanner) |
michael@0 | 1740 | { |
michael@0 | 1741 | struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; |
michael@0 | 1742 | if (new_buffer == NULL) |
michael@0 | 1743 | return; |
michael@0 | 1744 | |
michael@0 | 1745 | ppensure_buffer_stack(yyscanner); |
michael@0 | 1746 | |
michael@0 | 1747 | /* This block is copied from pp_switch_to_buffer. */ |
michael@0 | 1748 | if ( YY_CURRENT_BUFFER ) |
michael@0 | 1749 | { |
michael@0 | 1750 | /* Flush out information for old buffer. */ |
michael@0 | 1751 | *yyg->yy_c_buf_p = yyg->yy_hold_char; |
michael@0 | 1752 | YY_CURRENT_BUFFER_LVALUE->yy_buf_pos = yyg->yy_c_buf_p; |
michael@0 | 1753 | YY_CURRENT_BUFFER_LVALUE->yy_n_chars = yyg->yy_n_chars; |
michael@0 | 1754 | } |
michael@0 | 1755 | |
michael@0 | 1756 | /* Only push if top exists. Otherwise, replace top. */ |
michael@0 | 1757 | if (YY_CURRENT_BUFFER) |
michael@0 | 1758 | yyg->yy_buffer_stack_top++; |
michael@0 | 1759 | YY_CURRENT_BUFFER_LVALUE = new_buffer; |
michael@0 | 1760 | |
michael@0 | 1761 | /* copied from pp_switch_to_buffer. */ |
michael@0 | 1762 | pp_load_buffer_state(yyscanner ); |
michael@0 | 1763 | yyg->yy_did_buffer_switch_on_eof = 1; |
michael@0 | 1764 | } |
michael@0 | 1765 | |
michael@0 | 1766 | /** Removes and deletes the top of the stack, if present. |
michael@0 | 1767 | * The next element becomes the new top. |
michael@0 | 1768 | * @param yyscanner The scanner object. |
michael@0 | 1769 | */ |
michael@0 | 1770 | void pppop_buffer_state (yyscan_t yyscanner) |
michael@0 | 1771 | { |
michael@0 | 1772 | struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; |
michael@0 | 1773 | if (!YY_CURRENT_BUFFER) |
michael@0 | 1774 | return; |
michael@0 | 1775 | |
michael@0 | 1776 | pp_delete_buffer(YY_CURRENT_BUFFER ,yyscanner); |
michael@0 | 1777 | YY_CURRENT_BUFFER_LVALUE = NULL; |
michael@0 | 1778 | if (yyg->yy_buffer_stack_top > 0) |
michael@0 | 1779 | --yyg->yy_buffer_stack_top; |
michael@0 | 1780 | |
michael@0 | 1781 | if (YY_CURRENT_BUFFER) { |
michael@0 | 1782 | pp_load_buffer_state(yyscanner ); |
michael@0 | 1783 | yyg->yy_did_buffer_switch_on_eof = 1; |
michael@0 | 1784 | } |
michael@0 | 1785 | } |
michael@0 | 1786 | |
michael@0 | 1787 | /* Allocates the stack if it does not exist. |
michael@0 | 1788 | * Guarantees space for at least one push. |
michael@0 | 1789 | */ |
michael@0 | 1790 | static void ppensure_buffer_stack (yyscan_t yyscanner) |
michael@0 | 1791 | { |
michael@0 | 1792 | yy_size_t num_to_alloc; |
michael@0 | 1793 | struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; |
michael@0 | 1794 | |
michael@0 | 1795 | if (!yyg->yy_buffer_stack) { |
michael@0 | 1796 | |
michael@0 | 1797 | /* First allocation is just for 2 elements, since we don't know if this |
michael@0 | 1798 | * scanner will even need a stack. We use 2 instead of 1 to avoid an |
michael@0 | 1799 | * immediate realloc on the next call. |
michael@0 | 1800 | */ |
michael@0 | 1801 | num_to_alloc = 1; |
michael@0 | 1802 | yyg->yy_buffer_stack = (struct yy_buffer_state**)ppalloc |
michael@0 | 1803 | (num_to_alloc * sizeof(struct yy_buffer_state*) |
michael@0 | 1804 | , yyscanner); |
michael@0 | 1805 | if ( ! yyg->yy_buffer_stack ) |
michael@0 | 1806 | YY_FATAL_ERROR( "out of dynamic memory in ppensure_buffer_stack()" ); |
michael@0 | 1807 | |
michael@0 | 1808 | memset(yyg->yy_buffer_stack, 0, num_to_alloc * sizeof(struct yy_buffer_state*)); |
michael@0 | 1809 | |
michael@0 | 1810 | yyg->yy_buffer_stack_max = num_to_alloc; |
michael@0 | 1811 | yyg->yy_buffer_stack_top = 0; |
michael@0 | 1812 | return; |
michael@0 | 1813 | } |
michael@0 | 1814 | |
michael@0 | 1815 | if (yyg->yy_buffer_stack_top >= (yyg->yy_buffer_stack_max) - 1){ |
michael@0 | 1816 | |
michael@0 | 1817 | /* Increase the buffer to prepare for a possible push. */ |
michael@0 | 1818 | int grow_size = 8 /* arbitrary grow size */; |
michael@0 | 1819 | |
michael@0 | 1820 | num_to_alloc = yyg->yy_buffer_stack_max + grow_size; |
michael@0 | 1821 | yyg->yy_buffer_stack = (struct yy_buffer_state**)pprealloc |
michael@0 | 1822 | (yyg->yy_buffer_stack, |
michael@0 | 1823 | num_to_alloc * sizeof(struct yy_buffer_state*) |
michael@0 | 1824 | , yyscanner); |
michael@0 | 1825 | if ( ! yyg->yy_buffer_stack ) |
michael@0 | 1826 | YY_FATAL_ERROR( "out of dynamic memory in ppensure_buffer_stack()" ); |
michael@0 | 1827 | |
michael@0 | 1828 | /* zero only the new slots.*/ |
michael@0 | 1829 | memset(yyg->yy_buffer_stack + yyg->yy_buffer_stack_max, 0, grow_size * sizeof(struct yy_buffer_state*)); |
michael@0 | 1830 | yyg->yy_buffer_stack_max = num_to_alloc; |
michael@0 | 1831 | } |
michael@0 | 1832 | } |
michael@0 | 1833 | |
michael@0 | 1834 | /** Setup the input buffer state to scan directly from a user-specified character buffer. |
michael@0 | 1835 | * @param base the character buffer |
michael@0 | 1836 | * @param size the size in bytes of the character buffer |
michael@0 | 1837 | * @param yyscanner The scanner object. |
michael@0 | 1838 | * @return the newly allocated buffer state object. |
michael@0 | 1839 | */ |
michael@0 | 1840 | YY_BUFFER_STATE pp_scan_buffer (char * base, yy_size_t size , yyscan_t yyscanner) |
michael@0 | 1841 | { |
michael@0 | 1842 | YY_BUFFER_STATE b; |
michael@0 | 1843 | |
michael@0 | 1844 | if ( size < 2 || |
michael@0 | 1845 | base[size-2] != YY_END_OF_BUFFER_CHAR || |
michael@0 | 1846 | base[size-1] != YY_END_OF_BUFFER_CHAR ) |
michael@0 | 1847 | /* They forgot to leave room for the EOB's. */ |
michael@0 | 1848 | return 0; |
michael@0 | 1849 | |
michael@0 | 1850 | b = (YY_BUFFER_STATE) ppalloc(sizeof( struct yy_buffer_state ) ,yyscanner ); |
michael@0 | 1851 | if ( ! b ) |
michael@0 | 1852 | YY_FATAL_ERROR( "out of dynamic memory in pp_scan_buffer()" ); |
michael@0 | 1853 | |
michael@0 | 1854 | b->yy_buf_size = size - 2; /* "- 2" to take care of EOB's */ |
michael@0 | 1855 | b->yy_buf_pos = b->yy_ch_buf = base; |
michael@0 | 1856 | b->yy_is_our_buffer = 0; |
michael@0 | 1857 | b->yy_input_file = 0; |
michael@0 | 1858 | b->yy_n_chars = b->yy_buf_size; |
michael@0 | 1859 | b->yy_is_interactive = 0; |
michael@0 | 1860 | b->yy_at_bol = 1; |
michael@0 | 1861 | b->yy_fill_buffer = 0; |
michael@0 | 1862 | b->yy_buffer_status = YY_BUFFER_NEW; |
michael@0 | 1863 | |
michael@0 | 1864 | pp_switch_to_buffer(b ,yyscanner ); |
michael@0 | 1865 | |
michael@0 | 1866 | return b; |
michael@0 | 1867 | } |
michael@0 | 1868 | |
michael@0 | 1869 | /** Setup the input buffer state to scan a string. The next call to pplex() will |
michael@0 | 1870 | * scan from a @e copy of @a str. |
michael@0 | 1871 | * @param yystr a NUL-terminated string to scan |
michael@0 | 1872 | * @param yyscanner The scanner object. |
michael@0 | 1873 | * @return the newly allocated buffer state object. |
michael@0 | 1874 | * @note If you want to scan bytes that may contain NUL values, then use |
michael@0 | 1875 | * pp_scan_bytes() instead. |
michael@0 | 1876 | */ |
michael@0 | 1877 | YY_BUFFER_STATE pp_scan_string (yyconst char * yystr , yyscan_t yyscanner) |
michael@0 | 1878 | { |
michael@0 | 1879 | |
michael@0 | 1880 | return pp_scan_bytes(yystr,strlen(yystr) ,yyscanner); |
michael@0 | 1881 | } |
michael@0 | 1882 | |
michael@0 | 1883 | /** Setup the input buffer state to scan the given bytes. The next call to pplex() will |
michael@0 | 1884 | * scan from a @e copy of @a bytes. |
michael@0 | 1885 | * @param bytes the byte buffer to scan |
michael@0 | 1886 | * @param len the number of bytes in the buffer pointed to by @a bytes. |
michael@0 | 1887 | * @param yyscanner The scanner object. |
michael@0 | 1888 | * @return the newly allocated buffer state object. |
michael@0 | 1889 | */ |
michael@0 | 1890 | YY_BUFFER_STATE pp_scan_bytes (yyconst char * yybytes, yy_size_t _yybytes_len , yyscan_t yyscanner) |
michael@0 | 1891 | { |
michael@0 | 1892 | YY_BUFFER_STATE b; |
michael@0 | 1893 | char *buf; |
michael@0 | 1894 | yy_size_t n, i; |
michael@0 | 1895 | |
michael@0 | 1896 | /* Get memory for full buffer, including space for trailing EOB's. */ |
michael@0 | 1897 | n = _yybytes_len + 2; |
michael@0 | 1898 | buf = (char *) ppalloc(n ,yyscanner ); |
michael@0 | 1899 | if ( ! buf ) |
michael@0 | 1900 | YY_FATAL_ERROR( "out of dynamic memory in pp_scan_bytes()" ); |
michael@0 | 1901 | |
michael@0 | 1902 | for ( i = 0; i < _yybytes_len; ++i ) |
michael@0 | 1903 | buf[i] = yybytes[i]; |
michael@0 | 1904 | |
michael@0 | 1905 | buf[_yybytes_len] = buf[_yybytes_len+1] = YY_END_OF_BUFFER_CHAR; |
michael@0 | 1906 | |
michael@0 | 1907 | b = pp_scan_buffer(buf,n ,yyscanner); |
michael@0 | 1908 | if ( ! b ) |
michael@0 | 1909 | YY_FATAL_ERROR( "bad buffer in pp_scan_bytes()" ); |
michael@0 | 1910 | |
michael@0 | 1911 | /* It's okay to grow etc. this buffer, and we should throw it |
michael@0 | 1912 | * away when we're done. |
michael@0 | 1913 | */ |
michael@0 | 1914 | b->yy_is_our_buffer = 1; |
michael@0 | 1915 | |
michael@0 | 1916 | return b; |
michael@0 | 1917 | } |
michael@0 | 1918 | |
michael@0 | 1919 | #ifndef YY_EXIT_FAILURE |
michael@0 | 1920 | #define YY_EXIT_FAILURE 2 |
michael@0 | 1921 | #endif |
michael@0 | 1922 | |
michael@0 | 1923 | static void yy_fatal_error (yyconst char* msg , yyscan_t yyscanner) |
michael@0 | 1924 | { |
michael@0 | 1925 | (void) fprintf( stderr, "%s\n", msg ); |
michael@0 | 1926 | exit( YY_EXIT_FAILURE ); |
michael@0 | 1927 | } |
michael@0 | 1928 | |
michael@0 | 1929 | /* Redefine yyless() so it works in section 3 code. */ |
michael@0 | 1930 | |
michael@0 | 1931 | #undef yyless |
michael@0 | 1932 | #define yyless(n) \ |
michael@0 | 1933 | do \ |
michael@0 | 1934 | { \ |
michael@0 | 1935 | /* Undo effects of setting up yytext. */ \ |
michael@0 | 1936 | int yyless_macro_arg = (n); \ |
michael@0 | 1937 | YY_LESS_LINENO(yyless_macro_arg);\ |
michael@0 | 1938 | yytext[yyleng] = yyg->yy_hold_char; \ |
michael@0 | 1939 | yyg->yy_c_buf_p = yytext + yyless_macro_arg; \ |
michael@0 | 1940 | yyg->yy_hold_char = *yyg->yy_c_buf_p; \ |
michael@0 | 1941 | *yyg->yy_c_buf_p = '\0'; \ |
michael@0 | 1942 | yyleng = yyless_macro_arg; \ |
michael@0 | 1943 | } \ |
michael@0 | 1944 | while ( 0 ) |
michael@0 | 1945 | |
michael@0 | 1946 | /* Accessor methods (get/set functions) to struct members. */ |
michael@0 | 1947 | |
michael@0 | 1948 | /** Get the user-defined data for this scanner. |
michael@0 | 1949 | * @param yyscanner The scanner object. |
michael@0 | 1950 | */ |
michael@0 | 1951 | YY_EXTRA_TYPE ppget_extra (yyscan_t yyscanner) |
michael@0 | 1952 | { |
michael@0 | 1953 | struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; |
michael@0 | 1954 | return yyextra; |
michael@0 | 1955 | } |
michael@0 | 1956 | |
michael@0 | 1957 | /** Get the current line number. |
michael@0 | 1958 | * @param yyscanner The scanner object. |
michael@0 | 1959 | */ |
michael@0 | 1960 | int ppget_lineno (yyscan_t yyscanner) |
michael@0 | 1961 | { |
michael@0 | 1962 | struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; |
michael@0 | 1963 | |
michael@0 | 1964 | if (! YY_CURRENT_BUFFER) |
michael@0 | 1965 | return 0; |
michael@0 | 1966 | |
michael@0 | 1967 | return yylineno; |
michael@0 | 1968 | } |
michael@0 | 1969 | |
michael@0 | 1970 | /** Get the current column number. |
michael@0 | 1971 | * @param yyscanner The scanner object. |
michael@0 | 1972 | */ |
michael@0 | 1973 | int ppget_column (yyscan_t yyscanner) |
michael@0 | 1974 | { |
michael@0 | 1975 | struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; |
michael@0 | 1976 | |
michael@0 | 1977 | if (! YY_CURRENT_BUFFER) |
michael@0 | 1978 | return 0; |
michael@0 | 1979 | |
michael@0 | 1980 | return yycolumn; |
michael@0 | 1981 | } |
michael@0 | 1982 | |
michael@0 | 1983 | /** Get the input stream. |
michael@0 | 1984 | * @param yyscanner The scanner object. |
michael@0 | 1985 | */ |
michael@0 | 1986 | FILE *ppget_in (yyscan_t yyscanner) |
michael@0 | 1987 | { |
michael@0 | 1988 | struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; |
michael@0 | 1989 | return yyin; |
michael@0 | 1990 | } |
michael@0 | 1991 | |
michael@0 | 1992 | /** Get the output stream. |
michael@0 | 1993 | * @param yyscanner The scanner object. |
michael@0 | 1994 | */ |
michael@0 | 1995 | FILE *ppget_out (yyscan_t yyscanner) |
michael@0 | 1996 | { |
michael@0 | 1997 | struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; |
michael@0 | 1998 | return yyout; |
michael@0 | 1999 | } |
michael@0 | 2000 | |
michael@0 | 2001 | /** Get the length of the current token. |
michael@0 | 2002 | * @param yyscanner The scanner object. |
michael@0 | 2003 | */ |
michael@0 | 2004 | yy_size_t ppget_leng (yyscan_t yyscanner) |
michael@0 | 2005 | { |
michael@0 | 2006 | struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; |
michael@0 | 2007 | return yyleng; |
michael@0 | 2008 | } |
michael@0 | 2009 | |
michael@0 | 2010 | /** Get the current token. |
michael@0 | 2011 | * @param yyscanner The scanner object. |
michael@0 | 2012 | */ |
michael@0 | 2013 | |
michael@0 | 2014 | char *ppget_text (yyscan_t yyscanner) |
michael@0 | 2015 | { |
michael@0 | 2016 | struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; |
michael@0 | 2017 | return yytext; |
michael@0 | 2018 | } |
michael@0 | 2019 | |
michael@0 | 2020 | /** Set the user-defined data. This data is never touched by the scanner. |
michael@0 | 2021 | * @param user_defined The data to be associated with this scanner. |
michael@0 | 2022 | * @param yyscanner The scanner object. |
michael@0 | 2023 | */ |
michael@0 | 2024 | void ppset_extra (YY_EXTRA_TYPE user_defined , yyscan_t yyscanner) |
michael@0 | 2025 | { |
michael@0 | 2026 | struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; |
michael@0 | 2027 | yyextra = user_defined ; |
michael@0 | 2028 | } |
michael@0 | 2029 | |
michael@0 | 2030 | /** Set the current line number. |
michael@0 | 2031 | * @param line_number |
michael@0 | 2032 | * @param yyscanner The scanner object. |
michael@0 | 2033 | */ |
michael@0 | 2034 | void ppset_lineno (int line_number , yyscan_t yyscanner) |
michael@0 | 2035 | { |
michael@0 | 2036 | struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; |
michael@0 | 2037 | |
michael@0 | 2038 | /* lineno is only valid if an input buffer exists. */ |
michael@0 | 2039 | if (! YY_CURRENT_BUFFER ) |
michael@0 | 2040 | yy_fatal_error( "ppset_lineno called with no buffer" , yyscanner); |
michael@0 | 2041 | |
michael@0 | 2042 | yylineno = line_number; |
michael@0 | 2043 | } |
michael@0 | 2044 | |
michael@0 | 2045 | /** Set the current column. |
michael@0 | 2046 | * @param line_number |
michael@0 | 2047 | * @param yyscanner The scanner object. |
michael@0 | 2048 | */ |
michael@0 | 2049 | void ppset_column (int column_no , yyscan_t yyscanner) |
michael@0 | 2050 | { |
michael@0 | 2051 | struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; |
michael@0 | 2052 | |
michael@0 | 2053 | /* column is only valid if an input buffer exists. */ |
michael@0 | 2054 | if (! YY_CURRENT_BUFFER ) |
michael@0 | 2055 | yy_fatal_error( "ppset_column called with no buffer" , yyscanner); |
michael@0 | 2056 | |
michael@0 | 2057 | yycolumn = column_no; |
michael@0 | 2058 | } |
michael@0 | 2059 | |
michael@0 | 2060 | /** Set the input stream. This does not discard the current |
michael@0 | 2061 | * input buffer. |
michael@0 | 2062 | * @param in_str A readable stream. |
michael@0 | 2063 | * @param yyscanner The scanner object. |
michael@0 | 2064 | * @see pp_switch_to_buffer |
michael@0 | 2065 | */ |
michael@0 | 2066 | void ppset_in (FILE * in_str , yyscan_t yyscanner) |
michael@0 | 2067 | { |
michael@0 | 2068 | struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; |
michael@0 | 2069 | yyin = in_str ; |
michael@0 | 2070 | } |
michael@0 | 2071 | |
michael@0 | 2072 | void ppset_out (FILE * out_str , yyscan_t yyscanner) |
michael@0 | 2073 | { |
michael@0 | 2074 | struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; |
michael@0 | 2075 | yyout = out_str ; |
michael@0 | 2076 | } |
michael@0 | 2077 | |
michael@0 | 2078 | int ppget_debug (yyscan_t yyscanner) |
michael@0 | 2079 | { |
michael@0 | 2080 | struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; |
michael@0 | 2081 | return yy_flex_debug; |
michael@0 | 2082 | } |
michael@0 | 2083 | |
michael@0 | 2084 | void ppset_debug (int bdebug , yyscan_t yyscanner) |
michael@0 | 2085 | { |
michael@0 | 2086 | struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; |
michael@0 | 2087 | yy_flex_debug = bdebug ; |
michael@0 | 2088 | } |
michael@0 | 2089 | |
michael@0 | 2090 | /* Accessor methods for yylval and yylloc */ |
michael@0 | 2091 | |
michael@0 | 2092 | YYSTYPE * ppget_lval (yyscan_t yyscanner) |
michael@0 | 2093 | { |
michael@0 | 2094 | struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; |
michael@0 | 2095 | return yylval; |
michael@0 | 2096 | } |
michael@0 | 2097 | |
michael@0 | 2098 | void ppset_lval (YYSTYPE * yylval_param , yyscan_t yyscanner) |
michael@0 | 2099 | { |
michael@0 | 2100 | struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; |
michael@0 | 2101 | yylval = yylval_param; |
michael@0 | 2102 | } |
michael@0 | 2103 | |
michael@0 | 2104 | YYLTYPE *ppget_lloc (yyscan_t yyscanner) |
michael@0 | 2105 | { |
michael@0 | 2106 | struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; |
michael@0 | 2107 | return yylloc; |
michael@0 | 2108 | } |
michael@0 | 2109 | |
michael@0 | 2110 | void ppset_lloc (YYLTYPE * yylloc_param , yyscan_t yyscanner) |
michael@0 | 2111 | { |
michael@0 | 2112 | struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; |
michael@0 | 2113 | yylloc = yylloc_param; |
michael@0 | 2114 | } |
michael@0 | 2115 | |
michael@0 | 2116 | /* User-visible API */ |
michael@0 | 2117 | |
michael@0 | 2118 | /* pplex_init is special because it creates the scanner itself, so it is |
michael@0 | 2119 | * the ONLY reentrant function that doesn't take the scanner as the last argument. |
michael@0 | 2120 | * That's why we explicitly handle the declaration, instead of using our macros. |
michael@0 | 2121 | */ |
michael@0 | 2122 | |
michael@0 | 2123 | int pplex_init(yyscan_t* ptr_yy_globals) |
michael@0 | 2124 | |
michael@0 | 2125 | { |
michael@0 | 2126 | if (ptr_yy_globals == NULL){ |
michael@0 | 2127 | errno = EINVAL; |
michael@0 | 2128 | return 1; |
michael@0 | 2129 | } |
michael@0 | 2130 | |
michael@0 | 2131 | *ptr_yy_globals = (yyscan_t) ppalloc ( sizeof( struct yyguts_t ), NULL ); |
michael@0 | 2132 | |
michael@0 | 2133 | if (*ptr_yy_globals == NULL){ |
michael@0 | 2134 | errno = ENOMEM; |
michael@0 | 2135 | return 1; |
michael@0 | 2136 | } |
michael@0 | 2137 | |
michael@0 | 2138 | /* By setting to 0xAA, we expose bugs in yy_init_globals. Leave at 0x00 for releases. */ |
michael@0 | 2139 | memset(*ptr_yy_globals,0x00,sizeof(struct yyguts_t)); |
michael@0 | 2140 | |
michael@0 | 2141 | return yy_init_globals ( *ptr_yy_globals ); |
michael@0 | 2142 | } |
michael@0 | 2143 | |
michael@0 | 2144 | /* pplex_init_extra has the same functionality as pplex_init, but follows the |
michael@0 | 2145 | * convention of taking the scanner as the last argument. Note however, that |
michael@0 | 2146 | * this is a *pointer* to a scanner, as it will be allocated by this call (and |
michael@0 | 2147 | * is the reason, too, why this function also must handle its own declaration). |
michael@0 | 2148 | * The user defined value in the first argument will be available to ppalloc in |
michael@0 | 2149 | * the yyextra field. |
michael@0 | 2150 | */ |
michael@0 | 2151 | |
michael@0 | 2152 | int pplex_init_extra(YY_EXTRA_TYPE yy_user_defined,yyscan_t* ptr_yy_globals ) |
michael@0 | 2153 | |
michael@0 | 2154 | { |
michael@0 | 2155 | struct yyguts_t dummy_yyguts; |
michael@0 | 2156 | |
michael@0 | 2157 | ppset_extra (yy_user_defined, &dummy_yyguts); |
michael@0 | 2158 | |
michael@0 | 2159 | if (ptr_yy_globals == NULL){ |
michael@0 | 2160 | errno = EINVAL; |
michael@0 | 2161 | return 1; |
michael@0 | 2162 | } |
michael@0 | 2163 | |
michael@0 | 2164 | *ptr_yy_globals = (yyscan_t) ppalloc ( sizeof( struct yyguts_t ), &dummy_yyguts ); |
michael@0 | 2165 | |
michael@0 | 2166 | if (*ptr_yy_globals == NULL){ |
michael@0 | 2167 | errno = ENOMEM; |
michael@0 | 2168 | return 1; |
michael@0 | 2169 | } |
michael@0 | 2170 | |
michael@0 | 2171 | /* By setting to 0xAA, we expose bugs in |
michael@0 | 2172 | yy_init_globals. Leave at 0x00 for releases. */ |
michael@0 | 2173 | memset(*ptr_yy_globals,0x00,sizeof(struct yyguts_t)); |
michael@0 | 2174 | |
michael@0 | 2175 | ppset_extra (yy_user_defined, *ptr_yy_globals); |
michael@0 | 2176 | |
michael@0 | 2177 | return yy_init_globals ( *ptr_yy_globals ); |
michael@0 | 2178 | } |
michael@0 | 2179 | |
michael@0 | 2180 | static int yy_init_globals (yyscan_t yyscanner) |
michael@0 | 2181 | { |
michael@0 | 2182 | struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; |
michael@0 | 2183 | /* Initialization is the same as for the non-reentrant scanner. |
michael@0 | 2184 | * This function is called from pplex_destroy(), so don't allocate here. |
michael@0 | 2185 | */ |
michael@0 | 2186 | |
michael@0 | 2187 | yyg->yy_buffer_stack = 0; |
michael@0 | 2188 | yyg->yy_buffer_stack_top = 0; |
michael@0 | 2189 | yyg->yy_buffer_stack_max = 0; |
michael@0 | 2190 | yyg->yy_c_buf_p = (char *) 0; |
michael@0 | 2191 | yyg->yy_init = 0; |
michael@0 | 2192 | yyg->yy_start = 0; |
michael@0 | 2193 | |
michael@0 | 2194 | yyg->yy_start_stack_ptr = 0; |
michael@0 | 2195 | yyg->yy_start_stack_depth = 0; |
michael@0 | 2196 | yyg->yy_start_stack = NULL; |
michael@0 | 2197 | |
michael@0 | 2198 | /* Defined in main.c */ |
michael@0 | 2199 | #ifdef YY_STDINIT |
michael@0 | 2200 | yyin = stdin; |
michael@0 | 2201 | yyout = stdout; |
michael@0 | 2202 | #else |
michael@0 | 2203 | yyin = (FILE *) 0; |
michael@0 | 2204 | yyout = (FILE *) 0; |
michael@0 | 2205 | #endif |
michael@0 | 2206 | |
michael@0 | 2207 | /* For future reference: Set errno on error, since we are called by |
michael@0 | 2208 | * pplex_init() |
michael@0 | 2209 | */ |
michael@0 | 2210 | return 0; |
michael@0 | 2211 | } |
michael@0 | 2212 | |
michael@0 | 2213 | /* pplex_destroy is for both reentrant and non-reentrant scanners. */ |
michael@0 | 2214 | int pplex_destroy (yyscan_t yyscanner) |
michael@0 | 2215 | { |
michael@0 | 2216 | struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; |
michael@0 | 2217 | |
michael@0 | 2218 | /* Pop the buffer stack, destroying each element. */ |
michael@0 | 2219 | while(YY_CURRENT_BUFFER){ |
michael@0 | 2220 | pp_delete_buffer(YY_CURRENT_BUFFER ,yyscanner ); |
michael@0 | 2221 | YY_CURRENT_BUFFER_LVALUE = NULL; |
michael@0 | 2222 | pppop_buffer_state(yyscanner); |
michael@0 | 2223 | } |
michael@0 | 2224 | |
michael@0 | 2225 | /* Destroy the stack itself. */ |
michael@0 | 2226 | ppfree(yyg->yy_buffer_stack ,yyscanner); |
michael@0 | 2227 | yyg->yy_buffer_stack = NULL; |
michael@0 | 2228 | |
michael@0 | 2229 | /* Destroy the start condition stack. */ |
michael@0 | 2230 | ppfree(yyg->yy_start_stack ,yyscanner ); |
michael@0 | 2231 | yyg->yy_start_stack = NULL; |
michael@0 | 2232 | |
michael@0 | 2233 | /* Reset the globals. This is important in a non-reentrant scanner so the next time |
michael@0 | 2234 | * pplex() is called, initialization will occur. */ |
michael@0 | 2235 | yy_init_globals( yyscanner); |
michael@0 | 2236 | |
michael@0 | 2237 | /* Destroy the main struct (reentrant only). */ |
michael@0 | 2238 | ppfree ( yyscanner , yyscanner ); |
michael@0 | 2239 | yyscanner = NULL; |
michael@0 | 2240 | return 0; |
michael@0 | 2241 | } |
michael@0 | 2242 | |
michael@0 | 2243 | /* |
michael@0 | 2244 | * Internal utility routines. |
michael@0 | 2245 | */ |
michael@0 | 2246 | |
michael@0 | 2247 | #ifndef yytext_ptr |
michael@0 | 2248 | static void yy_flex_strncpy (char* s1, yyconst char * s2, int n , yyscan_t yyscanner) |
michael@0 | 2249 | { |
michael@0 | 2250 | register int i; |
michael@0 | 2251 | for ( i = 0; i < n; ++i ) |
michael@0 | 2252 | s1[i] = s2[i]; |
michael@0 | 2253 | } |
michael@0 | 2254 | #endif |
michael@0 | 2255 | |
michael@0 | 2256 | #ifdef YY_NEED_STRLEN |
michael@0 | 2257 | static int yy_flex_strlen (yyconst char * s , yyscan_t yyscanner) |
michael@0 | 2258 | { |
michael@0 | 2259 | register int n; |
michael@0 | 2260 | for ( n = 0; s[n]; ++n ) |
michael@0 | 2261 | ; |
michael@0 | 2262 | |
michael@0 | 2263 | return n; |
michael@0 | 2264 | } |
michael@0 | 2265 | #endif |
michael@0 | 2266 | |
michael@0 | 2267 | void *ppalloc (yy_size_t size , yyscan_t yyscanner) |
michael@0 | 2268 | { |
michael@0 | 2269 | return (void *) malloc( size ); |
michael@0 | 2270 | } |
michael@0 | 2271 | |
michael@0 | 2272 | void *pprealloc (void * ptr, yy_size_t size , yyscan_t yyscanner) |
michael@0 | 2273 | { |
michael@0 | 2274 | /* The cast to (char *) in the following accommodates both |
michael@0 | 2275 | * implementations that use char* generic pointers, and those |
michael@0 | 2276 | * that use void* generic pointers. It works with the latter |
michael@0 | 2277 | * because both ANSI C and C++ allow castless assignment from |
michael@0 | 2278 | * any pointer type to void*, and deal with argument conversions |
michael@0 | 2279 | * as though doing an assignment. |
michael@0 | 2280 | */ |
michael@0 | 2281 | return (void *) realloc( (char *) ptr, size ); |
michael@0 | 2282 | } |
michael@0 | 2283 | |
michael@0 | 2284 | void ppfree (void * ptr , yyscan_t yyscanner) |
michael@0 | 2285 | { |
michael@0 | 2286 | free( (char *) ptr ); /* see pprealloc() for (char *) cast */ |
michael@0 | 2287 | } |
michael@0 | 2288 | |
michael@0 | 2289 | #define YYTABLES_NAME "yytables" |
michael@0 | 2290 | |
michael@0 | 2291 | namespace pp { |
michael@0 | 2292 | |
michael@0 | 2293 | // TODO(alokp): Maximum token length should ideally be specified by |
michael@0 | 2294 | // the preprocessor client, i.e., the compiler. |
michael@0 | 2295 | const size_t Tokenizer::kMaxTokenLength = 256; |
michael@0 | 2296 | |
michael@0 | 2297 | Tokenizer::Tokenizer(Diagnostics* diagnostics) : mHandle(0) |
michael@0 | 2298 | { |
michael@0 | 2299 | mContext.diagnostics = diagnostics; |
michael@0 | 2300 | } |
michael@0 | 2301 | |
michael@0 | 2302 | Tokenizer::~Tokenizer() |
michael@0 | 2303 | { |
michael@0 | 2304 | destroyScanner(); |
michael@0 | 2305 | } |
michael@0 | 2306 | |
michael@0 | 2307 | bool Tokenizer::init(size_t count, const char* const string[], const int length[]) |
michael@0 | 2308 | { |
michael@0 | 2309 | if ((count > 0) && (string == 0)) return false; |
michael@0 | 2310 | |
michael@0 | 2311 | mContext.input = Input(count, string, length); |
michael@0 | 2312 | return initScanner(); |
michael@0 | 2313 | } |
michael@0 | 2314 | |
michael@0 | 2315 | void Tokenizer::setFileNumber(int file) |
michael@0 | 2316 | { |
michael@0 | 2317 | // We use column number as file number. |
michael@0 | 2318 | // See macro yyfileno. |
michael@0 | 2319 | ppset_column(file,mHandle); |
michael@0 | 2320 | } |
michael@0 | 2321 | |
michael@0 | 2322 | void Tokenizer::setLineNumber(int line) |
michael@0 | 2323 | { |
michael@0 | 2324 | ppset_lineno(line,mHandle); |
michael@0 | 2325 | } |
michael@0 | 2326 | |
michael@0 | 2327 | void Tokenizer::lex(Token* token) |
michael@0 | 2328 | { |
michael@0 | 2329 | token->type = pplex(&token->text,&token->location,mHandle); |
michael@0 | 2330 | if (token->text.size() > kMaxTokenLength) |
michael@0 | 2331 | { |
michael@0 | 2332 | mContext.diagnostics->report(Diagnostics::TOKEN_TOO_LONG, |
michael@0 | 2333 | token->location, token->text); |
michael@0 | 2334 | token->text.erase(kMaxTokenLength); |
michael@0 | 2335 | } |
michael@0 | 2336 | |
michael@0 | 2337 | token->flags = 0; |
michael@0 | 2338 | |
michael@0 | 2339 | token->setAtStartOfLine(mContext.lineStart); |
michael@0 | 2340 | mContext.lineStart = token->type == '\n'; |
michael@0 | 2341 | |
michael@0 | 2342 | token->setHasLeadingSpace(mContext.leadingSpace); |
michael@0 | 2343 | mContext.leadingSpace = false; |
michael@0 | 2344 | } |
michael@0 | 2345 | |
michael@0 | 2346 | bool Tokenizer::initScanner() |
michael@0 | 2347 | { |
michael@0 | 2348 | if ((mHandle == NULL) && pplex_init_extra(&mContext,&mHandle)) |
michael@0 | 2349 | return false; |
michael@0 | 2350 | |
michael@0 | 2351 | pprestart(0,mHandle); |
michael@0 | 2352 | return true; |
michael@0 | 2353 | } |
michael@0 | 2354 | |
michael@0 | 2355 | void Tokenizer::destroyScanner() |
michael@0 | 2356 | { |
michael@0 | 2357 | if (mHandle == NULL) |
michael@0 | 2358 | return; |
michael@0 | 2359 | |
michael@0 | 2360 | pplex_destroy(mHandle); |
michael@0 | 2361 | mHandle = NULL; |
michael@0 | 2362 | } |
michael@0 | 2363 | |
michael@0 | 2364 | } // namespace pp |
michael@0 | 2365 |