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