blob: b006d404f9e48be56f5336e6c34c730ecc25a4db [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//
Jamie Madill88f6e942014-02-19 10:27:53 -05003// Copyright (c) 2011-2014 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
Jamie Madill185de882014-12-22 15:17:52 -050021#define YY_FLEX_SUBMINOR_VERSION 39
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)
Jamie Madill185de882014-12-22 15:17:52 -0500199 #define YY_LINENO_REWIND_TO(ptr)
alokp@chromium.org04d7d222012-05-16 19:24:07 +0000200
201/* Return all but the first "n" matched characters back to the input stream. */
202#define yyless(n) \
203 do \
204 { \
205 /* Undo effects of setting up yytext. */ \
206 int yyless_macro_arg = (n); \
207 YY_LESS_LINENO(yyless_macro_arg);\
208 *yy_cp = yyg->yy_hold_char; \
209 YY_RESTORE_YY_MORE_OFFSET \
210 yyg->yy_c_buf_p = yy_cp = yy_bp + yyless_macro_arg - YY_MORE_ADJ; \
211 YY_DO_BEFORE_ACTION; /* set up yytext again */ \
212 } \
213 while ( 0 )
214
215#define unput(c) yyunput( c, yyg->yytext_ptr , yyscanner )
216
alokp@chromium.org04d7d222012-05-16 19:24:07 +0000217#ifndef YY_STRUCT_YY_BUFFER_STATE
218#define YY_STRUCT_YY_BUFFER_STATE
219struct yy_buffer_state
220 {
221 FILE *yy_input_file;
222
223 char *yy_ch_buf; /* input buffer */
224 char *yy_buf_pos; /* current position in input buffer */
225
226 /* Size of input buffer in bytes, not including room for EOB
227 * characters.
228 */
229 yy_size_t yy_buf_size;
230
231 /* Number of characters read into yy_ch_buf, not including EOB
232 * characters.
233 */
shannonwoods@chromium.orgb0757162013-05-30 00:21:27 +0000234 yy_size_t yy_n_chars;
alokp@chromium.org04d7d222012-05-16 19:24:07 +0000235
236 /* Whether we "own" the buffer - i.e., we know we created it,
237 * and can realloc() it to grow it, and should free() it to
238 * delete it.
239 */
240 int yy_is_our_buffer;
241
242 /* Whether this is an "interactive" input source; if so, and
243 * if we're using stdio for input, then we want to use getc()
244 * instead of fread(), to make sure we stop fetching input after
245 * each newline.
246 */
247 int yy_is_interactive;
248
249 /* Whether we're considered to be at the beginning of a line.
250 * If so, '^' rules will be active on the next match, otherwise
251 * not.
252 */
253 int yy_at_bol;
254
255 int yy_bs_lineno; /**< The line count. */
256 int yy_bs_column; /**< The column count. */
257
258 /* Whether to try to fill the input buffer when we reach the
259 * end of it.
260 */
261 int yy_fill_buffer;
262
263 int yy_buffer_status;
264
265#define YY_BUFFER_NEW 0
266#define YY_BUFFER_NORMAL 1
267 /* When an EOF's been seen but there's still some text to process
268 * then we mark the buffer as YY_EOF_PENDING, to indicate that we
269 * shouldn't try reading from the input source any more. We might
270 * still have a bunch of tokens to match, though, because of
271 * possible backing-up.
272 *
273 * When we actually see the EOF, we change the status to "new"
274 * (via pprestart()), so that the user can continue scanning by
275 * just pointing yyin at a new input file.
276 */
277#define YY_BUFFER_EOF_PENDING 2
278
279 };
280#endif /* !YY_STRUCT_YY_BUFFER_STATE */
281
282/* We provide macros for accessing buffer states in case in the
283 * future we want to put the buffer states in a more general
284 * "scanner state".
285 *
286 * Returns the top of the stack, or NULL.
287 */
288#define YY_CURRENT_BUFFER ( yyg->yy_buffer_stack \
289 ? yyg->yy_buffer_stack[yyg->yy_buffer_stack_top] \
290 : NULL)
291
292/* Same as previous macro, but useful when we know that the buffer stack is not
293 * NULL or when we need an lvalue. For internal use only.
294 */
295#define YY_CURRENT_BUFFER_LVALUE yyg->yy_buffer_stack[yyg->yy_buffer_stack_top]
296
297void pprestart (FILE *input_file ,yyscan_t yyscanner );
298void pp_switch_to_buffer (YY_BUFFER_STATE new_buffer ,yyscan_t yyscanner );
299YY_BUFFER_STATE pp_create_buffer (FILE *file,int size ,yyscan_t yyscanner );
300void pp_delete_buffer (YY_BUFFER_STATE b ,yyscan_t yyscanner );
301void pp_flush_buffer (YY_BUFFER_STATE b ,yyscan_t yyscanner );
302void pppush_buffer_state (YY_BUFFER_STATE new_buffer ,yyscan_t yyscanner );
303void pppop_buffer_state (yyscan_t yyscanner );
304
305static void ppensure_buffer_stack (yyscan_t yyscanner );
306static void pp_load_buffer_state (yyscan_t yyscanner );
307static void pp_init_buffer (YY_BUFFER_STATE b,FILE *file ,yyscan_t yyscanner );
308
309#define YY_FLUSH_BUFFER pp_flush_buffer(YY_CURRENT_BUFFER ,yyscanner)
310
311YY_BUFFER_STATE pp_scan_buffer (char *base,yy_size_t size ,yyscan_t yyscanner );
312YY_BUFFER_STATE pp_scan_string (yyconst char *yy_str ,yyscan_t yyscanner );
shannonwoods@chromium.orgb0757162013-05-30 00:21:27 +0000313YY_BUFFER_STATE pp_scan_bytes (yyconst char *bytes,yy_size_t len ,yyscan_t yyscanner );
alokp@chromium.org04d7d222012-05-16 19:24:07 +0000314
315void *ppalloc (yy_size_t ,yyscan_t yyscanner );
316void *pprealloc (void *,yy_size_t ,yyscan_t yyscanner );
317void ppfree (void * ,yyscan_t yyscanner );
318
319#define yy_new_buffer pp_create_buffer
320
321#define yy_set_interactive(is_interactive) \
322 { \
323 if ( ! YY_CURRENT_BUFFER ){ \
324 ppensure_buffer_stack (yyscanner); \
325 YY_CURRENT_BUFFER_LVALUE = \
326 pp_create_buffer(yyin,YY_BUF_SIZE ,yyscanner); \
327 } \
328 YY_CURRENT_BUFFER_LVALUE->yy_is_interactive = is_interactive; \
329 }
330
331#define yy_set_bol(at_bol) \
332 { \
333 if ( ! YY_CURRENT_BUFFER ){\
334 ppensure_buffer_stack (yyscanner); \
335 YY_CURRENT_BUFFER_LVALUE = \
336 pp_create_buffer(yyin,YY_BUF_SIZE ,yyscanner); \
337 } \
338 YY_CURRENT_BUFFER_LVALUE->yy_at_bol = at_bol; \
339 }
340
341#define YY_AT_BOL() (YY_CURRENT_BUFFER_LVALUE->yy_at_bol)
342
343/* Begin user sect3 */
344
Zhenyao Mof1d723c2013-09-23 14:57:07 -0400345#define ppwrap(yyscanner) 1
alokp@chromium.org04d7d222012-05-16 19:24:07 +0000346#define YY_SKIP_YYWRAP
347
348typedef unsigned char YY_CHAR;
349
350typedef int yy_state_type;
351
352#define yytext_ptr yytext_r
353
354static yy_state_type yy_get_previous_state (yyscan_t yyscanner );
355static yy_state_type yy_try_NUL_trans (yy_state_type current_state ,yyscan_t yyscanner);
356static int yy_get_next_buffer (yyscan_t yyscanner );
357static void yy_fatal_error (yyconst char msg[] ,yyscan_t yyscanner );
358
359/* Done after the current pattern has been matched and before the
360 * corresponding action - sets up yytext.
361 */
362#define YY_DO_BEFORE_ACTION \
363 yyg->yytext_ptr = yy_bp; \
shannonwoods@chromium.orgb0757162013-05-30 00:21:27 +0000364 yyleng = (yy_size_t) (yy_cp - yy_bp); \
alokp@chromium.org04d7d222012-05-16 19:24:07 +0000365 yyg->yy_hold_char = *yy_cp; \
366 *yy_cp = '\0'; \
367 yyg->yy_c_buf_p = yy_cp;
368
shannon.woods%transgaming.com@gtempaccount.combcde56f2013-04-13 03:32:12 +0000369#define YY_NUM_RULES 38
370#define YY_END_OF_BUFFER 39
alokp@chromium.org04d7d222012-05-16 19:24:07 +0000371/* This struct is not used in this scanner,
372 but its presence is necessary. */
373struct yy_trans_info
374 {
375 flex_int32_t yy_verify;
376 flex_int32_t yy_nxt;
377 };
shannonwoods@chromium.org2a5436f2013-05-30 00:21:41 +0000378static yyconst flex_int16_t yy_accept[98] =
alokp@chromium.org04d7d222012-05-16 19:24:07 +0000379 { 0,
shannon.woods%transgaming.com@gtempaccount.combcde56f2013-04-13 03:32:12 +0000380 0, 0, 0, 0, 39, 37, 34, 35, 35, 33,
alokp@chromium.org04d7d222012-05-16 19:24:07 +0000381 7, 33, 33, 33, 33, 33, 33, 33, 33, 9,
shannon.woods%transgaming.com@gtempaccount.combcde56f2013-04-13 03:32:12 +0000382 9, 33, 33, 33, 8, 37, 33, 33, 3, 5,
383 5, 4, 34, 35, 19, 27, 20, 30, 25, 12,
384 23, 13, 24, 10, 2, 1, 26, 10, 9, 11,
shannonwoods@chromium.orgc8100b82013-05-30 00:20:34 +0000385 11, 11, 9, 11, 9, 9, 14, 16, 18, 17,
386 15, 8, 36, 36, 31, 21, 32, 22, 3, 5,
shannonwoods@chromium.org2a5436f2013-05-30 00:21:41 +0000387 6, 11, 10, 11, 10, 1, 10, 11, 10, 0,
388 10, 9, 9, 9, 28, 29, 0, 10, 10, 10,
389 10, 9, 10, 10, 9, 10, 0
shannonwoods@chromium.org3f83e292013-05-30 00:21:34 +0000390
alokp@chromium.org04d7d222012-05-16 19:24:07 +0000391 } ;
392
393static yyconst flex_int32_t yy_ec[256] =
394 { 0,
395 1, 1, 1, 1, 1, 1, 1, 1, 2, 3,
396 2, 2, 4, 1, 1, 1, 1, 1, 1, 1,
397 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
398 1, 2, 5, 1, 6, 1, 7, 8, 1, 9,
399 9, 10, 11, 9, 12, 13, 14, 15, 16, 16,
400 16, 16, 16, 16, 16, 17, 17, 9, 9, 18,
shannonwoods@chromium.org2a5436f2013-05-30 00:21:41 +0000401 19, 20, 9, 1, 21, 21, 21, 21, 22, 23,
402 24, 24, 24, 24, 24, 24, 24, 24, 24, 24,
403 24, 24, 24, 24, 25, 24, 24, 26, 24, 24,
404 9, 27, 9, 28, 24, 1, 21, 21, 21, 21,
alokp@chromium.org04d7d222012-05-16 19:24:07 +0000405
shannonwoods@chromium.org2a5436f2013-05-30 00:21:41 +0000406 22, 23, 24, 24, 24, 24, 24, 24, 24, 24,
407 24, 24, 24, 24, 24, 24, 25, 24, 24, 26,
408 24, 24, 9, 29, 9, 9, 1, 1, 1, 1,
alokp@chromium.org04d7d222012-05-16 19:24:07 +0000409 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 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
416
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, 1, 1, 1, 1, 1,
422 1, 1, 1, 1, 1
423 } ;
424
shannonwoods@chromium.org2a5436f2013-05-30 00:21:41 +0000425static yyconst flex_int32_t yy_meta[30] =
alokp@chromium.org04d7d222012-05-16 19:24:07 +0000426 { 0,
427 1, 1, 2, 2, 1, 1, 1, 1, 1, 3,
shannonwoods@chromium.org2a5436f2013-05-30 00:21:41 +0000428 1, 1, 4, 1, 5, 5, 5, 1, 1, 1,
429 5, 5, 5, 5, 5, 5, 1, 1, 1
alokp@chromium.org04d7d222012-05-16 19:24:07 +0000430 } ;
431
shannonwoods@chromium.org2a5436f2013-05-30 00:21:41 +0000432static yyconst flex_int16_t yy_base[103] =
alokp@chromium.org04d7d222012-05-16 19:24:07 +0000433 { 0,
shannonwoods@chromium.org2a5436f2013-05-30 00:21:41 +0000434 0, 0, 27, 29, 137, 194, 133, 194, 117, 100,
435 194, 98, 26, 194, 94, 24, 28, 33, 32, 39,
436 51, 39, 80, 50, 0, 68, 25, 54, 0, 194,
437 88, 71, 80, 194, 194, 194, 194, 194, 194, 194,
438 194, 194, 194, 71, 194, 0, 194, 85, 55, 64,
439 99, 111, 53, 105, 0, 50, 55, 194, 194, 194,
440 40, 0, 194, 38, 194, 194, 194, 194, 0, 194,
441 194, 117, 0, 130, 0, 0, 0, 137, 0, 88,
442 113, 0, 131, 0, 194, 194, 143, 139, 152, 150,
443 0, 13, 153, 194, 0, 194, 194, 176, 31, 181,
shannon.woods%transgaming.com@gtempaccount.combcde56f2013-04-13 03:32:12 +0000444
shannonwoods@chromium.org2a5436f2013-05-30 00:21:41 +0000445 186, 188
alokp@chromium.org04d7d222012-05-16 19:24:07 +0000446 } ;
447
shannonwoods@chromium.org2a5436f2013-05-30 00:21:41 +0000448static yyconst flex_int16_t yy_def[103] =
alokp@chromium.org04d7d222012-05-16 19:24:07 +0000449 { 0,
shannonwoods@chromium.org2a5436f2013-05-30 00:21:41 +0000450 97, 1, 98, 98, 97, 97, 97, 97, 97, 97,
451 97, 97, 97, 97, 97, 97, 97, 97, 97, 97,
452 20, 97, 97, 97, 99, 97, 97, 97, 100, 97,
453 97, 97, 97, 97, 97, 97, 97, 97, 97, 97,
454 97, 97, 97, 97, 97, 101, 97, 97, 20, 20,
455 50, 51, 51, 102, 21, 51, 97, 97, 97, 97,
456 97, 99, 97, 97, 97, 97, 97, 97, 100, 97,
457 97, 44, 44, 72, 72, 101, 48, 51, 51, 97,
458 52, 51, 102, 51, 97, 97, 97, 74, 78, 97,
459 51, 51, 97, 97, 51, 97, 0, 97, 97, 97,
shannon.woods%transgaming.com@gtempaccount.combcde56f2013-04-13 03:32:12 +0000460
shannonwoods@chromium.org2a5436f2013-05-30 00:21:41 +0000461 97, 97
alokp@chromium.org04d7d222012-05-16 19:24:07 +0000462 } ;
463
shannonwoods@chromium.org2a5436f2013-05-30 00:21:41 +0000464static yyconst flex_int16_t yy_nxt[224] =
alokp@chromium.org04d7d222012-05-16 19:24:07 +0000465 { 0,
466 6, 7, 8, 9, 10, 11, 12, 13, 14, 15,
467 16, 17, 18, 19, 20, 21, 21, 22, 23, 24,
shannonwoods@chromium.org2a5436f2013-05-30 00:21:41 +0000468 25, 25, 25, 25, 25, 25, 26, 27, 28, 30,
469 31, 30, 31, 37, 40, 62, 32, 95, 32, 42,
470 63, 45, 41, 65, 38, 46, 43, 44, 44, 44,
471 47, 48, 66, 49, 49, 50, 57, 58, 86, 51,
472 52, 51, 51, 53, 54, 55, 55, 55, 60, 61,
473 63, 64, 67, 85, 84, 56, 51, 82, 50, 50,
474 51, 33, 68, 72, 71, 73, 73, 73, 51, 51,
475 70, 72, 74, 75, 72, 72, 72, 51, 59, 77,
alokp@chromium.org04d7d222012-05-16 19:24:07 +0000476
shannonwoods@chromium.org2a5436f2013-05-30 00:21:41 +0000477 77, 77, 90, 90, 90, 51, 78, 79, 51, 51,
478 51, 51, 39, 51, 51, 51, 36, 51, 35, 34,
479 51, 80, 80, 97, 97, 81, 81, 81, 51, 51,
480 51, 72, 72, 72, 33, 91, 97, 97, 72, 72,
481 87, 87, 97, 51, 88, 88, 88, 87, 87, 97,
482 97, 89, 89, 89, 51, 92, 51, 93, 93, 93,
483 97, 75, 97, 97, 90, 90, 90, 93, 93, 93,
484 97, 97, 94, 97, 79, 96, 29, 29, 29, 29,
485 29, 69, 97, 97, 69, 69, 76, 97, 76, 76,
486 76, 83, 83, 5, 97, 97, 97, 97, 97, 97,
shannonwoods@chromium.orgc8100b82013-05-30 00:20:34 +0000487
shannonwoods@chromium.org2a5436f2013-05-30 00:21:41 +0000488 97, 97, 97, 97, 97, 97, 97, 97, 97, 97,
489 97, 97, 97, 97, 97, 97, 97, 97, 97, 97,
490 97, 97, 97
alokp@chromium.org04d7d222012-05-16 19:24:07 +0000491 } ;
492
shannonwoods@chromium.org2a5436f2013-05-30 00:21:41 +0000493static yyconst flex_int16_t yy_chk[224] =
alokp@chromium.org04d7d222012-05-16 19:24:07 +0000494 { 0,
495 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
496 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
shannonwoods@chromium.org2a5436f2013-05-30 00:21:41 +0000497 1, 1, 1, 1, 1, 1, 1, 1, 1, 3,
498 3, 4, 4, 13, 16, 99, 3, 92, 4, 17,
499 64, 19, 16, 27, 13, 19, 17, 18, 18, 18,
500 19, 20, 27, 20, 20, 20, 22, 22, 61, 20,
501 20, 20, 20, 20, 20, 21, 21, 21, 24, 24,
502 26, 26, 28, 57, 56, 21, 21, 53, 50, 50,
503 49, 33, 28, 44, 32, 44, 44, 44, 50, 50,
504 31, 44, 44, 44, 44, 44, 44, 48, 23, 48,
alokp@chromium.org04d7d222012-05-16 19:24:07 +0000505
shannonwoods@chromium.org2a5436f2013-05-30 00:21:41 +0000506 48, 48, 80, 80, 80, 48, 48, 48, 48, 48,
507 48, 51, 15, 51, 51, 51, 12, 54, 10, 9,
508 51, 52, 52, 81, 81, 52, 52, 52, 54, 54,
509 54, 72, 72, 72, 7, 81, 5, 0, 72, 72,
510 74, 74, 0, 83, 74, 74, 74, 78, 78, 88,
511 88, 78, 78, 78, 83, 83, 83, 87, 87, 87,
512 0, 88, 89, 89, 90, 90, 90, 93, 93, 93,
513 0, 0, 90, 0, 89, 93, 98, 98, 98, 98,
514 98, 100, 0, 0, 100, 100, 101, 0, 101, 101,
515 101, 102, 102, 97, 97, 97, 97, 97, 97, 97,
shannonwoods@chromium.orgc8100b82013-05-30 00:20:34 +0000516
shannonwoods@chromium.org2a5436f2013-05-30 00:21:41 +0000517 97, 97, 97, 97, 97, 97, 97, 97, 97, 97,
518 97, 97, 97, 97, 97, 97, 97, 97, 97, 97,
519 97, 97, 97
alokp@chromium.org04d7d222012-05-16 19:24:07 +0000520 } ;
521
522/* The intent behind this definition is that it'll catch
523 * any uses of REJECT which flex missed.
524 */
525#define REJECT reject_used_but_not_detected
526#define yymore() yymore_used_but_not_detected
527#define YY_MORE_ADJ 0
528#define YY_RESTORE_YY_MORE_OFFSET
529/*
530//
Jamie Madill88f6e942014-02-19 10:27:53 -0500531// Copyright (c) 2002-2014 The ANGLE Project Authors. All rights reserved.
alokp@chromium.org04d7d222012-05-16 19:24:07 +0000532// Use of this source code is governed by a BSD-style license that can be
533// found in the LICENSE file.
534//
535
536This file contains the Lex specification for GLSL ES preprocessor.
537Based on Microsoft Visual Studio 2010 Preprocessor Grammar:
538http://msdn.microsoft.com/en-us/library/2scxys89.aspx
539
540IF YOU MODIFY THIS FILE YOU ALSO NEED TO RUN generate_parser.sh.
541*/
542
543#include "Tokenizer.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"
Minmin Gong794e0002015-04-07 18:31:54 -0700551#elif defined(_MSC_VER)
552#pragma warning(disable: 4244)
maxvujovic@gmail.comc6b3b3c2012-06-27 22:49:39 +0000553#endif
554
alokp@chromium.org04d7d222012-05-16 19:24:07 +0000555typedef std::string YYSTYPE;
alokp@chromium.org2c958ee2012-05-17 20:35:42 +0000556typedef pp::SourceLocation YYLTYPE;
alokp@chromium.org04d7d222012-05-16 19:24:07 +0000557
558// Use the unused yycolumn variable to track file (string) number.
559#define yyfileno yycolumn
560
561#define YY_USER_INIT \
562 do { \
563 yyfileno = 0; \
564 yylineno = 1; \
565 yyextra->leadingSpace = false; \
566 yyextra->lineStart = true; \
567 } while(0);
568
alokp@chromium.org19d7aa62012-05-31 17:34:05 +0000569#define YY_USER_ACTION \
570 do \
571 { \
572 pp::Input* input = &yyextra->input; \
573 pp::Input::Location* scanLoc = &yyextra->scanLoc; \
574 while ((scanLoc->sIndex < input->count()) && \
575 (scanLoc->cIndex >= input->length(scanLoc->sIndex))) \
576 { \
577 scanLoc->cIndex -= input->length(scanLoc->sIndex++); \
578 ++yyfileno; yylineno = 1; \
579 } \
580 yylloc->file = yyfileno; \
581 yylloc->line = yylineno; \
582 scanLoc->cIndex += yyleng; \
alokp@chromium.org04d7d222012-05-16 19:24:07 +0000583 } while(0);
584
585#define YY_INPUT(buf, result, maxSize) \
586 result = yyextra->input.read(buf, maxSize);
587
588#define INITIAL 0
589#define COMMENT 1
590
591#define YY_EXTRA_TYPE pp::Tokenizer::Context*
592
593/* Holds the entire state of the reentrant scanner. */
594struct yyguts_t
595 {
596
597 /* User-defined. Not touched by flex. */
598 YY_EXTRA_TYPE yyextra_r;
599
600 /* The rest are the same as the globals declared in the non-reentrant scanner. */
601 FILE *yyin_r, *yyout_r;
602 size_t yy_buffer_stack_top; /**< index of top of stack. */
603 size_t yy_buffer_stack_max; /**< capacity of stack. */
604 YY_BUFFER_STATE * yy_buffer_stack; /**< Stack as an array. */
605 char yy_hold_char;
shannonwoods@chromium.orgb0757162013-05-30 00:21:27 +0000606 yy_size_t yy_n_chars;
607 yy_size_t yyleng_r;
alokp@chromium.org04d7d222012-05-16 19:24:07 +0000608 char *yy_c_buf_p;
609 int yy_init;
610 int yy_start;
611 int yy_did_buffer_switch_on_eof;
612 int yy_start_stack_ptr;
613 int yy_start_stack_depth;
614 int *yy_start_stack;
615 yy_state_type yy_last_accepting_state;
616 char* yy_last_accepting_cpos;
617
618 int yylineno_r;
619 int yy_flex_debug_r;
620
621 char *yytext_r;
622 int yy_more_flag;
623 int yy_more_len;
624
625 YYSTYPE * yylval_r;
626
627 YYLTYPE * yylloc_r;
628
629 }; /* end struct yyguts_t */
630
631static int yy_init_globals (yyscan_t yyscanner );
632
633 /* This must go here because YYSTYPE and YYLTYPE are included
634 * from bison output in section 1.*/
635 # define yylval yyg->yylval_r
636
637 # define yylloc yyg->yylloc_r
638
639int pplex_init (yyscan_t* scanner);
640
641int pplex_init_extra (YY_EXTRA_TYPE user_defined,yyscan_t* scanner);
642
643/* Accessor methods to globals.
644 These are made visible to non-reentrant scanners for convenience. */
645
646int pplex_destroy (yyscan_t yyscanner );
647
648int ppget_debug (yyscan_t yyscanner );
649
650void ppset_debug (int debug_flag ,yyscan_t yyscanner );
651
652YY_EXTRA_TYPE ppget_extra (yyscan_t yyscanner );
653
654void ppset_extra (YY_EXTRA_TYPE user_defined ,yyscan_t yyscanner );
655
656FILE *ppget_in (yyscan_t yyscanner );
657
658void ppset_in (FILE * in_str ,yyscan_t yyscanner );
659
660FILE *ppget_out (yyscan_t yyscanner );
661
662void ppset_out (FILE * out_str ,yyscan_t yyscanner );
663
shannonwoods@chromium.orgb0757162013-05-30 00:21:27 +0000664yy_size_t ppget_leng (yyscan_t yyscanner );
alokp@chromium.org04d7d222012-05-16 19:24:07 +0000665
666char *ppget_text (yyscan_t yyscanner );
667
668int ppget_lineno (yyscan_t yyscanner );
669
670void ppset_lineno (int line_number ,yyscan_t yyscanner );
671
Zhenyao Mof1d723c2013-09-23 14:57:07 -0400672int ppget_column (yyscan_t yyscanner );
673
674void ppset_column (int column_no ,yyscan_t yyscanner );
675
alokp@chromium.org04d7d222012-05-16 19:24:07 +0000676YYSTYPE * ppget_lval (yyscan_t yyscanner );
677
678void ppset_lval (YYSTYPE * yylval_param ,yyscan_t yyscanner );
679
680 YYLTYPE *ppget_lloc (yyscan_t yyscanner );
681
682 void ppset_lloc (YYLTYPE * yylloc_param ,yyscan_t yyscanner );
683
684/* Macros after this point can all be overridden by user definitions in
685 * section 1.
686 */
687
688#ifndef YY_SKIP_YYWRAP
689#ifdef __cplusplus
690extern "C" int ppwrap (yyscan_t yyscanner );
691#else
692extern int ppwrap (yyscan_t yyscanner );
693#endif
694#endif
695
696#ifndef yytext_ptr
697static void yy_flex_strncpy (char *,yyconst char *,int ,yyscan_t yyscanner);
698#endif
699
700#ifdef YY_NEED_STRLEN
701static int yy_flex_strlen (yyconst char * ,yyscan_t yyscanner);
702#endif
703
704#ifndef YY_NO_INPUT
705
706#ifdef __cplusplus
707static int yyinput (yyscan_t yyscanner );
708#else
709static int input (yyscan_t yyscanner );
710#endif
711
712#endif
713
714/* Amount of stuff to slurp up with each read. */
715#ifndef YY_READ_BUF_SIZE
716#define YY_READ_BUF_SIZE 8192
717#endif
718
719/* Copy whatever the last rule matched to the standard output. */
720#ifndef ECHO
721/* This used to be an fputs(), but since the string might contain NUL's,
722 * we now use fwrite().
723 */
Zhenyao Mof1d723c2013-09-23 14:57:07 -0400724#define ECHO do { if (fwrite( yytext, yyleng, 1, yyout )) {} } while (0)
alokp@chromium.org04d7d222012-05-16 19:24:07 +0000725#endif
726
727/* Gets input and stuffs it into "buf". number of characters read, or YY_NULL,
728 * is returned in "result".
729 */
730#ifndef YY_INPUT
731#define YY_INPUT(buf,result,max_size) \
732 if ( YY_CURRENT_BUFFER_LVALUE->yy_is_interactive ) \
733 { \
734 int c = '*'; \
Zhenyao Mof1d723c2013-09-23 14:57:07 -0400735 size_t n; \
alokp@chromium.org04d7d222012-05-16 19:24:07 +0000736 for ( n = 0; n < max_size && \
737 (c = getc( yyin )) != EOF && c != '\n'; ++n ) \
738 buf[n] = (char) c; \
739 if ( c == '\n' ) \
740 buf[n++] = (char) c; \
741 if ( c == EOF && ferror( yyin ) ) \
742 YY_FATAL_ERROR( "input in flex scanner failed" ); \
743 result = n; \
744 } \
745 else \
746 { \
747 errno=0; \
748 while ( (result = fread(buf, 1, max_size, yyin))==0 && ferror(yyin)) \
749 { \
750 if( errno != EINTR) \
751 { \
752 YY_FATAL_ERROR( "input in flex scanner failed" ); \
753 break; \
754 } \
755 errno=0; \
756 clearerr(yyin); \
757 } \
758 }\
759\
760
761#endif
762
763/* No semi-colon after return; correct usage is to write "yyterminate();" -
764 * we don't want an extra ';' after the "return" because that will cause
765 * some compilers to complain about unreachable statements.
766 */
767#ifndef yyterminate
768#define yyterminate() return YY_NULL
769#endif
770
771/* Number of entries by which start-condition stack grows. */
772#ifndef YY_START_STACK_INCR
773#define YY_START_STACK_INCR 25
774#endif
775
776/* Report a fatal error. */
777#ifndef YY_FATAL_ERROR
778#define YY_FATAL_ERROR(msg) yy_fatal_error( msg , yyscanner)
779#endif
780
781/* end tables serialization structures and prototypes */
782
783/* Default declaration of generated scanner - a define so the user can
784 * easily add parameters.
785 */
786#ifndef YY_DECL
787#define YY_DECL_IS_OURS 1
788
789extern int pplex \
790 (YYSTYPE * yylval_param,YYLTYPE * yylloc_param ,yyscan_t yyscanner);
791
792#define YY_DECL int pplex \
793 (YYSTYPE * yylval_param, YYLTYPE * yylloc_param , yyscan_t yyscanner)
794#endif /* !YY_DECL */
795
796/* Code executed at the beginning of each rule, after yytext and yyleng
797 * have been set up.
798 */
799#ifndef YY_USER_ACTION
800#define YY_USER_ACTION
801#endif
802
803/* Code executed at the end of each rule. */
804#ifndef YY_BREAK
805#define YY_BREAK break;
806#endif
807
808#define YY_RULE_SETUP \
809 YY_USER_ACTION
810
811/** The main scanner function which does all the work.
812 */
813YY_DECL
814{
815 register yy_state_type yy_current_state;
816 register char *yy_cp, *yy_bp;
817 register int yy_act;
818 struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
819
alokp@chromium.org04d7d222012-05-16 19:24:07 +0000820 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
Jamie Madill185de882014-12-22 15:17:52 -0500850 {
851
852 /* Line comment */
853
alokp@chromium.org04d7d222012-05-16 19:24:07 +0000854 while ( 1 ) /* loops until end-of-file is reached */
855 {
856 yy_cp = yyg->yy_c_buf_p;
857
858 /* Support of yytext. */
859 *yy_cp = yyg->yy_hold_char;
860
861 /* yy_bp points to the position in yy_ch_buf of the start of
862 * the current run.
863 */
864 yy_bp = yy_cp;
865
866 yy_current_state = yyg->yy_start;
867yy_match:
868 do
869 {
Jamie Madill185de882014-12-22 15:17:52 -0500870 register YY_CHAR yy_c = yy_ec[YY_SC_TO_UI(*yy_cp)] ;
alokp@chromium.org04d7d222012-05-16 19:24:07 +0000871 if ( yy_accept[yy_current_state] )
872 {
873 yyg->yy_last_accepting_state = yy_current_state;
874 yyg->yy_last_accepting_cpos = yy_cp;
875 }
876 while ( yy_chk[yy_base[yy_current_state] + yy_c] != yy_current_state )
877 {
878 yy_current_state = (int) yy_def[yy_current_state];
shannonwoods@chromium.org2a5436f2013-05-30 00:21:41 +0000879 if ( yy_current_state >= 98 )
alokp@chromium.org04d7d222012-05-16 19:24:07 +0000880 yy_c = yy_meta[(unsigned int) yy_c];
881 }
882 yy_current_state = yy_nxt[yy_base[yy_current_state] + (unsigned int) yy_c];
883 ++yy_cp;
884 }
shannonwoods@chromium.org2a5436f2013-05-30 00:21:41 +0000885 while ( yy_current_state != 97 );
alokp@chromium.org04d7d222012-05-16 19:24:07 +0000886 yy_cp = yyg->yy_last_accepting_cpos;
887 yy_current_state = yyg->yy_last_accepting_state;
888
889yy_find_action:
890 yy_act = yy_accept[yy_current_state];
891
892 YY_DO_BEFORE_ACTION;
893
894do_action: /* This label is used only to access EOF actions. */
895
896 switch ( yy_act )
897 { /* beginning of action switch */
898 case 0: /* must back up */
899 /* undo the effects of YY_DO_BEFORE_ACTION */
900 *yy_cp = yyg->yy_hold_char;
901 yy_cp = yyg->yy_last_accepting_cpos;
902 yy_current_state = yyg->yy_last_accepting_state;
903 goto yy_find_action;
904
905case 1:
906YY_RULE_SETUP
907
908 YY_BREAK
909/* Block comment */
910/* Line breaks are just counted - not returned. */
Jamie Madillb96687d2015-04-30 15:56:51 -0400911/* The comment is replaced by a single space. */
alokp@chromium.org04d7d222012-05-16 19:24:07 +0000912case 2:
913YY_RULE_SETUP
914{ BEGIN(COMMENT); }
915 YY_BREAK
916case 3:
917YY_RULE_SETUP
918
919 YY_BREAK
920case 4:
921YY_RULE_SETUP
922
923 YY_BREAK
924case 5:
925/* rule 5 can match eol */
926YY_RULE_SETUP
927{ ++yylineno; }
928 YY_BREAK
alokp@chromium.org04d7d222012-05-16 19:24:07 +0000929case 6:
930YY_RULE_SETUP
alokp@chromium.org2c958ee2012-05-17 20:35:42 +0000931{
932 yyextra->leadingSpace = true;
933 BEGIN(INITIAL);
934}
alokp@chromium.org04d7d222012-05-16 19:24:07 +0000935 YY_BREAK
936case 7:
937YY_RULE_SETUP
938{
939 // # is only valid at start of line for preprocessor directives.
alokp@chromium.org432d6fc2012-06-27 22:13:21 +0000940 yylval->assign(1, yytext[0]);
941 return yyextra->lineStart ? pp::Token::PP_HASH : pp::Token::PP_OTHER;
alokp@chromium.org04d7d222012-05-16 19:24:07 +0000942}
943 YY_BREAK
944case 8:
945YY_RULE_SETUP
946{
947 yylval->assign(yytext, yyleng);
948 return pp::Token::IDENTIFIER;
949}
950 YY_BREAK
951case 9:
952YY_RULE_SETUP
953{
954 yylval->assign(yytext, yyleng);
955 return pp::Token::CONST_INT;
956}
957 YY_BREAK
958case 10:
959YY_RULE_SETUP
960{
961 yylval->assign(yytext, yyleng);
962 return pp::Token::CONST_FLOAT;
963}
964 YY_BREAK
965/* Anything that starts with a {DIGIT} or .{DIGIT} must be a number. */
966/* Rule to catch all invalid integers and floats. */
967case 11:
968YY_RULE_SETUP
969{
alokp@chromium.org432d6fc2012-06-27 22:13:21 +0000970 yylval->assign(yytext, yyleng);
971 return pp::Token::PP_NUMBER;
alokp@chromium.org04d7d222012-05-16 19:24:07 +0000972}
973 YY_BREAK
974case 12:
975YY_RULE_SETUP
alokp@chromium.org07d921d2012-05-22 20:22:08 +0000976{
977 yylval->assign(yytext, yyleng);
978 return pp::Token::OP_INC;
979}
alokp@chromium.org04d7d222012-05-16 19:24:07 +0000980 YY_BREAK
981case 13:
982YY_RULE_SETUP
alokp@chromium.org07d921d2012-05-22 20:22:08 +0000983{
984 yylval->assign(yytext, yyleng);
985 return pp::Token::OP_DEC;
986}
alokp@chromium.org04d7d222012-05-16 19:24:07 +0000987 YY_BREAK
988case 14:
989YY_RULE_SETUP
alokp@chromium.org07d921d2012-05-22 20:22:08 +0000990{
991 yylval->assign(yytext, yyleng);
992 return pp::Token::OP_LEFT;
993}
alokp@chromium.org04d7d222012-05-16 19:24:07 +0000994 YY_BREAK
995case 15:
996YY_RULE_SETUP
alokp@chromium.org07d921d2012-05-22 20:22:08 +0000997{
998 yylval->assign(yytext, yyleng);
999 return pp::Token::OP_RIGHT;
1000}
alokp@chromium.org04d7d222012-05-16 19:24:07 +00001001 YY_BREAK
1002case 16:
1003YY_RULE_SETUP
alokp@chromium.org07d921d2012-05-22 20:22:08 +00001004{
1005 yylval->assign(yytext, yyleng);
1006 return pp::Token::OP_LE;
1007}
alokp@chromium.org04d7d222012-05-16 19:24:07 +00001008 YY_BREAK
1009case 17:
1010YY_RULE_SETUP
alokp@chromium.org07d921d2012-05-22 20:22:08 +00001011{
1012 yylval->assign(yytext, yyleng);
1013 return pp::Token::OP_GE;
1014}
alokp@chromium.org04d7d222012-05-16 19:24:07 +00001015 YY_BREAK
1016case 18:
1017YY_RULE_SETUP
alokp@chromium.org07d921d2012-05-22 20:22:08 +00001018{
1019 yylval->assign(yytext, yyleng);
1020 return pp::Token::OP_EQ;
1021}
alokp@chromium.org04d7d222012-05-16 19:24:07 +00001022 YY_BREAK
1023case 19:
1024YY_RULE_SETUP
alokp@chromium.org07d921d2012-05-22 20:22:08 +00001025{
1026 yylval->assign(yytext, yyleng);
1027 return pp::Token::OP_NE;
1028}
alokp@chromium.org04d7d222012-05-16 19:24:07 +00001029 YY_BREAK
1030case 20:
1031YY_RULE_SETUP
alokp@chromium.org07d921d2012-05-22 20:22:08 +00001032{
1033 yylval->assign(yytext, yyleng);
1034 return pp::Token::OP_AND;
1035}
alokp@chromium.org04d7d222012-05-16 19:24:07 +00001036 YY_BREAK
1037case 21:
1038YY_RULE_SETUP
alokp@chromium.org07d921d2012-05-22 20:22:08 +00001039{
1040 yylval->assign(yytext, yyleng);
1041 return pp::Token::OP_XOR;
1042}
alokp@chromium.org04d7d222012-05-16 19:24:07 +00001043 YY_BREAK
1044case 22:
1045YY_RULE_SETUP
alokp@chromium.org07d921d2012-05-22 20:22:08 +00001046{
1047 yylval->assign(yytext, yyleng);
1048 return pp::Token::OP_OR;
1049}
alokp@chromium.org04d7d222012-05-16 19:24:07 +00001050 YY_BREAK
1051case 23:
1052YY_RULE_SETUP
alokp@chromium.org07d921d2012-05-22 20:22:08 +00001053{
1054 yylval->assign(yytext, yyleng);
1055 return pp::Token::OP_ADD_ASSIGN;
1056}
alokp@chromium.org04d7d222012-05-16 19:24:07 +00001057 YY_BREAK
1058case 24:
1059YY_RULE_SETUP
alokp@chromium.org07d921d2012-05-22 20:22:08 +00001060{
1061 yylval->assign(yytext, yyleng);
1062 return pp::Token::OP_SUB_ASSIGN;
1063}
alokp@chromium.org04d7d222012-05-16 19:24:07 +00001064 YY_BREAK
1065case 25:
1066YY_RULE_SETUP
alokp@chromium.org07d921d2012-05-22 20:22:08 +00001067{
1068 yylval->assign(yytext, yyleng);
1069 return pp::Token::OP_MUL_ASSIGN;
1070}
alokp@chromium.org04d7d222012-05-16 19:24:07 +00001071 YY_BREAK
1072case 26:
1073YY_RULE_SETUP
alokp@chromium.org07d921d2012-05-22 20:22:08 +00001074{
1075 yylval->assign(yytext, yyleng);
1076 return pp::Token::OP_DIV_ASSIGN;
1077}
alokp@chromium.org04d7d222012-05-16 19:24:07 +00001078 YY_BREAK
1079case 27:
1080YY_RULE_SETUP
alokp@chromium.org07d921d2012-05-22 20:22:08 +00001081{
1082 yylval->assign(yytext, yyleng);
1083 return pp::Token::OP_MOD_ASSIGN;
1084}
alokp@chromium.org04d7d222012-05-16 19:24:07 +00001085 YY_BREAK
1086case 28:
1087YY_RULE_SETUP
alokp@chromium.org07d921d2012-05-22 20:22:08 +00001088{
1089 yylval->assign(yytext, yyleng);
1090 return pp::Token::OP_LEFT_ASSIGN;
1091}
alokp@chromium.org04d7d222012-05-16 19:24:07 +00001092 YY_BREAK
1093case 29:
1094YY_RULE_SETUP
alokp@chromium.org07d921d2012-05-22 20:22:08 +00001095{
1096 yylval->assign(yytext, yyleng);
1097 return pp::Token::OP_RIGHT_ASSIGN;
1098}
alokp@chromium.org04d7d222012-05-16 19:24:07 +00001099 YY_BREAK
1100case 30:
1101YY_RULE_SETUP
alokp@chromium.org07d921d2012-05-22 20:22:08 +00001102{
1103 yylval->assign(yytext, yyleng);
1104 return pp::Token::OP_AND_ASSIGN;
1105}
alokp@chromium.org04d7d222012-05-16 19:24:07 +00001106 YY_BREAK
1107case 31:
1108YY_RULE_SETUP
alokp@chromium.org07d921d2012-05-22 20:22:08 +00001109{
1110 yylval->assign(yytext, yyleng);
1111 return pp::Token::OP_XOR_ASSIGN;
1112}
alokp@chromium.org04d7d222012-05-16 19:24:07 +00001113 YY_BREAK
1114case 32:
1115YY_RULE_SETUP
alokp@chromium.org07d921d2012-05-22 20:22:08 +00001116{
1117 yylval->assign(yytext, yyleng);
1118 return pp::Token::OP_OR_ASSIGN;
1119}
alokp@chromium.org04d7d222012-05-16 19:24:07 +00001120 YY_BREAK
1121case 33:
1122YY_RULE_SETUP
alokp@chromium.org07d921d2012-05-22 20:22:08 +00001123{
1124 yylval->assign(1, yytext[0]);
1125 return yytext[0];
1126}
alokp@chromium.org04d7d222012-05-16 19:24:07 +00001127 YY_BREAK
1128case 34:
1129YY_RULE_SETUP
1130{ yyextra->leadingSpace = true; }
1131 YY_BREAK
1132case 35:
1133/* rule 35 can match eol */
1134YY_RULE_SETUP
1135{
1136 ++yylineno;
alokp@chromium.org07d921d2012-05-22 20:22:08 +00001137 yylval->assign(1, '\n');
alokp@chromium.org04d7d222012-05-16 19:24:07 +00001138 return '\n';
1139}
1140 YY_BREAK
1141case 36:
shannon.woods%transgaming.com@gtempaccount.combcde56f2013-04-13 03:32:12 +00001142/* rule 36 can match eol */
1143YY_RULE_SETUP
1144{ ++yylineno; }
1145 YY_BREAK
1146case 37:
alokp@chromium.org04d7d222012-05-16 19:24:07 +00001147YY_RULE_SETUP
1148{
alokp@chromium.org432d6fc2012-06-27 22:13:21 +00001149 yylval->assign(1, yytext[0]);
1150 return pp::Token::PP_OTHER;
alokp@chromium.org04d7d222012-05-16 19:24:07 +00001151}
1152 YY_BREAK
1153case YY_STATE_EOF(INITIAL):
alokp@chromium.org07d921d2012-05-22 20:22:08 +00001154case YY_STATE_EOF(COMMENT):
1155{
alokp@chromium.org19d7aa62012-05-31 17:34:05 +00001156 // YY_USER_ACTION is not invoked for handling EOF.
1157 // Set the location for EOF token manually.
1158 pp::Input* input = &yyextra->input;
1159 pp::Input::Location* scanLoc = &yyextra->scanLoc;
shannon.woods@transgaming.comd64b3da2013-02-28 23:19:26 +00001160 yy_size_t sIndexMax = input->count() ? input->count() - 1 : 0;
alokp@chromium.org19d7aa62012-05-31 17:34:05 +00001161 if (scanLoc->sIndex != sIndexMax)
1162 {
1163 // We can only reach here if there are empty strings at the
1164 // end of the input.
1165 scanLoc->sIndex = sIndexMax; scanLoc->cIndex = 0;
shannon.woods@transgaming.comd64b3da2013-02-28 23:19:26 +00001166 // FIXME: this is not 64-bit clean.
1167 yyfileno = static_cast<int>(sIndexMax); yylineno = 1;
alokp@chromium.org19d7aa62012-05-31 17:34:05 +00001168 }
1169 yylloc->file = yyfileno;
1170 yylloc->line = yylineno;
1171 yylval->clear();
1172
alokp@chromium.org07d921d2012-05-22 20:22:08 +00001173 if (YY_START == COMMENT)
1174 {
Shannon Woods7f2d7942013-11-19 15:07:58 -05001175 yyextra->diagnostics->report(pp::Diagnostics::PP_EOF_IN_COMMENT,
alokp@chromium.org07d921d2012-05-22 20:22:08 +00001176 pp::SourceLocation(yyfileno, yylineno),
1177 "");
1178 }
alokp@chromium.org07d921d2012-05-22 20:22:08 +00001179 yyterminate();
1180}
alokp@chromium.org04d7d222012-05-16 19:24:07 +00001181 YY_BREAK
shannon.woods%transgaming.com@gtempaccount.combcde56f2013-04-13 03:32:12 +00001182case 38:
alokp@chromium.org04d7d222012-05-16 19:24:07 +00001183YY_RULE_SETUP
1184ECHO;
1185 YY_BREAK
1186
1187 case YY_END_OF_BUFFER:
1188 {
1189 /* Amount of text matched not including the EOB char. */
1190 int yy_amount_of_matched_text = (int) (yy_cp - yyg->yytext_ptr) - 1;
1191
1192 /* Undo the effects of YY_DO_BEFORE_ACTION. */
1193 *yy_cp = yyg->yy_hold_char;
1194 YY_RESTORE_YY_MORE_OFFSET
1195
1196 if ( YY_CURRENT_BUFFER_LVALUE->yy_buffer_status == YY_BUFFER_NEW )
1197 {
1198 /* We're scanning a new file or input source. It's
1199 * possible that this happened because the user
1200 * just pointed yyin at a new source and called
1201 * pplex(). If so, then we have to assure
1202 * consistency between YY_CURRENT_BUFFER and our
1203 * globals. Here is the right place to do so, because
1204 * this is the first action (other than possibly a
1205 * back-up) that will match for the new input source.
1206 */
1207 yyg->yy_n_chars = YY_CURRENT_BUFFER_LVALUE->yy_n_chars;
1208 YY_CURRENT_BUFFER_LVALUE->yy_input_file = yyin;
1209 YY_CURRENT_BUFFER_LVALUE->yy_buffer_status = YY_BUFFER_NORMAL;
1210 }
1211
1212 /* Note that here we test for yy_c_buf_p "<=" to the position
1213 * of the first EOB in the buffer, since yy_c_buf_p will
1214 * already have been incremented past the NUL character
1215 * (since all states make transitions on EOB to the
1216 * end-of-buffer state). Contrast this with the test
1217 * in input().
1218 */
1219 if ( yyg->yy_c_buf_p <= &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[yyg->yy_n_chars] )
1220 { /* This was really a NUL. */
1221 yy_state_type yy_next_state;
1222
1223 yyg->yy_c_buf_p = yyg->yytext_ptr + yy_amount_of_matched_text;
1224
1225 yy_current_state = yy_get_previous_state( yyscanner );
1226
1227 /* Okay, we're now positioned to make the NUL
1228 * transition. We couldn't have
1229 * yy_get_previous_state() go ahead and do it
1230 * for us because it doesn't know how to deal
1231 * with the possibility of jamming (and we don't
1232 * want to build jamming into it because then it
1233 * will run more slowly).
1234 */
1235
1236 yy_next_state = yy_try_NUL_trans( yy_current_state , yyscanner);
1237
1238 yy_bp = yyg->yytext_ptr + YY_MORE_ADJ;
1239
1240 if ( yy_next_state )
1241 {
1242 /* Consume the NUL. */
1243 yy_cp = ++yyg->yy_c_buf_p;
1244 yy_current_state = yy_next_state;
1245 goto yy_match;
1246 }
1247
1248 else
1249 {
1250 yy_cp = yyg->yy_last_accepting_cpos;
1251 yy_current_state = yyg->yy_last_accepting_state;
1252 goto yy_find_action;
1253 }
1254 }
1255
1256 else switch ( yy_get_next_buffer( yyscanner ) )
1257 {
1258 case EOB_ACT_END_OF_FILE:
1259 {
1260 yyg->yy_did_buffer_switch_on_eof = 0;
1261
1262 if ( ppwrap(yyscanner ) )
1263 {
1264 /* Note: because we've taken care in
1265 * yy_get_next_buffer() to have set up
1266 * yytext, we can now set up
1267 * yy_c_buf_p so that if some total
1268 * hoser (like flex itself) wants to
1269 * call the scanner after we return the
1270 * YY_NULL, it'll still work - another
1271 * YY_NULL will get returned.
1272 */
1273 yyg->yy_c_buf_p = yyg->yytext_ptr + YY_MORE_ADJ;
1274
1275 yy_act = YY_STATE_EOF(YY_START);
1276 goto do_action;
1277 }
1278
1279 else
1280 {
1281 if ( ! yyg->yy_did_buffer_switch_on_eof )
1282 YY_NEW_FILE;
1283 }
1284 break;
1285 }
1286
1287 case EOB_ACT_CONTINUE_SCAN:
1288 yyg->yy_c_buf_p =
1289 yyg->yytext_ptr + yy_amount_of_matched_text;
1290
1291 yy_current_state = yy_get_previous_state( yyscanner );
1292
1293 yy_cp = yyg->yy_c_buf_p;
1294 yy_bp = yyg->yytext_ptr + YY_MORE_ADJ;
1295 goto yy_match;
1296
1297 case EOB_ACT_LAST_MATCH:
1298 yyg->yy_c_buf_p =
1299 &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[yyg->yy_n_chars];
1300
1301 yy_current_state = yy_get_previous_state( yyscanner );
1302
1303 yy_cp = yyg->yy_c_buf_p;
1304 yy_bp = yyg->yytext_ptr + YY_MORE_ADJ;
1305 goto yy_find_action;
1306 }
1307 break;
1308 }
1309
1310 default:
1311 YY_FATAL_ERROR(
1312 "fatal flex scanner internal error--no action found" );
1313 } /* end of action switch */
1314 } /* end of scanning one token */
Jamie Madill185de882014-12-22 15:17:52 -05001315 } /* end of user's declarations */
alokp@chromium.org04d7d222012-05-16 19:24:07 +00001316} /* end of pplex */
1317
1318/* yy_get_next_buffer - try to read in a new buffer
1319 *
1320 * Returns a code representing an action:
1321 * EOB_ACT_LAST_MATCH -
1322 * EOB_ACT_CONTINUE_SCAN - continue scanning from current position
1323 * EOB_ACT_END_OF_FILE - end of file
1324 */
1325static int yy_get_next_buffer (yyscan_t yyscanner)
1326{
1327 struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
1328 register char *dest = YY_CURRENT_BUFFER_LVALUE->yy_ch_buf;
1329 register char *source = yyg->yytext_ptr;
1330 register int number_to_move, i;
1331 int ret_val;
1332
1333 if ( yyg->yy_c_buf_p > &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[yyg->yy_n_chars + 1] )
1334 YY_FATAL_ERROR(
1335 "fatal flex scanner internal error--end of buffer missed" );
1336
1337 if ( YY_CURRENT_BUFFER_LVALUE->yy_fill_buffer == 0 )
1338 { /* Don't try to fill the buffer, so this is an EOF. */
1339 if ( yyg->yy_c_buf_p - yyg->yytext_ptr - YY_MORE_ADJ == 1 )
1340 {
1341 /* We matched a single character, the EOB, so
1342 * treat this as a final EOF.
1343 */
1344 return EOB_ACT_END_OF_FILE;
1345 }
1346
1347 else
1348 {
1349 /* We matched some text prior to the EOB, first
1350 * process it.
1351 */
1352 return EOB_ACT_LAST_MATCH;
1353 }
1354 }
1355
1356 /* Try to read more data. */
1357
1358 /* First move last chars to start of buffer. */
1359 number_to_move = (int) (yyg->yy_c_buf_p - yyg->yytext_ptr) - 1;
1360
1361 for ( i = 0; i < number_to_move; ++i )
1362 *(dest++) = *(source++);
1363
1364 if ( YY_CURRENT_BUFFER_LVALUE->yy_buffer_status == YY_BUFFER_EOF_PENDING )
1365 /* don't do the read, it's not guaranteed to return an EOF,
1366 * just force an EOF
1367 */
1368 YY_CURRENT_BUFFER_LVALUE->yy_n_chars = yyg->yy_n_chars = 0;
1369
1370 else
1371 {
shannonwoods@chromium.orgb0757162013-05-30 00:21:27 +00001372 yy_size_t num_to_read =
alokp@chromium.org04d7d222012-05-16 19:24:07 +00001373 YY_CURRENT_BUFFER_LVALUE->yy_buf_size - number_to_move - 1;
1374
1375 while ( num_to_read <= 0 )
1376 { /* Not enough room in the buffer - grow it. */
1377
1378 /* just a shorter name for the current buffer */
Zhenyao Mof1d723c2013-09-23 14:57:07 -04001379 YY_BUFFER_STATE b = YY_CURRENT_BUFFER_LVALUE;
alokp@chromium.org04d7d222012-05-16 19:24:07 +00001380
1381 int yy_c_buf_p_offset =
1382 (int) (yyg->yy_c_buf_p - b->yy_ch_buf);
1383
1384 if ( b->yy_is_our_buffer )
1385 {
shannonwoods@chromium.orgb0757162013-05-30 00:21:27 +00001386 yy_size_t new_size = b->yy_buf_size * 2;
alokp@chromium.org04d7d222012-05-16 19:24:07 +00001387
1388 if ( new_size <= 0 )
1389 b->yy_buf_size += b->yy_buf_size / 8;
1390 else
1391 b->yy_buf_size *= 2;
1392
1393 b->yy_ch_buf = (char *)
1394 /* Include room in for 2 EOB chars. */
1395 pprealloc((void *) b->yy_ch_buf,b->yy_buf_size + 2 ,yyscanner );
1396 }
1397 else
1398 /* Can't grow it, we don't own it. */
1399 b->yy_ch_buf = 0;
1400
1401 if ( ! b->yy_ch_buf )
1402 YY_FATAL_ERROR(
1403 "fatal error - scanner input buffer overflow" );
1404
1405 yyg->yy_c_buf_p = &b->yy_ch_buf[yy_c_buf_p_offset];
1406
1407 num_to_read = YY_CURRENT_BUFFER_LVALUE->yy_buf_size -
1408 number_to_move - 1;
1409
1410 }
1411
1412 if ( num_to_read > YY_READ_BUF_SIZE )
1413 num_to_read = YY_READ_BUF_SIZE;
1414
1415 /* Read in more data. */
1416 YY_INPUT( (&YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[number_to_move]),
shannonwoods@chromium.orgb0757162013-05-30 00:21:27 +00001417 yyg->yy_n_chars, num_to_read );
alokp@chromium.org04d7d222012-05-16 19:24:07 +00001418
1419 YY_CURRENT_BUFFER_LVALUE->yy_n_chars = yyg->yy_n_chars;
1420 }
1421
1422 if ( yyg->yy_n_chars == 0 )
1423 {
1424 if ( number_to_move == YY_MORE_ADJ )
1425 {
1426 ret_val = EOB_ACT_END_OF_FILE;
1427 pprestart(yyin ,yyscanner);
1428 }
1429
1430 else
1431 {
1432 ret_val = EOB_ACT_LAST_MATCH;
1433 YY_CURRENT_BUFFER_LVALUE->yy_buffer_status =
1434 YY_BUFFER_EOF_PENDING;
1435 }
1436 }
1437
1438 else
1439 ret_val = EOB_ACT_CONTINUE_SCAN;
1440
1441 if ((yy_size_t) (yyg->yy_n_chars + number_to_move) > YY_CURRENT_BUFFER_LVALUE->yy_buf_size) {
1442 /* Extend the array by 50%, plus the number we really need. */
1443 yy_size_t new_size = yyg->yy_n_chars + number_to_move + (yyg->yy_n_chars >> 1);
1444 YY_CURRENT_BUFFER_LVALUE->yy_ch_buf = (char *) pprealloc((void *) YY_CURRENT_BUFFER_LVALUE->yy_ch_buf,new_size ,yyscanner );
1445 if ( ! YY_CURRENT_BUFFER_LVALUE->yy_ch_buf )
1446 YY_FATAL_ERROR( "out of dynamic memory in yy_get_next_buffer()" );
1447 }
1448
1449 yyg->yy_n_chars += number_to_move;
1450 YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[yyg->yy_n_chars] = YY_END_OF_BUFFER_CHAR;
1451 YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[yyg->yy_n_chars + 1] = YY_END_OF_BUFFER_CHAR;
1452
1453 yyg->yytext_ptr = &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[0];
1454
1455 return ret_val;
1456}
1457
1458/* yy_get_previous_state - get the state just before the EOB char was reached */
1459
1460 static yy_state_type yy_get_previous_state (yyscan_t yyscanner)
1461{
1462 register yy_state_type yy_current_state;
1463 register char *yy_cp;
1464 struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
1465
1466 yy_current_state = yyg->yy_start;
1467
1468 for ( yy_cp = yyg->yytext_ptr + YY_MORE_ADJ; yy_cp < yyg->yy_c_buf_p; ++yy_cp )
1469 {
1470 register YY_CHAR yy_c = (*yy_cp ? yy_ec[YY_SC_TO_UI(*yy_cp)] : 1);
1471 if ( yy_accept[yy_current_state] )
1472 {
1473 yyg->yy_last_accepting_state = yy_current_state;
1474 yyg->yy_last_accepting_cpos = yy_cp;
1475 }
1476 while ( yy_chk[yy_base[yy_current_state] + yy_c] != yy_current_state )
1477 {
1478 yy_current_state = (int) yy_def[yy_current_state];
shannonwoods@chromium.org2a5436f2013-05-30 00:21:41 +00001479 if ( yy_current_state >= 98 )
alokp@chromium.org04d7d222012-05-16 19:24:07 +00001480 yy_c = yy_meta[(unsigned int) yy_c];
1481 }
1482 yy_current_state = yy_nxt[yy_base[yy_current_state] + (unsigned int) yy_c];
1483 }
1484
1485 return yy_current_state;
1486}
1487
1488/* yy_try_NUL_trans - try to make a transition on the NUL character
1489 *
1490 * synopsis
1491 * next_state = yy_try_NUL_trans( current_state );
1492 */
1493 static yy_state_type yy_try_NUL_trans (yy_state_type yy_current_state , yyscan_t yyscanner)
1494{
1495 register int yy_is_jam;
1496 struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; /* This var may be unused depending upon options. */
1497 register char *yy_cp = yyg->yy_c_buf_p;
1498
1499 register YY_CHAR yy_c = 1;
1500 if ( yy_accept[yy_current_state] )
1501 {
1502 yyg->yy_last_accepting_state = yy_current_state;
1503 yyg->yy_last_accepting_cpos = yy_cp;
1504 }
1505 while ( yy_chk[yy_base[yy_current_state] + yy_c] != yy_current_state )
1506 {
1507 yy_current_state = (int) yy_def[yy_current_state];
shannonwoods@chromium.org2a5436f2013-05-30 00:21:41 +00001508 if ( yy_current_state >= 98 )
alokp@chromium.org04d7d222012-05-16 19:24:07 +00001509 yy_c = yy_meta[(unsigned int) yy_c];
1510 }
1511 yy_current_state = yy_nxt[yy_base[yy_current_state] + (unsigned int) yy_c];
shannonwoods@chromium.org2a5436f2013-05-30 00:21:41 +00001512 yy_is_jam = (yy_current_state == 97);
alokp@chromium.org04d7d222012-05-16 19:24:07 +00001513
Zhenyao Mof1d723c2013-09-23 14:57:07 -04001514 (void)yyg;
alokp@chromium.org04d7d222012-05-16 19:24:07 +00001515 return yy_is_jam ? 0 : yy_current_state;
1516}
1517
1518#ifndef YY_NO_INPUT
1519#ifdef __cplusplus
1520 static int yyinput (yyscan_t yyscanner)
1521#else
1522 static int input (yyscan_t yyscanner)
1523#endif
1524
1525{
1526 int c;
1527 struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
1528
1529 *yyg->yy_c_buf_p = yyg->yy_hold_char;
1530
1531 if ( *yyg->yy_c_buf_p == YY_END_OF_BUFFER_CHAR )
1532 {
1533 /* yy_c_buf_p now points to the character we want to return.
1534 * If this occurs *before* the EOB characters, then it's a
1535 * valid NUL; if not, then we've hit the end of the buffer.
1536 */
1537 if ( yyg->yy_c_buf_p < &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[yyg->yy_n_chars] )
1538 /* This was really a NUL. */
1539 *yyg->yy_c_buf_p = '\0';
1540
1541 else
1542 { /* need more input */
shannonwoods@chromium.orgb0757162013-05-30 00:21:27 +00001543 yy_size_t offset = yyg->yy_c_buf_p - yyg->yytext_ptr;
alokp@chromium.org04d7d222012-05-16 19:24:07 +00001544 ++yyg->yy_c_buf_p;
1545
1546 switch ( yy_get_next_buffer( yyscanner ) )
1547 {
1548 case EOB_ACT_LAST_MATCH:
1549 /* This happens because yy_g_n_b()
1550 * sees that we've accumulated a
1551 * token and flags that we need to
1552 * try matching the token before
1553 * proceeding. But for input(),
1554 * there's no matching to consider.
1555 * So convert the EOB_ACT_LAST_MATCH
1556 * to EOB_ACT_END_OF_FILE.
1557 */
1558
1559 /* Reset buffer status. */
1560 pprestart(yyin ,yyscanner);
1561
1562 /*FALLTHROUGH*/
1563
1564 case EOB_ACT_END_OF_FILE:
1565 {
1566 if ( ppwrap(yyscanner ) )
shannonwoods@chromium.org4b8a3112013-05-30 00:13:01 +00001567 return EOF;
alokp@chromium.org04d7d222012-05-16 19:24:07 +00001568
1569 if ( ! yyg->yy_did_buffer_switch_on_eof )
1570 YY_NEW_FILE;
1571#ifdef __cplusplus
1572 return yyinput(yyscanner);
1573#else
1574 return input(yyscanner);
1575#endif
1576 }
1577
1578 case EOB_ACT_CONTINUE_SCAN:
1579 yyg->yy_c_buf_p = yyg->yytext_ptr + offset;
1580 break;
1581 }
1582 }
1583 }
1584
1585 c = *(unsigned char *) yyg->yy_c_buf_p; /* cast for 8-bit char's */
1586 *yyg->yy_c_buf_p = '\0'; /* preserve yytext */
1587 yyg->yy_hold_char = *++yyg->yy_c_buf_p;
1588
1589 return c;
1590}
1591#endif /* ifndef YY_NO_INPUT */
1592
1593/** Immediately switch to a different input stream.
1594 * @param input_file A readable stream.
1595 * @param yyscanner The scanner object.
1596 * @note This function does not reset the start condition to @c INITIAL .
1597 */
1598 void pprestart (FILE * input_file , yyscan_t yyscanner)
1599{
1600 struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
1601
1602 if ( ! YY_CURRENT_BUFFER ){
1603 ppensure_buffer_stack (yyscanner);
1604 YY_CURRENT_BUFFER_LVALUE =
1605 pp_create_buffer(yyin,YY_BUF_SIZE ,yyscanner);
1606 }
1607
1608 pp_init_buffer(YY_CURRENT_BUFFER,input_file ,yyscanner);
1609 pp_load_buffer_state(yyscanner );
1610}
1611
1612/** Switch to a different input buffer.
1613 * @param new_buffer The new input buffer.
1614 * @param yyscanner The scanner object.
1615 */
1616 void pp_switch_to_buffer (YY_BUFFER_STATE new_buffer , yyscan_t yyscanner)
1617{
1618 struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
1619
1620 /* TODO. We should be able to replace this entire function body
1621 * with
1622 * pppop_buffer_state();
1623 * pppush_buffer_state(new_buffer);
1624 */
1625 ppensure_buffer_stack (yyscanner);
1626 if ( YY_CURRENT_BUFFER == new_buffer )
1627 return;
1628
1629 if ( YY_CURRENT_BUFFER )
1630 {
1631 /* Flush out information for old buffer. */
1632 *yyg->yy_c_buf_p = yyg->yy_hold_char;
1633 YY_CURRENT_BUFFER_LVALUE->yy_buf_pos = yyg->yy_c_buf_p;
1634 YY_CURRENT_BUFFER_LVALUE->yy_n_chars = yyg->yy_n_chars;
1635 }
1636
1637 YY_CURRENT_BUFFER_LVALUE = new_buffer;
1638 pp_load_buffer_state(yyscanner );
1639
1640 /* We don't actually know whether we did this switch during
1641 * EOF (ppwrap()) processing, but the only time this flag
1642 * is looked at is after ppwrap() is called, so it's safe
1643 * to go ahead and always set it.
1644 */
1645 yyg->yy_did_buffer_switch_on_eof = 1;
1646}
1647
1648static void pp_load_buffer_state (yyscan_t yyscanner)
1649{
1650 struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
1651 yyg->yy_n_chars = YY_CURRENT_BUFFER_LVALUE->yy_n_chars;
1652 yyg->yytext_ptr = yyg->yy_c_buf_p = YY_CURRENT_BUFFER_LVALUE->yy_buf_pos;
1653 yyin = YY_CURRENT_BUFFER_LVALUE->yy_input_file;
1654 yyg->yy_hold_char = *yyg->yy_c_buf_p;
1655}
1656
1657/** Allocate and initialize an input buffer state.
1658 * @param file A readable stream.
1659 * @param size The character buffer size in bytes. When in doubt, use @c YY_BUF_SIZE.
1660 * @param yyscanner The scanner object.
1661 * @return the allocated buffer state.
1662 */
1663 YY_BUFFER_STATE pp_create_buffer (FILE * file, int size , yyscan_t yyscanner)
1664{
1665 YY_BUFFER_STATE b;
1666
1667 b = (YY_BUFFER_STATE) ppalloc(sizeof( struct yy_buffer_state ) ,yyscanner );
1668 if ( ! b )
1669 YY_FATAL_ERROR( "out of dynamic memory in pp_create_buffer()" );
1670
1671 b->yy_buf_size = size;
1672
1673 /* yy_ch_buf has to be 2 characters longer than the size given because
1674 * we need to put in 2 end-of-buffer characters.
1675 */
1676 b->yy_ch_buf = (char *) ppalloc(b->yy_buf_size + 2 ,yyscanner );
1677 if ( ! b->yy_ch_buf )
1678 YY_FATAL_ERROR( "out of dynamic memory in pp_create_buffer()" );
1679
1680 b->yy_is_our_buffer = 1;
1681
1682 pp_init_buffer(b,file ,yyscanner);
1683
1684 return b;
1685}
1686
1687/** Destroy the buffer.
1688 * @param b a buffer created with pp_create_buffer()
1689 * @param yyscanner The scanner object.
1690 */
1691 void pp_delete_buffer (YY_BUFFER_STATE b , yyscan_t yyscanner)
1692{
1693 struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
1694
1695 if ( ! b )
1696 return;
1697
1698 if ( b == YY_CURRENT_BUFFER ) /* Not sure if we should pop here. */
1699 YY_CURRENT_BUFFER_LVALUE = (YY_BUFFER_STATE) 0;
1700
1701 if ( b->yy_is_our_buffer )
1702 ppfree((void *) b->yy_ch_buf ,yyscanner );
1703
1704 ppfree((void *) b ,yyscanner );
1705}
1706
1707/* Initializes or reinitializes a buffer.
1708 * This function is sometimes called more than once on the same buffer,
1709 * such as during a pprestart() or at EOF.
1710 */
1711 static void pp_init_buffer (YY_BUFFER_STATE b, FILE * file , yyscan_t yyscanner)
1712
1713{
1714 int oerrno = errno;
1715 struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
1716
1717 pp_flush_buffer(b ,yyscanner);
1718
1719 b->yy_input_file = file;
1720 b->yy_fill_buffer = 1;
1721
1722 /* If b is the current buffer, then pp_init_buffer was _probably_
1723 * called from pprestart() or through yy_get_next_buffer.
1724 * In that case, we don't want to reset the lineno or column.
1725 */
1726 if (b != YY_CURRENT_BUFFER){
1727 b->yy_bs_lineno = 1;
1728 b->yy_bs_column = 0;
1729 }
1730
1731 b->yy_is_interactive = 0;
1732
1733 errno = oerrno;
1734}
1735
1736/** Discard all buffered characters. On the next scan, YY_INPUT will be called.
1737 * @param b the buffer state to be flushed, usually @c YY_CURRENT_BUFFER.
1738 * @param yyscanner The scanner object.
1739 */
1740 void pp_flush_buffer (YY_BUFFER_STATE b , yyscan_t yyscanner)
1741{
1742 struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
1743 if ( ! b )
1744 return;
1745
1746 b->yy_n_chars = 0;
1747
1748 /* We always need two end-of-buffer characters. The first causes
1749 * a transition to the end-of-buffer state. The second causes
1750 * a jam in that state.
1751 */
1752 b->yy_ch_buf[0] = YY_END_OF_BUFFER_CHAR;
1753 b->yy_ch_buf[1] = YY_END_OF_BUFFER_CHAR;
1754
1755 b->yy_buf_pos = &b->yy_ch_buf[0];
1756
1757 b->yy_at_bol = 1;
1758 b->yy_buffer_status = YY_BUFFER_NEW;
1759
1760 if ( b == YY_CURRENT_BUFFER )
1761 pp_load_buffer_state(yyscanner );
1762}
1763
1764/** Pushes the new state onto the stack. The new state becomes
1765 * the current state. This function will allocate the stack
1766 * if necessary.
1767 * @param new_buffer The new state.
1768 * @param yyscanner The scanner object.
1769 */
1770void pppush_buffer_state (YY_BUFFER_STATE new_buffer , yyscan_t yyscanner)
1771{
1772 struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
1773 if (new_buffer == NULL)
1774 return;
1775
1776 ppensure_buffer_stack(yyscanner);
1777
1778 /* This block is copied from pp_switch_to_buffer. */
1779 if ( YY_CURRENT_BUFFER )
1780 {
1781 /* Flush out information for old buffer. */
1782 *yyg->yy_c_buf_p = yyg->yy_hold_char;
1783 YY_CURRENT_BUFFER_LVALUE->yy_buf_pos = yyg->yy_c_buf_p;
1784 YY_CURRENT_BUFFER_LVALUE->yy_n_chars = yyg->yy_n_chars;
1785 }
1786
1787 /* Only push if top exists. Otherwise, replace top. */
1788 if (YY_CURRENT_BUFFER)
1789 yyg->yy_buffer_stack_top++;
1790 YY_CURRENT_BUFFER_LVALUE = new_buffer;
1791
1792 /* copied from pp_switch_to_buffer. */
1793 pp_load_buffer_state(yyscanner );
1794 yyg->yy_did_buffer_switch_on_eof = 1;
1795}
1796
1797/** Removes and deletes the top of the stack, if present.
1798 * The next element becomes the new top.
1799 * @param yyscanner The scanner object.
1800 */
1801void pppop_buffer_state (yyscan_t yyscanner)
1802{
1803 struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
1804 if (!YY_CURRENT_BUFFER)
1805 return;
1806
1807 pp_delete_buffer(YY_CURRENT_BUFFER ,yyscanner);
1808 YY_CURRENT_BUFFER_LVALUE = NULL;
1809 if (yyg->yy_buffer_stack_top > 0)
1810 --yyg->yy_buffer_stack_top;
1811
1812 if (YY_CURRENT_BUFFER) {
1813 pp_load_buffer_state(yyscanner );
1814 yyg->yy_did_buffer_switch_on_eof = 1;
1815 }
1816}
1817
1818/* Allocates the stack if it does not exist.
1819 * Guarantees space for at least one push.
1820 */
1821static void ppensure_buffer_stack (yyscan_t yyscanner)
1822{
shannonwoods@chromium.orgb0757162013-05-30 00:21:27 +00001823 yy_size_t num_to_alloc;
alokp@chromium.org04d7d222012-05-16 19:24:07 +00001824 struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
1825
1826 if (!yyg->yy_buffer_stack) {
1827
1828 /* First allocation is just for 2 elements, since we don't know if this
1829 * scanner will even need a stack. We use 2 instead of 1 to avoid an
1830 * immediate realloc on the next call.
1831 */
1832 num_to_alloc = 1;
1833 yyg->yy_buffer_stack = (struct yy_buffer_state**)ppalloc
1834 (num_to_alloc * sizeof(struct yy_buffer_state*)
1835 , yyscanner);
1836 if ( ! yyg->yy_buffer_stack )
1837 YY_FATAL_ERROR( "out of dynamic memory in ppensure_buffer_stack()" );
1838
1839 memset(yyg->yy_buffer_stack, 0, num_to_alloc * sizeof(struct yy_buffer_state*));
1840
1841 yyg->yy_buffer_stack_max = num_to_alloc;
1842 yyg->yy_buffer_stack_top = 0;
1843 return;
1844 }
1845
1846 if (yyg->yy_buffer_stack_top >= (yyg->yy_buffer_stack_max) - 1){
1847
1848 /* Increase the buffer to prepare for a possible push. */
1849 int grow_size = 8 /* arbitrary grow size */;
1850
1851 num_to_alloc = yyg->yy_buffer_stack_max + grow_size;
1852 yyg->yy_buffer_stack = (struct yy_buffer_state**)pprealloc
1853 (yyg->yy_buffer_stack,
1854 num_to_alloc * sizeof(struct yy_buffer_state*)
1855 , yyscanner);
1856 if ( ! yyg->yy_buffer_stack )
1857 YY_FATAL_ERROR( "out of dynamic memory in ppensure_buffer_stack()" );
1858
1859 /* zero only the new slots.*/
1860 memset(yyg->yy_buffer_stack + yyg->yy_buffer_stack_max, 0, grow_size * sizeof(struct yy_buffer_state*));
1861 yyg->yy_buffer_stack_max = num_to_alloc;
1862 }
1863}
1864
1865/** Setup the input buffer state to scan directly from a user-specified character buffer.
1866 * @param base the character buffer
1867 * @param size the size in bytes of the character buffer
1868 * @param yyscanner The scanner object.
1869 * @return the newly allocated buffer state object.
1870 */
1871YY_BUFFER_STATE pp_scan_buffer (char * base, yy_size_t size , yyscan_t yyscanner)
1872{
1873 YY_BUFFER_STATE b;
1874
1875 if ( size < 2 ||
1876 base[size-2] != YY_END_OF_BUFFER_CHAR ||
1877 base[size-1] != YY_END_OF_BUFFER_CHAR )
1878 /* They forgot to leave room for the EOB's. */
1879 return 0;
1880
1881 b = (YY_BUFFER_STATE) ppalloc(sizeof( struct yy_buffer_state ) ,yyscanner );
1882 if ( ! b )
1883 YY_FATAL_ERROR( "out of dynamic memory in pp_scan_buffer()" );
1884
1885 b->yy_buf_size = size - 2; /* "- 2" to take care of EOB's */
1886 b->yy_buf_pos = b->yy_ch_buf = base;
1887 b->yy_is_our_buffer = 0;
1888 b->yy_input_file = 0;
1889 b->yy_n_chars = b->yy_buf_size;
1890 b->yy_is_interactive = 0;
1891 b->yy_at_bol = 1;
1892 b->yy_fill_buffer = 0;
1893 b->yy_buffer_status = YY_BUFFER_NEW;
1894
1895 pp_switch_to_buffer(b ,yyscanner );
1896
1897 return b;
1898}
1899
1900/** Setup the input buffer state to scan a string. The next call to pplex() will
1901 * scan from a @e copy of @a str.
1902 * @param yystr a NUL-terminated string to scan
1903 * @param yyscanner The scanner object.
1904 * @return the newly allocated buffer state object.
1905 * @note If you want to scan bytes that may contain NUL values, then use
1906 * pp_scan_bytes() instead.
1907 */
1908YY_BUFFER_STATE pp_scan_string (yyconst char * yystr , yyscan_t yyscanner)
1909{
1910
1911 return pp_scan_bytes(yystr,strlen(yystr) ,yyscanner);
1912}
1913
1914/** Setup the input buffer state to scan the given bytes. The next call to pplex() will
1915 * scan from a @e copy of @a bytes.
Zhenyao Mof1d723c2013-09-23 14:57:07 -04001916 * @param yybytes the byte buffer to scan
1917 * @param _yybytes_len the number of bytes in the buffer pointed to by @a bytes.
alokp@chromium.org04d7d222012-05-16 19:24:07 +00001918 * @param yyscanner The scanner object.
1919 * @return the newly allocated buffer state object.
1920 */
shannonwoods@chromium.orgb0757162013-05-30 00:21:27 +00001921YY_BUFFER_STATE pp_scan_bytes (yyconst char * yybytes, yy_size_t _yybytes_len , yyscan_t yyscanner)
alokp@chromium.org04d7d222012-05-16 19:24:07 +00001922{
1923 YY_BUFFER_STATE b;
1924 char *buf;
Zhenyao Mof1d723c2013-09-23 14:57:07 -04001925 yy_size_t n;
1926 yy_size_t i;
alokp@chromium.org04d7d222012-05-16 19:24:07 +00001927
1928 /* Get memory for full buffer, including space for trailing EOB's. */
1929 n = _yybytes_len + 2;
1930 buf = (char *) ppalloc(n ,yyscanner );
1931 if ( ! buf )
1932 YY_FATAL_ERROR( "out of dynamic memory in pp_scan_bytes()" );
1933
1934 for ( i = 0; i < _yybytes_len; ++i )
1935 buf[i] = yybytes[i];
1936
1937 buf[_yybytes_len] = buf[_yybytes_len+1] = YY_END_OF_BUFFER_CHAR;
1938
1939 b = pp_scan_buffer(buf,n ,yyscanner);
1940 if ( ! b )
1941 YY_FATAL_ERROR( "bad buffer in pp_scan_bytes()" );
1942
1943 /* It's okay to grow etc. this buffer, and we should throw it
1944 * away when we're done.
1945 */
1946 b->yy_is_our_buffer = 1;
1947
1948 return b;
1949}
1950
1951#ifndef YY_EXIT_FAILURE
1952#define YY_EXIT_FAILURE 2
1953#endif
1954
1955static void yy_fatal_error (yyconst char* msg , yyscan_t yyscanner)
1956{
1957 (void) fprintf( stderr, "%s\n", msg );
1958 exit( YY_EXIT_FAILURE );
1959}
1960
1961/* Redefine yyless() so it works in section 3 code. */
1962
1963#undef yyless
1964#define yyless(n) \
1965 do \
1966 { \
1967 /* Undo effects of setting up yytext. */ \
1968 int yyless_macro_arg = (n); \
1969 YY_LESS_LINENO(yyless_macro_arg);\
1970 yytext[yyleng] = yyg->yy_hold_char; \
1971 yyg->yy_c_buf_p = yytext + yyless_macro_arg; \
1972 yyg->yy_hold_char = *yyg->yy_c_buf_p; \
1973 *yyg->yy_c_buf_p = '\0'; \
1974 yyleng = yyless_macro_arg; \
1975 } \
1976 while ( 0 )
1977
1978/* Accessor methods (get/set functions) to struct members. */
1979
1980/** Get the user-defined data for this scanner.
1981 * @param yyscanner The scanner object.
1982 */
1983YY_EXTRA_TYPE ppget_extra (yyscan_t yyscanner)
1984{
1985 struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
1986 return yyextra;
1987}
1988
1989/** Get the current line number.
1990 * @param yyscanner The scanner object.
1991 */
1992int ppget_lineno (yyscan_t yyscanner)
1993{
1994 struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
1995
1996 if (! YY_CURRENT_BUFFER)
1997 return 0;
1998
1999 return yylineno;
2000}
2001
2002/** Get the current column number.
2003 * @param yyscanner The scanner object.
2004 */
2005int ppget_column (yyscan_t yyscanner)
2006{
2007 struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
2008
2009 if (! YY_CURRENT_BUFFER)
2010 return 0;
2011
2012 return yycolumn;
2013}
2014
2015/** Get the input stream.
2016 * @param yyscanner The scanner object.
2017 */
2018FILE *ppget_in (yyscan_t yyscanner)
2019{
2020 struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
2021 return yyin;
2022}
2023
2024/** Get the output stream.
2025 * @param yyscanner The scanner object.
2026 */
2027FILE *ppget_out (yyscan_t yyscanner)
2028{
2029 struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
2030 return yyout;
2031}
2032
2033/** Get the length of the current token.
2034 * @param yyscanner The scanner object.
2035 */
shannonwoods@chromium.orgb0757162013-05-30 00:21:27 +00002036yy_size_t ppget_leng (yyscan_t yyscanner)
alokp@chromium.org04d7d222012-05-16 19:24:07 +00002037{
2038 struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
2039 return yyleng;
2040}
2041
2042/** Get the current token.
2043 * @param yyscanner The scanner object.
2044 */
2045
2046char *ppget_text (yyscan_t yyscanner)
2047{
2048 struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
2049 return yytext;
2050}
2051
2052/** Set the user-defined data. This data is never touched by the scanner.
2053 * @param user_defined The data to be associated with this scanner.
2054 * @param yyscanner The scanner object.
2055 */
2056void ppset_extra (YY_EXTRA_TYPE user_defined , yyscan_t yyscanner)
2057{
2058 struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
2059 yyextra = user_defined ;
2060}
2061
2062/** Set the current line number.
2063 * @param line_number
2064 * @param yyscanner The scanner object.
2065 */
2066void ppset_lineno (int line_number , yyscan_t yyscanner)
2067{
2068 struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
2069
2070 /* lineno is only valid if an input buffer exists. */
2071 if (! YY_CURRENT_BUFFER )
Zhenyao Mof1d723c2013-09-23 14:57:07 -04002072 YY_FATAL_ERROR( "ppset_lineno called with no buffer" );
alokp@chromium.org04d7d222012-05-16 19:24:07 +00002073
2074 yylineno = line_number;
2075}
2076
2077/** Set the current column.
2078 * @param line_number
2079 * @param yyscanner The scanner object.
2080 */
2081void ppset_column (int column_no , yyscan_t yyscanner)
2082{
2083 struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
2084
2085 /* column is only valid if an input buffer exists. */
2086 if (! YY_CURRENT_BUFFER )
Zhenyao Mof1d723c2013-09-23 14:57:07 -04002087 YY_FATAL_ERROR( "ppset_column called with no buffer" );
alokp@chromium.org04d7d222012-05-16 19:24:07 +00002088
2089 yycolumn = column_no;
2090}
2091
2092/** Set the input stream. This does not discard the current
2093 * input buffer.
2094 * @param in_str A readable stream.
2095 * @param yyscanner The scanner object.
2096 * @see pp_switch_to_buffer
2097 */
2098void ppset_in (FILE * in_str , yyscan_t yyscanner)
2099{
2100 struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
2101 yyin = in_str ;
2102}
2103
2104void ppset_out (FILE * out_str , yyscan_t yyscanner)
2105{
2106 struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
2107 yyout = out_str ;
2108}
2109
2110int ppget_debug (yyscan_t yyscanner)
2111{
2112 struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
2113 return yy_flex_debug;
2114}
2115
2116void ppset_debug (int bdebug , yyscan_t yyscanner)
2117{
2118 struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
2119 yy_flex_debug = bdebug ;
2120}
2121
2122/* Accessor methods for yylval and yylloc */
2123
2124YYSTYPE * ppget_lval (yyscan_t yyscanner)
2125{
2126 struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
2127 return yylval;
2128}
2129
2130void ppset_lval (YYSTYPE * yylval_param , yyscan_t yyscanner)
2131{
2132 struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
2133 yylval = yylval_param;
2134}
2135
2136YYLTYPE *ppget_lloc (yyscan_t yyscanner)
2137{
2138 struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
2139 return yylloc;
2140}
2141
2142void ppset_lloc (YYLTYPE * yylloc_param , yyscan_t yyscanner)
2143{
2144 struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
2145 yylloc = yylloc_param;
2146}
2147
2148/* User-visible API */
2149
2150/* pplex_init is special because it creates the scanner itself, so it is
2151 * the ONLY reentrant function that doesn't take the scanner as the last argument.
2152 * That's why we explicitly handle the declaration, instead of using our macros.
2153 */
2154
2155int pplex_init(yyscan_t* ptr_yy_globals)
2156
2157{
2158 if (ptr_yy_globals == NULL){
2159 errno = EINVAL;
2160 return 1;
2161 }
2162
2163 *ptr_yy_globals = (yyscan_t) ppalloc ( sizeof( struct yyguts_t ), NULL );
2164
2165 if (*ptr_yy_globals == NULL){
2166 errno = ENOMEM;
2167 return 1;
2168 }
2169
2170 /* By setting to 0xAA, we expose bugs in yy_init_globals. Leave at 0x00 for releases. */
2171 memset(*ptr_yy_globals,0x00,sizeof(struct yyguts_t));
2172
2173 return yy_init_globals ( *ptr_yy_globals );
2174}
2175
2176/* pplex_init_extra has the same functionality as pplex_init, but follows the
2177 * convention of taking the scanner as the last argument. Note however, that
2178 * this is a *pointer* to a scanner, as it will be allocated by this call (and
2179 * is the reason, too, why this function also must handle its own declaration).
2180 * The user defined value in the first argument will be available to ppalloc in
2181 * the yyextra field.
2182 */
2183
2184int pplex_init_extra(YY_EXTRA_TYPE yy_user_defined,yyscan_t* ptr_yy_globals )
2185
2186{
2187 struct yyguts_t dummy_yyguts;
2188
2189 ppset_extra (yy_user_defined, &dummy_yyguts);
2190
2191 if (ptr_yy_globals == NULL){
2192 errno = EINVAL;
2193 return 1;
2194 }
2195
2196 *ptr_yy_globals = (yyscan_t) ppalloc ( sizeof( struct yyguts_t ), &dummy_yyguts );
2197
2198 if (*ptr_yy_globals == NULL){
2199 errno = ENOMEM;
2200 return 1;
2201 }
2202
2203 /* By setting to 0xAA, we expose bugs in
2204 yy_init_globals. Leave at 0x00 for releases. */
2205 memset(*ptr_yy_globals,0x00,sizeof(struct yyguts_t));
2206
2207 ppset_extra (yy_user_defined, *ptr_yy_globals);
2208
2209 return yy_init_globals ( *ptr_yy_globals );
2210}
2211
2212static int yy_init_globals (yyscan_t yyscanner)
2213{
2214 struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
2215 /* Initialization is the same as for the non-reentrant scanner.
2216 * This function is called from pplex_destroy(), so don't allocate here.
2217 */
2218
2219 yyg->yy_buffer_stack = 0;
2220 yyg->yy_buffer_stack_top = 0;
2221 yyg->yy_buffer_stack_max = 0;
2222 yyg->yy_c_buf_p = (char *) 0;
2223 yyg->yy_init = 0;
2224 yyg->yy_start = 0;
2225
2226 yyg->yy_start_stack_ptr = 0;
2227 yyg->yy_start_stack_depth = 0;
2228 yyg->yy_start_stack = NULL;
2229
2230/* Defined in main.c */
2231#ifdef YY_STDINIT
2232 yyin = stdin;
2233 yyout = stdout;
2234#else
2235 yyin = (FILE *) 0;
2236 yyout = (FILE *) 0;
2237#endif
2238
2239 /* For future reference: Set errno on error, since we are called by
2240 * pplex_init()
2241 */
2242 return 0;
2243}
2244
2245/* pplex_destroy is for both reentrant and non-reentrant scanners. */
2246int pplex_destroy (yyscan_t yyscanner)
2247{
2248 struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
2249
2250 /* Pop the buffer stack, destroying each element. */
2251 while(YY_CURRENT_BUFFER){
2252 pp_delete_buffer(YY_CURRENT_BUFFER ,yyscanner );
2253 YY_CURRENT_BUFFER_LVALUE = NULL;
2254 pppop_buffer_state(yyscanner);
2255 }
2256
2257 /* Destroy the stack itself. */
2258 ppfree(yyg->yy_buffer_stack ,yyscanner);
2259 yyg->yy_buffer_stack = NULL;
2260
2261 /* Destroy the start condition stack. */
2262 ppfree(yyg->yy_start_stack ,yyscanner );
2263 yyg->yy_start_stack = NULL;
2264
2265 /* Reset the globals. This is important in a non-reentrant scanner so the next time
2266 * pplex() is called, initialization will occur. */
2267 yy_init_globals( yyscanner);
2268
2269 /* Destroy the main struct (reentrant only). */
2270 ppfree ( yyscanner , yyscanner );
2271 yyscanner = NULL;
2272 return 0;
2273}
2274
2275/*
2276 * Internal utility routines.
2277 */
2278
2279#ifndef yytext_ptr
2280static void yy_flex_strncpy (char* s1, yyconst char * s2, int n , yyscan_t yyscanner)
2281{
2282 register int i;
2283 for ( i = 0; i < n; ++i )
2284 s1[i] = s2[i];
2285}
2286#endif
2287
2288#ifdef YY_NEED_STRLEN
2289static int yy_flex_strlen (yyconst char * s , yyscan_t yyscanner)
2290{
2291 register int n;
2292 for ( n = 0; s[n]; ++n )
2293 ;
2294
2295 return n;
2296}
2297#endif
2298
2299void *ppalloc (yy_size_t size , yyscan_t yyscanner)
2300{
2301 return (void *) malloc( size );
2302}
2303
2304void *pprealloc (void * ptr, yy_size_t size , yyscan_t yyscanner)
2305{
2306 /* The cast to (char *) in the following accommodates both
2307 * implementations that use char* generic pointers, and those
2308 * that use void* generic pointers. It works with the latter
2309 * because both ANSI C and C++ allow castless assignment from
2310 * any pointer type to void*, and deal with argument conversions
2311 * as though doing an assignment.
2312 */
2313 return (void *) realloc( (char *) ptr, size );
2314}
2315
2316void ppfree (void * ptr , yyscan_t yyscanner)
2317{
2318 free( (char *) ptr ); /* see pprealloc() for (char *) cast */
2319}
2320
2321#define YYTABLES_NAME "yytables"
2322
2323namespace pp {
2324
Zhenyao Mod526f982014-05-13 14:51:19 -07002325Tokenizer::Tokenizer(Diagnostics *diagnostics)
Jamie Madill5508f392014-02-20 13:31:36 -05002326 : mHandle(0),
2327 mMaxTokenSize(256)
alokp@chromium.org04d7d222012-05-16 19:24:07 +00002328{
alokp@chromium.org2c958ee2012-05-17 20:35:42 +00002329 mContext.diagnostics = diagnostics;
alokp@chromium.org04d7d222012-05-16 19:24:07 +00002330}
2331
2332Tokenizer::~Tokenizer()
2333{
2334 destroyScanner();
2335}
2336
Zhenyao Mod526f982014-05-13 14:51:19 -07002337bool Tokenizer::init(size_t count, const char * const string[], const int length[])
alokp@chromium.org04d7d222012-05-16 19:24:07 +00002338{
Zhenyao Mod526f982014-05-13 14:51:19 -07002339 if ((count > 0) && (string == 0))
2340 return false;
alokp@chromium.org04d7d222012-05-16 19:24:07 +00002341
2342 mContext.input = Input(count, string, length);
2343 return initScanner();
2344}
2345
alokp@chromium.org46aa13d2012-06-15 15:40:27 +00002346void Tokenizer::setFileNumber(int file)
2347{
2348 // We use column number as file number.
2349 // See macro yyfileno.
2350 ppset_column(file,mHandle);
2351}
2352
2353void Tokenizer::setLineNumber(int line)
2354{
2355 ppset_lineno(line,mHandle);
2356}
2357
Jamie Madill5508f392014-02-20 13:31:36 -05002358void Tokenizer::setMaxTokenSize(size_t maxTokenSize)
2359{
2360 mMaxTokenSize = maxTokenSize;
2361}
2362
Zhenyao Mod526f982014-05-13 14:51:19 -07002363void Tokenizer::lex(Token *token)
alokp@chromium.org04d7d222012-05-16 19:24:07 +00002364{
alokp@chromium.org5b6a68e2012-06-28 20:29:13 +00002365 token->type = pplex(&token->text,&token->location,mHandle);
Jamie Madill5508f392014-02-20 13:31:36 -05002366 if (token->text.size() > mMaxTokenSize)
alokp@chromium.orgc022c3a2012-07-09 15:56:42 +00002367 {
Shannon Woods7f2d7942013-11-19 15:07:58 -05002368 mContext.diagnostics->report(Diagnostics::PP_TOKEN_TOO_LONG,
alokp@chromium.orgc022c3a2012-07-09 15:56:42 +00002369 token->location, token->text);
Jamie Madill5508f392014-02-20 13:31:36 -05002370 token->text.erase(mMaxTokenSize);
alokp@chromium.orgc022c3a2012-07-09 15:56:42 +00002371 }
2372
alokp@chromium.org7fc38dd2012-06-14 18:23:23 +00002373 token->flags = 0;
alokp@chromium.org04d7d222012-05-16 19:24:07 +00002374
alokp@chromium.org19d7aa62012-05-31 17:34:05 +00002375 token->setAtStartOfLine(mContext.lineStart);
2376 mContext.lineStart = token->type == '\n';
2377
alokp@chromium.org04d7d222012-05-16 19:24:07 +00002378 token->setHasLeadingSpace(mContext.leadingSpace);
2379 mContext.leadingSpace = false;
alokp@chromium.org04d7d222012-05-16 19:24:07 +00002380}
2381
2382bool Tokenizer::initScanner()
2383{
2384 if ((mHandle == NULL) && pplex_init_extra(&mContext,&mHandle))
2385 return false;
2386
2387 pprestart(0,mHandle);
2388 return true;
2389}
2390
2391void Tokenizer::destroyScanner()
2392{
2393 if (mHandle == NULL)
2394 return;
2395
2396 pplex_destroy(mHandle);
2397 mHandle = NULL;
2398}
2399
2400} // namespace pp
2401