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