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