blob: 76bd873e4d24ed112fd26af764aa49c25b0460b8 [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
Jamie Madill2dc8bf82015-04-30 15:56:52 -0400555// Workaround for flex using the register keyword, deprecated in C++11.
556#ifdef __cplusplus
557#if __cplusplus > 199711L
558#define register
559#endif
560#endif
561
alokp@chromium.org04d7d222012-05-16 19:24:07 +0000562typedef std::string YYSTYPE;
alokp@chromium.org2c958ee2012-05-17 20:35:42 +0000563typedef pp::SourceLocation YYLTYPE;
alokp@chromium.org04d7d222012-05-16 19:24:07 +0000564
565// Use the unused yycolumn variable to track file (string) number.
566#define yyfileno yycolumn
567
568#define YY_USER_INIT \
569 do { \
570 yyfileno = 0; \
571 yylineno = 1; \
572 yyextra->leadingSpace = false; \
573 yyextra->lineStart = true; \
574 } while(0);
575
alokp@chromium.org19d7aa62012-05-31 17:34:05 +0000576#define YY_USER_ACTION \
577 do \
578 { \
579 pp::Input* input = &yyextra->input; \
580 pp::Input::Location* scanLoc = &yyextra->scanLoc; \
581 while ((scanLoc->sIndex < input->count()) && \
582 (scanLoc->cIndex >= input->length(scanLoc->sIndex))) \
583 { \
584 scanLoc->cIndex -= input->length(scanLoc->sIndex++); \
585 ++yyfileno; yylineno = 1; \
586 } \
587 yylloc->file = yyfileno; \
588 yylloc->line = yylineno; \
589 scanLoc->cIndex += yyleng; \
alokp@chromium.org04d7d222012-05-16 19:24:07 +0000590 } while(0);
591
592#define YY_INPUT(buf, result, maxSize) \
593 result = yyextra->input.read(buf, maxSize);
594
595#define INITIAL 0
596#define COMMENT 1
597
598#define YY_EXTRA_TYPE pp::Tokenizer::Context*
599
600/* Holds the entire state of the reentrant scanner. */
601struct yyguts_t
602 {
603
604 /* User-defined. Not touched by flex. */
605 YY_EXTRA_TYPE yyextra_r;
606
607 /* The rest are the same as the globals declared in the non-reentrant scanner. */
608 FILE *yyin_r, *yyout_r;
609 size_t yy_buffer_stack_top; /**< index of top of stack. */
610 size_t yy_buffer_stack_max; /**< capacity of stack. */
611 YY_BUFFER_STATE * yy_buffer_stack; /**< Stack as an array. */
612 char yy_hold_char;
shannonwoods@chromium.orgb0757162013-05-30 00:21:27 +0000613 yy_size_t yy_n_chars;
614 yy_size_t yyleng_r;
alokp@chromium.org04d7d222012-05-16 19:24:07 +0000615 char *yy_c_buf_p;
616 int yy_init;
617 int yy_start;
618 int yy_did_buffer_switch_on_eof;
619 int yy_start_stack_ptr;
620 int yy_start_stack_depth;
621 int *yy_start_stack;
622 yy_state_type yy_last_accepting_state;
623 char* yy_last_accepting_cpos;
624
625 int yylineno_r;
626 int yy_flex_debug_r;
627
628 char *yytext_r;
629 int yy_more_flag;
630 int yy_more_len;
631
632 YYSTYPE * yylval_r;
633
634 YYLTYPE * yylloc_r;
635
636 }; /* end struct yyguts_t */
637
638static int yy_init_globals (yyscan_t yyscanner );
639
640 /* This must go here because YYSTYPE and YYLTYPE are included
641 * from bison output in section 1.*/
642 # define yylval yyg->yylval_r
643
644 # define yylloc yyg->yylloc_r
645
646int pplex_init (yyscan_t* scanner);
647
648int pplex_init_extra (YY_EXTRA_TYPE user_defined,yyscan_t* scanner);
649
650/* Accessor methods to globals.
651 These are made visible to non-reentrant scanners for convenience. */
652
653int pplex_destroy (yyscan_t yyscanner );
654
655int ppget_debug (yyscan_t yyscanner );
656
657void ppset_debug (int debug_flag ,yyscan_t yyscanner );
658
659YY_EXTRA_TYPE ppget_extra (yyscan_t yyscanner );
660
661void ppset_extra (YY_EXTRA_TYPE user_defined ,yyscan_t yyscanner );
662
663FILE *ppget_in (yyscan_t yyscanner );
664
665void ppset_in (FILE * in_str ,yyscan_t yyscanner );
666
667FILE *ppget_out (yyscan_t yyscanner );
668
669void ppset_out (FILE * out_str ,yyscan_t yyscanner );
670
shannonwoods@chromium.orgb0757162013-05-30 00:21:27 +0000671yy_size_t ppget_leng (yyscan_t yyscanner );
alokp@chromium.org04d7d222012-05-16 19:24:07 +0000672
673char *ppget_text (yyscan_t yyscanner );
674
675int ppget_lineno (yyscan_t yyscanner );
676
677void ppset_lineno (int line_number ,yyscan_t yyscanner );
678
Zhenyao Mof1d723c2013-09-23 14:57:07 -0400679int ppget_column (yyscan_t yyscanner );
680
681void ppset_column (int column_no ,yyscan_t yyscanner );
682
alokp@chromium.org04d7d222012-05-16 19:24:07 +0000683YYSTYPE * ppget_lval (yyscan_t yyscanner );
684
685void ppset_lval (YYSTYPE * yylval_param ,yyscan_t yyscanner );
686
687 YYLTYPE *ppget_lloc (yyscan_t yyscanner );
688
689 void ppset_lloc (YYLTYPE * yylloc_param ,yyscan_t yyscanner );
690
691/* Macros after this point can all be overridden by user definitions in
692 * section 1.
693 */
694
695#ifndef YY_SKIP_YYWRAP
696#ifdef __cplusplus
697extern "C" int ppwrap (yyscan_t yyscanner );
698#else
699extern int ppwrap (yyscan_t yyscanner );
700#endif
701#endif
702
703#ifndef yytext_ptr
704static void yy_flex_strncpy (char *,yyconst char *,int ,yyscan_t yyscanner);
705#endif
706
707#ifdef YY_NEED_STRLEN
708static int yy_flex_strlen (yyconst char * ,yyscan_t yyscanner);
709#endif
710
711#ifndef YY_NO_INPUT
712
713#ifdef __cplusplus
714static int yyinput (yyscan_t yyscanner );
715#else
716static int input (yyscan_t yyscanner );
717#endif
718
719#endif
720
721/* Amount of stuff to slurp up with each read. */
722#ifndef YY_READ_BUF_SIZE
723#define YY_READ_BUF_SIZE 8192
724#endif
725
726/* Copy whatever the last rule matched to the standard output. */
727#ifndef ECHO
728/* This used to be an fputs(), but since the string might contain NUL's,
729 * we now use fwrite().
730 */
Zhenyao Mof1d723c2013-09-23 14:57:07 -0400731#define ECHO do { if (fwrite( yytext, yyleng, 1, yyout )) {} } while (0)
alokp@chromium.org04d7d222012-05-16 19:24:07 +0000732#endif
733
734/* Gets input and stuffs it into "buf". number of characters read, or YY_NULL,
735 * is returned in "result".
736 */
737#ifndef YY_INPUT
738#define YY_INPUT(buf,result,max_size) \
739 if ( YY_CURRENT_BUFFER_LVALUE->yy_is_interactive ) \
740 { \
741 int c = '*'; \
Zhenyao Mof1d723c2013-09-23 14:57:07 -0400742 size_t n; \
alokp@chromium.org04d7d222012-05-16 19:24:07 +0000743 for ( n = 0; n < max_size && \
744 (c = getc( yyin )) != EOF && c != '\n'; ++n ) \
745 buf[n] = (char) c; \
746 if ( c == '\n' ) \
747 buf[n++] = (char) c; \
748 if ( c == EOF && ferror( yyin ) ) \
749 YY_FATAL_ERROR( "input in flex scanner failed" ); \
750 result = n; \
751 } \
752 else \
753 { \
754 errno=0; \
755 while ( (result = fread(buf, 1, max_size, yyin))==0 && ferror(yyin)) \
756 { \
757 if( errno != EINTR) \
758 { \
759 YY_FATAL_ERROR( "input in flex scanner failed" ); \
760 break; \
761 } \
762 errno=0; \
763 clearerr(yyin); \
764 } \
765 }\
766\
767
768#endif
769
770/* No semi-colon after return; correct usage is to write "yyterminate();" -
771 * we don't want an extra ';' after the "return" because that will cause
772 * some compilers to complain about unreachable statements.
773 */
774#ifndef yyterminate
775#define yyterminate() return YY_NULL
776#endif
777
778/* Number of entries by which start-condition stack grows. */
779#ifndef YY_START_STACK_INCR
780#define YY_START_STACK_INCR 25
781#endif
782
783/* Report a fatal error. */
784#ifndef YY_FATAL_ERROR
785#define YY_FATAL_ERROR(msg) yy_fatal_error( msg , yyscanner)
786#endif
787
788/* end tables serialization structures and prototypes */
789
790/* Default declaration of generated scanner - a define so the user can
791 * easily add parameters.
792 */
793#ifndef YY_DECL
794#define YY_DECL_IS_OURS 1
795
796extern int pplex \
797 (YYSTYPE * yylval_param,YYLTYPE * yylloc_param ,yyscan_t yyscanner);
798
799#define YY_DECL int pplex \
800 (YYSTYPE * yylval_param, YYLTYPE * yylloc_param , yyscan_t yyscanner)
801#endif /* !YY_DECL */
802
803/* Code executed at the beginning of each rule, after yytext and yyleng
804 * have been set up.
805 */
806#ifndef YY_USER_ACTION
807#define YY_USER_ACTION
808#endif
809
810/* Code executed at the end of each rule. */
811#ifndef YY_BREAK
812#define YY_BREAK break;
813#endif
814
815#define YY_RULE_SETUP \
816 YY_USER_ACTION
817
818/** The main scanner function which does all the work.
819 */
820YY_DECL
821{
822 register yy_state_type yy_current_state;
823 register char *yy_cp, *yy_bp;
824 register int yy_act;
825 struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
826
alokp@chromium.org04d7d222012-05-16 19:24:07 +0000827 yylval = yylval_param;
828
829 yylloc = yylloc_param;
830
831 if ( !yyg->yy_init )
832 {
833 yyg->yy_init = 1;
834
835#ifdef YY_USER_INIT
836 YY_USER_INIT;
837#endif
838
839 if ( ! yyg->yy_start )
840 yyg->yy_start = 1; /* first start state */
841
842 if ( ! yyin )
843 yyin = stdin;
844
845 if ( ! yyout )
846 yyout = stdout;
847
848 if ( ! YY_CURRENT_BUFFER ) {
849 ppensure_buffer_stack (yyscanner);
850 YY_CURRENT_BUFFER_LVALUE =
851 pp_create_buffer(yyin,YY_BUF_SIZE ,yyscanner);
852 }
853
854 pp_load_buffer_state(yyscanner );
855 }
856
Jamie Madill185de882014-12-22 15:17:52 -0500857 {
858
859 /* Line comment */
860
alokp@chromium.org04d7d222012-05-16 19:24:07 +0000861 while ( 1 ) /* loops until end-of-file is reached */
862 {
863 yy_cp = yyg->yy_c_buf_p;
864
865 /* Support of yytext. */
866 *yy_cp = yyg->yy_hold_char;
867
868 /* yy_bp points to the position in yy_ch_buf of the start of
869 * the current run.
870 */
871 yy_bp = yy_cp;
872
873 yy_current_state = yyg->yy_start;
874yy_match:
875 do
876 {
Jamie Madill185de882014-12-22 15:17:52 -0500877 register YY_CHAR yy_c = yy_ec[YY_SC_TO_UI(*yy_cp)] ;
alokp@chromium.org04d7d222012-05-16 19:24:07 +0000878 if ( yy_accept[yy_current_state] )
879 {
880 yyg->yy_last_accepting_state = yy_current_state;
881 yyg->yy_last_accepting_cpos = yy_cp;
882 }
883 while ( yy_chk[yy_base[yy_current_state] + yy_c] != yy_current_state )
884 {
885 yy_current_state = (int) yy_def[yy_current_state];
shannonwoods@chromium.org2a5436f2013-05-30 00:21:41 +0000886 if ( yy_current_state >= 98 )
alokp@chromium.org04d7d222012-05-16 19:24:07 +0000887 yy_c = yy_meta[(unsigned int) yy_c];
888 }
889 yy_current_state = yy_nxt[yy_base[yy_current_state] + (unsigned int) yy_c];
890 ++yy_cp;
891 }
shannonwoods@chromium.org2a5436f2013-05-30 00:21:41 +0000892 while ( yy_current_state != 97 );
alokp@chromium.org04d7d222012-05-16 19:24:07 +0000893 yy_cp = yyg->yy_last_accepting_cpos;
894 yy_current_state = yyg->yy_last_accepting_state;
895
896yy_find_action:
897 yy_act = yy_accept[yy_current_state];
898
899 YY_DO_BEFORE_ACTION;
900
901do_action: /* This label is used only to access EOF actions. */
902
903 switch ( yy_act )
904 { /* beginning of action switch */
905 case 0: /* must back up */
906 /* undo the effects of YY_DO_BEFORE_ACTION */
907 *yy_cp = yyg->yy_hold_char;
908 yy_cp = yyg->yy_last_accepting_cpos;
909 yy_current_state = yyg->yy_last_accepting_state;
910 goto yy_find_action;
911
912case 1:
913YY_RULE_SETUP
914
915 YY_BREAK
916/* Block comment */
917/* Line breaks are just counted - not returned. */
Jamie Madillb96687d2015-04-30 15:56:51 -0400918/* The comment is replaced by a single space. */
alokp@chromium.org04d7d222012-05-16 19:24:07 +0000919case 2:
920YY_RULE_SETUP
921{ BEGIN(COMMENT); }
922 YY_BREAK
923case 3:
924YY_RULE_SETUP
925
926 YY_BREAK
927case 4:
928YY_RULE_SETUP
929
930 YY_BREAK
931case 5:
932/* rule 5 can match eol */
933YY_RULE_SETUP
934{ ++yylineno; }
935 YY_BREAK
alokp@chromium.org04d7d222012-05-16 19:24:07 +0000936case 6:
937YY_RULE_SETUP
alokp@chromium.org2c958ee2012-05-17 20:35:42 +0000938{
939 yyextra->leadingSpace = true;
940 BEGIN(INITIAL);
941}
alokp@chromium.org04d7d222012-05-16 19:24:07 +0000942 YY_BREAK
943case 7:
944YY_RULE_SETUP
945{
946 // # is only valid at start of line for preprocessor directives.
alokp@chromium.org432d6fc2012-06-27 22:13:21 +0000947 yylval->assign(1, yytext[0]);
948 return yyextra->lineStart ? pp::Token::PP_HASH : pp::Token::PP_OTHER;
alokp@chromium.org04d7d222012-05-16 19:24:07 +0000949}
950 YY_BREAK
951case 8:
952YY_RULE_SETUP
953{
954 yylval->assign(yytext, yyleng);
955 return pp::Token::IDENTIFIER;
956}
957 YY_BREAK
958case 9:
959YY_RULE_SETUP
960{
961 yylval->assign(yytext, yyleng);
962 return pp::Token::CONST_INT;
963}
964 YY_BREAK
965case 10:
966YY_RULE_SETUP
967{
968 yylval->assign(yytext, yyleng);
969 return pp::Token::CONST_FLOAT;
970}
971 YY_BREAK
972/* Anything that starts with a {DIGIT} or .{DIGIT} must be a number. */
973/* Rule to catch all invalid integers and floats. */
974case 11:
975YY_RULE_SETUP
976{
alokp@chromium.org432d6fc2012-06-27 22:13:21 +0000977 yylval->assign(yytext, yyleng);
978 return pp::Token::PP_NUMBER;
alokp@chromium.org04d7d222012-05-16 19:24:07 +0000979}
980 YY_BREAK
981case 12:
982YY_RULE_SETUP
alokp@chromium.org07d921d2012-05-22 20:22:08 +0000983{
984 yylval->assign(yytext, yyleng);
985 return pp::Token::OP_INC;
986}
alokp@chromium.org04d7d222012-05-16 19:24:07 +0000987 YY_BREAK
988case 13:
989YY_RULE_SETUP
alokp@chromium.org07d921d2012-05-22 20:22:08 +0000990{
991 yylval->assign(yytext, yyleng);
992 return pp::Token::OP_DEC;
993}
alokp@chromium.org04d7d222012-05-16 19:24:07 +0000994 YY_BREAK
995case 14:
996YY_RULE_SETUP
alokp@chromium.org07d921d2012-05-22 20:22:08 +0000997{
998 yylval->assign(yytext, yyleng);
999 return pp::Token::OP_LEFT;
1000}
alokp@chromium.org04d7d222012-05-16 19:24:07 +00001001 YY_BREAK
1002case 15:
1003YY_RULE_SETUP
alokp@chromium.org07d921d2012-05-22 20:22:08 +00001004{
1005 yylval->assign(yytext, yyleng);
1006 return pp::Token::OP_RIGHT;
1007}
alokp@chromium.org04d7d222012-05-16 19:24:07 +00001008 YY_BREAK
1009case 16:
1010YY_RULE_SETUP
alokp@chromium.org07d921d2012-05-22 20:22:08 +00001011{
1012 yylval->assign(yytext, yyleng);
1013 return pp::Token::OP_LE;
1014}
alokp@chromium.org04d7d222012-05-16 19:24:07 +00001015 YY_BREAK
1016case 17:
1017YY_RULE_SETUP
alokp@chromium.org07d921d2012-05-22 20:22:08 +00001018{
1019 yylval->assign(yytext, yyleng);
1020 return pp::Token::OP_GE;
1021}
alokp@chromium.org04d7d222012-05-16 19:24:07 +00001022 YY_BREAK
1023case 18:
1024YY_RULE_SETUP
alokp@chromium.org07d921d2012-05-22 20:22:08 +00001025{
1026 yylval->assign(yytext, yyleng);
1027 return pp::Token::OP_EQ;
1028}
alokp@chromium.org04d7d222012-05-16 19:24:07 +00001029 YY_BREAK
1030case 19:
1031YY_RULE_SETUP
alokp@chromium.org07d921d2012-05-22 20:22:08 +00001032{
1033 yylval->assign(yytext, yyleng);
1034 return pp::Token::OP_NE;
1035}
alokp@chromium.org04d7d222012-05-16 19:24:07 +00001036 YY_BREAK
1037case 20:
1038YY_RULE_SETUP
alokp@chromium.org07d921d2012-05-22 20:22:08 +00001039{
1040 yylval->assign(yytext, yyleng);
1041 return pp::Token::OP_AND;
1042}
alokp@chromium.org04d7d222012-05-16 19:24:07 +00001043 YY_BREAK
1044case 21:
1045YY_RULE_SETUP
alokp@chromium.org07d921d2012-05-22 20:22:08 +00001046{
1047 yylval->assign(yytext, yyleng);
1048 return pp::Token::OP_XOR;
1049}
alokp@chromium.org04d7d222012-05-16 19:24:07 +00001050 YY_BREAK
1051case 22:
1052YY_RULE_SETUP
alokp@chromium.org07d921d2012-05-22 20:22:08 +00001053{
1054 yylval->assign(yytext, yyleng);
1055 return pp::Token::OP_OR;
1056}
alokp@chromium.org04d7d222012-05-16 19:24:07 +00001057 YY_BREAK
1058case 23:
1059YY_RULE_SETUP
alokp@chromium.org07d921d2012-05-22 20:22:08 +00001060{
1061 yylval->assign(yytext, yyleng);
1062 return pp::Token::OP_ADD_ASSIGN;
1063}
alokp@chromium.org04d7d222012-05-16 19:24:07 +00001064 YY_BREAK
1065case 24:
1066YY_RULE_SETUP
alokp@chromium.org07d921d2012-05-22 20:22:08 +00001067{
1068 yylval->assign(yytext, yyleng);
1069 return pp::Token::OP_SUB_ASSIGN;
1070}
alokp@chromium.org04d7d222012-05-16 19:24:07 +00001071 YY_BREAK
1072case 25:
1073YY_RULE_SETUP
alokp@chromium.org07d921d2012-05-22 20:22:08 +00001074{
1075 yylval->assign(yytext, yyleng);
1076 return pp::Token::OP_MUL_ASSIGN;
1077}
alokp@chromium.org04d7d222012-05-16 19:24:07 +00001078 YY_BREAK
1079case 26:
1080YY_RULE_SETUP
alokp@chromium.org07d921d2012-05-22 20:22:08 +00001081{
1082 yylval->assign(yytext, yyleng);
1083 return pp::Token::OP_DIV_ASSIGN;
1084}
alokp@chromium.org04d7d222012-05-16 19:24:07 +00001085 YY_BREAK
1086case 27:
1087YY_RULE_SETUP
alokp@chromium.org07d921d2012-05-22 20:22:08 +00001088{
1089 yylval->assign(yytext, yyleng);
1090 return pp::Token::OP_MOD_ASSIGN;
1091}
alokp@chromium.org04d7d222012-05-16 19:24:07 +00001092 YY_BREAK
1093case 28:
1094YY_RULE_SETUP
alokp@chromium.org07d921d2012-05-22 20:22:08 +00001095{
1096 yylval->assign(yytext, yyleng);
1097 return pp::Token::OP_LEFT_ASSIGN;
1098}
alokp@chromium.org04d7d222012-05-16 19:24:07 +00001099 YY_BREAK
1100case 29:
1101YY_RULE_SETUP
alokp@chromium.org07d921d2012-05-22 20:22:08 +00001102{
1103 yylval->assign(yytext, yyleng);
1104 return pp::Token::OP_RIGHT_ASSIGN;
1105}
alokp@chromium.org04d7d222012-05-16 19:24:07 +00001106 YY_BREAK
1107case 30:
1108YY_RULE_SETUP
alokp@chromium.org07d921d2012-05-22 20:22:08 +00001109{
1110 yylval->assign(yytext, yyleng);
1111 return pp::Token::OP_AND_ASSIGN;
1112}
alokp@chromium.org04d7d222012-05-16 19:24:07 +00001113 YY_BREAK
1114case 31:
1115YY_RULE_SETUP
alokp@chromium.org07d921d2012-05-22 20:22:08 +00001116{
1117 yylval->assign(yytext, yyleng);
1118 return pp::Token::OP_XOR_ASSIGN;
1119}
alokp@chromium.org04d7d222012-05-16 19:24:07 +00001120 YY_BREAK
1121case 32:
1122YY_RULE_SETUP
alokp@chromium.org07d921d2012-05-22 20:22:08 +00001123{
1124 yylval->assign(yytext, yyleng);
1125 return pp::Token::OP_OR_ASSIGN;
1126}
alokp@chromium.org04d7d222012-05-16 19:24:07 +00001127 YY_BREAK
1128case 33:
1129YY_RULE_SETUP
alokp@chromium.org07d921d2012-05-22 20:22:08 +00001130{
1131 yylval->assign(1, yytext[0]);
1132 return yytext[0];
1133}
alokp@chromium.org04d7d222012-05-16 19:24:07 +00001134 YY_BREAK
1135case 34:
1136YY_RULE_SETUP
1137{ yyextra->leadingSpace = true; }
1138 YY_BREAK
1139case 35:
1140/* rule 35 can match eol */
1141YY_RULE_SETUP
1142{
1143 ++yylineno;
alokp@chromium.org07d921d2012-05-22 20:22:08 +00001144 yylval->assign(1, '\n');
alokp@chromium.org04d7d222012-05-16 19:24:07 +00001145 return '\n';
1146}
1147 YY_BREAK
1148case 36:
shannon.woods%transgaming.com@gtempaccount.combcde56f2013-04-13 03:32:12 +00001149/* rule 36 can match eol */
1150YY_RULE_SETUP
1151{ ++yylineno; }
1152 YY_BREAK
1153case 37:
alokp@chromium.org04d7d222012-05-16 19:24:07 +00001154YY_RULE_SETUP
1155{
alokp@chromium.org432d6fc2012-06-27 22:13:21 +00001156 yylval->assign(1, yytext[0]);
1157 return pp::Token::PP_OTHER;
alokp@chromium.org04d7d222012-05-16 19:24:07 +00001158}
1159 YY_BREAK
1160case YY_STATE_EOF(INITIAL):
alokp@chromium.org07d921d2012-05-22 20:22:08 +00001161case YY_STATE_EOF(COMMENT):
1162{
alokp@chromium.org19d7aa62012-05-31 17:34:05 +00001163 // YY_USER_ACTION is not invoked for handling EOF.
1164 // Set the location for EOF token manually.
1165 pp::Input* input = &yyextra->input;
1166 pp::Input::Location* scanLoc = &yyextra->scanLoc;
shannon.woods@transgaming.comd64b3da2013-02-28 23:19:26 +00001167 yy_size_t sIndexMax = input->count() ? input->count() - 1 : 0;
alokp@chromium.org19d7aa62012-05-31 17:34:05 +00001168 if (scanLoc->sIndex != sIndexMax)
1169 {
1170 // We can only reach here if there are empty strings at the
1171 // end of the input.
1172 scanLoc->sIndex = sIndexMax; scanLoc->cIndex = 0;
shannon.woods@transgaming.comd64b3da2013-02-28 23:19:26 +00001173 // FIXME: this is not 64-bit clean.
1174 yyfileno = static_cast<int>(sIndexMax); yylineno = 1;
alokp@chromium.org19d7aa62012-05-31 17:34:05 +00001175 }
1176 yylloc->file = yyfileno;
1177 yylloc->line = yylineno;
1178 yylval->clear();
1179
alokp@chromium.org07d921d2012-05-22 20:22:08 +00001180 if (YY_START == COMMENT)
1181 {
Shannon Woods7f2d7942013-11-19 15:07:58 -05001182 yyextra->diagnostics->report(pp::Diagnostics::PP_EOF_IN_COMMENT,
alokp@chromium.org07d921d2012-05-22 20:22:08 +00001183 pp::SourceLocation(yyfileno, yylineno),
1184 "");
1185 }
alokp@chromium.org07d921d2012-05-22 20:22:08 +00001186 yyterminate();
1187}
alokp@chromium.org04d7d222012-05-16 19:24:07 +00001188 YY_BREAK
shannon.woods%transgaming.com@gtempaccount.combcde56f2013-04-13 03:32:12 +00001189case 38:
alokp@chromium.org04d7d222012-05-16 19:24:07 +00001190YY_RULE_SETUP
1191ECHO;
1192 YY_BREAK
1193
1194 case YY_END_OF_BUFFER:
1195 {
1196 /* Amount of text matched not including the EOB char. */
1197 int yy_amount_of_matched_text = (int) (yy_cp - yyg->yytext_ptr) - 1;
1198
1199 /* Undo the effects of YY_DO_BEFORE_ACTION. */
1200 *yy_cp = yyg->yy_hold_char;
1201 YY_RESTORE_YY_MORE_OFFSET
1202
1203 if ( YY_CURRENT_BUFFER_LVALUE->yy_buffer_status == YY_BUFFER_NEW )
1204 {
1205 /* We're scanning a new file or input source. It's
1206 * possible that this happened because the user
1207 * just pointed yyin at a new source and called
1208 * pplex(). If so, then we have to assure
1209 * consistency between YY_CURRENT_BUFFER and our
1210 * globals. Here is the right place to do so, because
1211 * this is the first action (other than possibly a
1212 * back-up) that will match for the new input source.
1213 */
1214 yyg->yy_n_chars = YY_CURRENT_BUFFER_LVALUE->yy_n_chars;
1215 YY_CURRENT_BUFFER_LVALUE->yy_input_file = yyin;
1216 YY_CURRENT_BUFFER_LVALUE->yy_buffer_status = YY_BUFFER_NORMAL;
1217 }
1218
1219 /* Note that here we test for yy_c_buf_p "<=" to the position
1220 * of the first EOB in the buffer, since yy_c_buf_p will
1221 * already have been incremented past the NUL character
1222 * (since all states make transitions on EOB to the
1223 * end-of-buffer state). Contrast this with the test
1224 * in input().
1225 */
1226 if ( yyg->yy_c_buf_p <= &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[yyg->yy_n_chars] )
1227 { /* This was really a NUL. */
1228 yy_state_type yy_next_state;
1229
1230 yyg->yy_c_buf_p = yyg->yytext_ptr + yy_amount_of_matched_text;
1231
1232 yy_current_state = yy_get_previous_state( yyscanner );
1233
1234 /* Okay, we're now positioned to make the NUL
1235 * transition. We couldn't have
1236 * yy_get_previous_state() go ahead and do it
1237 * for us because it doesn't know how to deal
1238 * with the possibility of jamming (and we don't
1239 * want to build jamming into it because then it
1240 * will run more slowly).
1241 */
1242
1243 yy_next_state = yy_try_NUL_trans( yy_current_state , yyscanner);
1244
1245 yy_bp = yyg->yytext_ptr + YY_MORE_ADJ;
1246
1247 if ( yy_next_state )
1248 {
1249 /* Consume the NUL. */
1250 yy_cp = ++yyg->yy_c_buf_p;
1251 yy_current_state = yy_next_state;
1252 goto yy_match;
1253 }
1254
1255 else
1256 {
1257 yy_cp = yyg->yy_last_accepting_cpos;
1258 yy_current_state = yyg->yy_last_accepting_state;
1259 goto yy_find_action;
1260 }
1261 }
1262
1263 else switch ( yy_get_next_buffer( yyscanner ) )
1264 {
1265 case EOB_ACT_END_OF_FILE:
1266 {
1267 yyg->yy_did_buffer_switch_on_eof = 0;
1268
1269 if ( ppwrap(yyscanner ) )
1270 {
1271 /* Note: because we've taken care in
1272 * yy_get_next_buffer() to have set up
1273 * yytext, we can now set up
1274 * yy_c_buf_p so that if some total
1275 * hoser (like flex itself) wants to
1276 * call the scanner after we return the
1277 * YY_NULL, it'll still work - another
1278 * YY_NULL will get returned.
1279 */
1280 yyg->yy_c_buf_p = yyg->yytext_ptr + YY_MORE_ADJ;
1281
1282 yy_act = YY_STATE_EOF(YY_START);
1283 goto do_action;
1284 }
1285
1286 else
1287 {
1288 if ( ! yyg->yy_did_buffer_switch_on_eof )
1289 YY_NEW_FILE;
1290 }
1291 break;
1292 }
1293
1294 case EOB_ACT_CONTINUE_SCAN:
1295 yyg->yy_c_buf_p =
1296 yyg->yytext_ptr + yy_amount_of_matched_text;
1297
1298 yy_current_state = yy_get_previous_state( yyscanner );
1299
1300 yy_cp = yyg->yy_c_buf_p;
1301 yy_bp = yyg->yytext_ptr + YY_MORE_ADJ;
1302 goto yy_match;
1303
1304 case EOB_ACT_LAST_MATCH:
1305 yyg->yy_c_buf_p =
1306 &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[yyg->yy_n_chars];
1307
1308 yy_current_state = yy_get_previous_state( yyscanner );
1309
1310 yy_cp = yyg->yy_c_buf_p;
1311 yy_bp = yyg->yytext_ptr + YY_MORE_ADJ;
1312 goto yy_find_action;
1313 }
1314 break;
1315 }
1316
1317 default:
1318 YY_FATAL_ERROR(
1319 "fatal flex scanner internal error--no action found" );
1320 } /* end of action switch */
1321 } /* end of scanning one token */
Jamie Madill185de882014-12-22 15:17:52 -05001322 } /* end of user's declarations */
alokp@chromium.org04d7d222012-05-16 19:24:07 +00001323} /* end of pplex */
1324
1325/* yy_get_next_buffer - try to read in a new buffer
1326 *
1327 * Returns a code representing an action:
1328 * EOB_ACT_LAST_MATCH -
1329 * EOB_ACT_CONTINUE_SCAN - continue scanning from current position
1330 * EOB_ACT_END_OF_FILE - end of file
1331 */
1332static int yy_get_next_buffer (yyscan_t yyscanner)
1333{
1334 struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
1335 register char *dest = YY_CURRENT_BUFFER_LVALUE->yy_ch_buf;
1336 register char *source = yyg->yytext_ptr;
1337 register int number_to_move, i;
1338 int ret_val;
1339
1340 if ( yyg->yy_c_buf_p > &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[yyg->yy_n_chars + 1] )
1341 YY_FATAL_ERROR(
1342 "fatal flex scanner internal error--end of buffer missed" );
1343
1344 if ( YY_CURRENT_BUFFER_LVALUE->yy_fill_buffer == 0 )
1345 { /* Don't try to fill the buffer, so this is an EOF. */
1346 if ( yyg->yy_c_buf_p - yyg->yytext_ptr - YY_MORE_ADJ == 1 )
1347 {
1348 /* We matched a single character, the EOB, so
1349 * treat this as a final EOF.
1350 */
1351 return EOB_ACT_END_OF_FILE;
1352 }
1353
1354 else
1355 {
1356 /* We matched some text prior to the EOB, first
1357 * process it.
1358 */
1359 return EOB_ACT_LAST_MATCH;
1360 }
1361 }
1362
1363 /* Try to read more data. */
1364
1365 /* First move last chars to start of buffer. */
1366 number_to_move = (int) (yyg->yy_c_buf_p - yyg->yytext_ptr) - 1;
1367
1368 for ( i = 0; i < number_to_move; ++i )
1369 *(dest++) = *(source++);
1370
1371 if ( YY_CURRENT_BUFFER_LVALUE->yy_buffer_status == YY_BUFFER_EOF_PENDING )
1372 /* don't do the read, it's not guaranteed to return an EOF,
1373 * just force an EOF
1374 */
1375 YY_CURRENT_BUFFER_LVALUE->yy_n_chars = yyg->yy_n_chars = 0;
1376
1377 else
1378 {
shannonwoods@chromium.orgb0757162013-05-30 00:21:27 +00001379 yy_size_t num_to_read =
alokp@chromium.org04d7d222012-05-16 19:24:07 +00001380 YY_CURRENT_BUFFER_LVALUE->yy_buf_size - number_to_move - 1;
1381
1382 while ( num_to_read <= 0 )
1383 { /* Not enough room in the buffer - grow it. */
1384
1385 /* just a shorter name for the current buffer */
Zhenyao Mof1d723c2013-09-23 14:57:07 -04001386 YY_BUFFER_STATE b = YY_CURRENT_BUFFER_LVALUE;
alokp@chromium.org04d7d222012-05-16 19:24:07 +00001387
1388 int yy_c_buf_p_offset =
1389 (int) (yyg->yy_c_buf_p - b->yy_ch_buf);
1390
1391 if ( b->yy_is_our_buffer )
1392 {
shannonwoods@chromium.orgb0757162013-05-30 00:21:27 +00001393 yy_size_t new_size = b->yy_buf_size * 2;
alokp@chromium.org04d7d222012-05-16 19:24:07 +00001394
1395 if ( new_size <= 0 )
1396 b->yy_buf_size += b->yy_buf_size / 8;
1397 else
1398 b->yy_buf_size *= 2;
1399
1400 b->yy_ch_buf = (char *)
1401 /* Include room in for 2 EOB chars. */
1402 pprealloc((void *) b->yy_ch_buf,b->yy_buf_size + 2 ,yyscanner );
1403 }
1404 else
1405 /* Can't grow it, we don't own it. */
1406 b->yy_ch_buf = 0;
1407
1408 if ( ! b->yy_ch_buf )
1409 YY_FATAL_ERROR(
1410 "fatal error - scanner input buffer overflow" );
1411
1412 yyg->yy_c_buf_p = &b->yy_ch_buf[yy_c_buf_p_offset];
1413
1414 num_to_read = YY_CURRENT_BUFFER_LVALUE->yy_buf_size -
1415 number_to_move - 1;
1416
1417 }
1418
1419 if ( num_to_read > YY_READ_BUF_SIZE )
1420 num_to_read = YY_READ_BUF_SIZE;
1421
1422 /* Read in more data. */
1423 YY_INPUT( (&YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[number_to_move]),
shannonwoods@chromium.orgb0757162013-05-30 00:21:27 +00001424 yyg->yy_n_chars, num_to_read );
alokp@chromium.org04d7d222012-05-16 19:24:07 +00001425
1426 YY_CURRENT_BUFFER_LVALUE->yy_n_chars = yyg->yy_n_chars;
1427 }
1428
1429 if ( yyg->yy_n_chars == 0 )
1430 {
1431 if ( number_to_move == YY_MORE_ADJ )
1432 {
1433 ret_val = EOB_ACT_END_OF_FILE;
1434 pprestart(yyin ,yyscanner);
1435 }
1436
1437 else
1438 {
1439 ret_val = EOB_ACT_LAST_MATCH;
1440 YY_CURRENT_BUFFER_LVALUE->yy_buffer_status =
1441 YY_BUFFER_EOF_PENDING;
1442 }
1443 }
1444
1445 else
1446 ret_val = EOB_ACT_CONTINUE_SCAN;
1447
1448 if ((yy_size_t) (yyg->yy_n_chars + number_to_move) > YY_CURRENT_BUFFER_LVALUE->yy_buf_size) {
1449 /* Extend the array by 50%, plus the number we really need. */
1450 yy_size_t new_size = yyg->yy_n_chars + number_to_move + (yyg->yy_n_chars >> 1);
1451 YY_CURRENT_BUFFER_LVALUE->yy_ch_buf = (char *) pprealloc((void *) YY_CURRENT_BUFFER_LVALUE->yy_ch_buf,new_size ,yyscanner );
1452 if ( ! YY_CURRENT_BUFFER_LVALUE->yy_ch_buf )
1453 YY_FATAL_ERROR( "out of dynamic memory in yy_get_next_buffer()" );
1454 }
1455
1456 yyg->yy_n_chars += number_to_move;
1457 YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[yyg->yy_n_chars] = YY_END_OF_BUFFER_CHAR;
1458 YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[yyg->yy_n_chars + 1] = YY_END_OF_BUFFER_CHAR;
1459
1460 yyg->yytext_ptr = &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[0];
1461
1462 return ret_val;
1463}
1464
1465/* yy_get_previous_state - get the state just before the EOB char was reached */
1466
1467 static yy_state_type yy_get_previous_state (yyscan_t yyscanner)
1468{
1469 register yy_state_type yy_current_state;
1470 register char *yy_cp;
1471 struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
1472
1473 yy_current_state = yyg->yy_start;
1474
1475 for ( yy_cp = yyg->yytext_ptr + YY_MORE_ADJ; yy_cp < yyg->yy_c_buf_p; ++yy_cp )
1476 {
1477 register YY_CHAR yy_c = (*yy_cp ? yy_ec[YY_SC_TO_UI(*yy_cp)] : 1);
1478 if ( yy_accept[yy_current_state] )
1479 {
1480 yyg->yy_last_accepting_state = yy_current_state;
1481 yyg->yy_last_accepting_cpos = yy_cp;
1482 }
1483 while ( yy_chk[yy_base[yy_current_state] + yy_c] != yy_current_state )
1484 {
1485 yy_current_state = (int) yy_def[yy_current_state];
shannonwoods@chromium.org2a5436f2013-05-30 00:21:41 +00001486 if ( yy_current_state >= 98 )
alokp@chromium.org04d7d222012-05-16 19:24:07 +00001487 yy_c = yy_meta[(unsigned int) yy_c];
1488 }
1489 yy_current_state = yy_nxt[yy_base[yy_current_state] + (unsigned int) yy_c];
1490 }
1491
1492 return yy_current_state;
1493}
1494
1495/* yy_try_NUL_trans - try to make a transition on the NUL character
1496 *
1497 * synopsis
1498 * next_state = yy_try_NUL_trans( current_state );
1499 */
1500 static yy_state_type yy_try_NUL_trans (yy_state_type yy_current_state , yyscan_t yyscanner)
1501{
1502 register int yy_is_jam;
1503 struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; /* This var may be unused depending upon options. */
1504 register char *yy_cp = yyg->yy_c_buf_p;
1505
1506 register YY_CHAR yy_c = 1;
1507 if ( yy_accept[yy_current_state] )
1508 {
1509 yyg->yy_last_accepting_state = yy_current_state;
1510 yyg->yy_last_accepting_cpos = yy_cp;
1511 }
1512 while ( yy_chk[yy_base[yy_current_state] + yy_c] != yy_current_state )
1513 {
1514 yy_current_state = (int) yy_def[yy_current_state];
shannonwoods@chromium.org2a5436f2013-05-30 00:21:41 +00001515 if ( yy_current_state >= 98 )
alokp@chromium.org04d7d222012-05-16 19:24:07 +00001516 yy_c = yy_meta[(unsigned int) yy_c];
1517 }
1518 yy_current_state = yy_nxt[yy_base[yy_current_state] + (unsigned int) yy_c];
shannonwoods@chromium.org2a5436f2013-05-30 00:21:41 +00001519 yy_is_jam = (yy_current_state == 97);
alokp@chromium.org04d7d222012-05-16 19:24:07 +00001520
Zhenyao Mof1d723c2013-09-23 14:57:07 -04001521 (void)yyg;
alokp@chromium.org04d7d222012-05-16 19:24:07 +00001522 return yy_is_jam ? 0 : yy_current_state;
1523}
1524
1525#ifndef YY_NO_INPUT
1526#ifdef __cplusplus
1527 static int yyinput (yyscan_t yyscanner)
1528#else
1529 static int input (yyscan_t yyscanner)
1530#endif
1531
1532{
1533 int c;
1534 struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
1535
1536 *yyg->yy_c_buf_p = yyg->yy_hold_char;
1537
1538 if ( *yyg->yy_c_buf_p == YY_END_OF_BUFFER_CHAR )
1539 {
1540 /* yy_c_buf_p now points to the character we want to return.
1541 * If this occurs *before* the EOB characters, then it's a
1542 * valid NUL; if not, then we've hit the end of the buffer.
1543 */
1544 if ( yyg->yy_c_buf_p < &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[yyg->yy_n_chars] )
1545 /* This was really a NUL. */
1546 *yyg->yy_c_buf_p = '\0';
1547
1548 else
1549 { /* need more input */
shannonwoods@chromium.orgb0757162013-05-30 00:21:27 +00001550 yy_size_t offset = yyg->yy_c_buf_p - yyg->yytext_ptr;
alokp@chromium.org04d7d222012-05-16 19:24:07 +00001551 ++yyg->yy_c_buf_p;
1552
1553 switch ( yy_get_next_buffer( yyscanner ) )
1554 {
1555 case EOB_ACT_LAST_MATCH:
1556 /* This happens because yy_g_n_b()
1557 * sees that we've accumulated a
1558 * token and flags that we need to
1559 * try matching the token before
1560 * proceeding. But for input(),
1561 * there's no matching to consider.
1562 * So convert the EOB_ACT_LAST_MATCH
1563 * to EOB_ACT_END_OF_FILE.
1564 */
1565
1566 /* Reset buffer status. */
1567 pprestart(yyin ,yyscanner);
1568
1569 /*FALLTHROUGH*/
1570
1571 case EOB_ACT_END_OF_FILE:
1572 {
1573 if ( ppwrap(yyscanner ) )
shannonwoods@chromium.org4b8a3112013-05-30 00:13:01 +00001574 return EOF;
alokp@chromium.org04d7d222012-05-16 19:24:07 +00001575
1576 if ( ! yyg->yy_did_buffer_switch_on_eof )
1577 YY_NEW_FILE;
1578#ifdef __cplusplus
1579 return yyinput(yyscanner);
1580#else
1581 return input(yyscanner);
1582#endif
1583 }
1584
1585 case EOB_ACT_CONTINUE_SCAN:
1586 yyg->yy_c_buf_p = yyg->yytext_ptr + offset;
1587 break;
1588 }
1589 }
1590 }
1591
1592 c = *(unsigned char *) yyg->yy_c_buf_p; /* cast for 8-bit char's */
1593 *yyg->yy_c_buf_p = '\0'; /* preserve yytext */
1594 yyg->yy_hold_char = *++yyg->yy_c_buf_p;
1595
1596 return c;
1597}
1598#endif /* ifndef YY_NO_INPUT */
1599
1600/** Immediately switch to a different input stream.
1601 * @param input_file A readable stream.
1602 * @param yyscanner The scanner object.
1603 * @note This function does not reset the start condition to @c INITIAL .
1604 */
1605 void pprestart (FILE * input_file , yyscan_t yyscanner)
1606{
1607 struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
1608
1609 if ( ! YY_CURRENT_BUFFER ){
1610 ppensure_buffer_stack (yyscanner);
1611 YY_CURRENT_BUFFER_LVALUE =
1612 pp_create_buffer(yyin,YY_BUF_SIZE ,yyscanner);
1613 }
1614
1615 pp_init_buffer(YY_CURRENT_BUFFER,input_file ,yyscanner);
1616 pp_load_buffer_state(yyscanner );
1617}
1618
1619/** Switch to a different input buffer.
1620 * @param new_buffer The new input buffer.
1621 * @param yyscanner The scanner object.
1622 */
1623 void pp_switch_to_buffer (YY_BUFFER_STATE new_buffer , yyscan_t yyscanner)
1624{
1625 struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
1626
1627 /* TODO. We should be able to replace this entire function body
1628 * with
1629 * pppop_buffer_state();
1630 * pppush_buffer_state(new_buffer);
1631 */
1632 ppensure_buffer_stack (yyscanner);
1633 if ( YY_CURRENT_BUFFER == new_buffer )
1634 return;
1635
1636 if ( YY_CURRENT_BUFFER )
1637 {
1638 /* Flush out information for old buffer. */
1639 *yyg->yy_c_buf_p = yyg->yy_hold_char;
1640 YY_CURRENT_BUFFER_LVALUE->yy_buf_pos = yyg->yy_c_buf_p;
1641 YY_CURRENT_BUFFER_LVALUE->yy_n_chars = yyg->yy_n_chars;
1642 }
1643
1644 YY_CURRENT_BUFFER_LVALUE = new_buffer;
1645 pp_load_buffer_state(yyscanner );
1646
1647 /* We don't actually know whether we did this switch during
1648 * EOF (ppwrap()) processing, but the only time this flag
1649 * is looked at is after ppwrap() is called, so it's safe
1650 * to go ahead and always set it.
1651 */
1652 yyg->yy_did_buffer_switch_on_eof = 1;
1653}
1654
1655static void pp_load_buffer_state (yyscan_t yyscanner)
1656{
1657 struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
1658 yyg->yy_n_chars = YY_CURRENT_BUFFER_LVALUE->yy_n_chars;
1659 yyg->yytext_ptr = yyg->yy_c_buf_p = YY_CURRENT_BUFFER_LVALUE->yy_buf_pos;
1660 yyin = YY_CURRENT_BUFFER_LVALUE->yy_input_file;
1661 yyg->yy_hold_char = *yyg->yy_c_buf_p;
1662}
1663
1664/** Allocate and initialize an input buffer state.
1665 * @param file A readable stream.
1666 * @param size The character buffer size in bytes. When in doubt, use @c YY_BUF_SIZE.
1667 * @param yyscanner The scanner object.
1668 * @return the allocated buffer state.
1669 */
1670 YY_BUFFER_STATE pp_create_buffer (FILE * file, int size , yyscan_t yyscanner)
1671{
1672 YY_BUFFER_STATE b;
1673
1674 b = (YY_BUFFER_STATE) ppalloc(sizeof( struct yy_buffer_state ) ,yyscanner );
1675 if ( ! b )
1676 YY_FATAL_ERROR( "out of dynamic memory in pp_create_buffer()" );
1677
1678 b->yy_buf_size = size;
1679
1680 /* yy_ch_buf has to be 2 characters longer than the size given because
1681 * we need to put in 2 end-of-buffer characters.
1682 */
1683 b->yy_ch_buf = (char *) ppalloc(b->yy_buf_size + 2 ,yyscanner );
1684 if ( ! b->yy_ch_buf )
1685 YY_FATAL_ERROR( "out of dynamic memory in pp_create_buffer()" );
1686
1687 b->yy_is_our_buffer = 1;
1688
1689 pp_init_buffer(b,file ,yyscanner);
1690
1691 return b;
1692}
1693
1694/** Destroy the buffer.
1695 * @param b a buffer created with pp_create_buffer()
1696 * @param yyscanner The scanner object.
1697 */
1698 void pp_delete_buffer (YY_BUFFER_STATE b , yyscan_t yyscanner)
1699{
1700 struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
1701
1702 if ( ! b )
1703 return;
1704
1705 if ( b == YY_CURRENT_BUFFER ) /* Not sure if we should pop here. */
1706 YY_CURRENT_BUFFER_LVALUE = (YY_BUFFER_STATE) 0;
1707
1708 if ( b->yy_is_our_buffer )
1709 ppfree((void *) b->yy_ch_buf ,yyscanner );
1710
1711 ppfree((void *) b ,yyscanner );
1712}
1713
1714/* Initializes or reinitializes a buffer.
1715 * This function is sometimes called more than once on the same buffer,
1716 * such as during a pprestart() or at EOF.
1717 */
1718 static void pp_init_buffer (YY_BUFFER_STATE b, FILE * file , yyscan_t yyscanner)
1719
1720{
1721 int oerrno = errno;
1722 struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
1723
1724 pp_flush_buffer(b ,yyscanner);
1725
1726 b->yy_input_file = file;
1727 b->yy_fill_buffer = 1;
1728
1729 /* If b is the current buffer, then pp_init_buffer was _probably_
1730 * called from pprestart() or through yy_get_next_buffer.
1731 * In that case, we don't want to reset the lineno or column.
1732 */
1733 if (b != YY_CURRENT_BUFFER){
1734 b->yy_bs_lineno = 1;
1735 b->yy_bs_column = 0;
1736 }
1737
1738 b->yy_is_interactive = 0;
1739
1740 errno = oerrno;
1741}
1742
1743/** Discard all buffered characters. On the next scan, YY_INPUT will be called.
1744 * @param b the buffer state to be flushed, usually @c YY_CURRENT_BUFFER.
1745 * @param yyscanner The scanner object.
1746 */
1747 void pp_flush_buffer (YY_BUFFER_STATE b , yyscan_t yyscanner)
1748{
1749 struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
1750 if ( ! b )
1751 return;
1752
1753 b->yy_n_chars = 0;
1754
1755 /* We always need two end-of-buffer characters. The first causes
1756 * a transition to the end-of-buffer state. The second causes
1757 * a jam in that state.
1758 */
1759 b->yy_ch_buf[0] = YY_END_OF_BUFFER_CHAR;
1760 b->yy_ch_buf[1] = YY_END_OF_BUFFER_CHAR;
1761
1762 b->yy_buf_pos = &b->yy_ch_buf[0];
1763
1764 b->yy_at_bol = 1;
1765 b->yy_buffer_status = YY_BUFFER_NEW;
1766
1767 if ( b == YY_CURRENT_BUFFER )
1768 pp_load_buffer_state(yyscanner );
1769}
1770
1771/** Pushes the new state onto the stack. The new state becomes
1772 * the current state. This function will allocate the stack
1773 * if necessary.
1774 * @param new_buffer The new state.
1775 * @param yyscanner The scanner object.
1776 */
1777void pppush_buffer_state (YY_BUFFER_STATE new_buffer , yyscan_t yyscanner)
1778{
1779 struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
1780 if (new_buffer == NULL)
1781 return;
1782
1783 ppensure_buffer_stack(yyscanner);
1784
1785 /* This block is copied from pp_switch_to_buffer. */
1786 if ( YY_CURRENT_BUFFER )
1787 {
1788 /* Flush out information for old buffer. */
1789 *yyg->yy_c_buf_p = yyg->yy_hold_char;
1790 YY_CURRENT_BUFFER_LVALUE->yy_buf_pos = yyg->yy_c_buf_p;
1791 YY_CURRENT_BUFFER_LVALUE->yy_n_chars = yyg->yy_n_chars;
1792 }
1793
1794 /* Only push if top exists. Otherwise, replace top. */
1795 if (YY_CURRENT_BUFFER)
1796 yyg->yy_buffer_stack_top++;
1797 YY_CURRENT_BUFFER_LVALUE = new_buffer;
1798
1799 /* copied from pp_switch_to_buffer. */
1800 pp_load_buffer_state(yyscanner );
1801 yyg->yy_did_buffer_switch_on_eof = 1;
1802}
1803
1804/** Removes and deletes the top of the stack, if present.
1805 * The next element becomes the new top.
1806 * @param yyscanner The scanner object.
1807 */
1808void pppop_buffer_state (yyscan_t yyscanner)
1809{
1810 struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
1811 if (!YY_CURRENT_BUFFER)
1812 return;
1813
1814 pp_delete_buffer(YY_CURRENT_BUFFER ,yyscanner);
1815 YY_CURRENT_BUFFER_LVALUE = NULL;
1816 if (yyg->yy_buffer_stack_top > 0)
1817 --yyg->yy_buffer_stack_top;
1818
1819 if (YY_CURRENT_BUFFER) {
1820 pp_load_buffer_state(yyscanner );
1821 yyg->yy_did_buffer_switch_on_eof = 1;
1822 }
1823}
1824
1825/* Allocates the stack if it does not exist.
1826 * Guarantees space for at least one push.
1827 */
1828static void ppensure_buffer_stack (yyscan_t yyscanner)
1829{
shannonwoods@chromium.orgb0757162013-05-30 00:21:27 +00001830 yy_size_t num_to_alloc;
alokp@chromium.org04d7d222012-05-16 19:24:07 +00001831 struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
1832
1833 if (!yyg->yy_buffer_stack) {
1834
1835 /* First allocation is just for 2 elements, since we don't know if this
1836 * scanner will even need a stack. We use 2 instead of 1 to avoid an
1837 * immediate realloc on the next call.
1838 */
1839 num_to_alloc = 1;
1840 yyg->yy_buffer_stack = (struct yy_buffer_state**)ppalloc
1841 (num_to_alloc * sizeof(struct yy_buffer_state*)
1842 , yyscanner);
1843 if ( ! yyg->yy_buffer_stack )
1844 YY_FATAL_ERROR( "out of dynamic memory in ppensure_buffer_stack()" );
1845
1846 memset(yyg->yy_buffer_stack, 0, num_to_alloc * sizeof(struct yy_buffer_state*));
1847
1848 yyg->yy_buffer_stack_max = num_to_alloc;
1849 yyg->yy_buffer_stack_top = 0;
1850 return;
1851 }
1852
1853 if (yyg->yy_buffer_stack_top >= (yyg->yy_buffer_stack_max) - 1){
1854
1855 /* Increase the buffer to prepare for a possible push. */
1856 int grow_size = 8 /* arbitrary grow size */;
1857
1858 num_to_alloc = yyg->yy_buffer_stack_max + grow_size;
1859 yyg->yy_buffer_stack = (struct yy_buffer_state**)pprealloc
1860 (yyg->yy_buffer_stack,
1861 num_to_alloc * sizeof(struct yy_buffer_state*)
1862 , yyscanner);
1863 if ( ! yyg->yy_buffer_stack )
1864 YY_FATAL_ERROR( "out of dynamic memory in ppensure_buffer_stack()" );
1865
1866 /* zero only the new slots.*/
1867 memset(yyg->yy_buffer_stack + yyg->yy_buffer_stack_max, 0, grow_size * sizeof(struct yy_buffer_state*));
1868 yyg->yy_buffer_stack_max = num_to_alloc;
1869 }
1870}
1871
1872/** Setup the input buffer state to scan directly from a user-specified character buffer.
1873 * @param base the character buffer
1874 * @param size the size in bytes of the character buffer
1875 * @param yyscanner The scanner object.
1876 * @return the newly allocated buffer state object.
1877 */
1878YY_BUFFER_STATE pp_scan_buffer (char * base, yy_size_t size , yyscan_t yyscanner)
1879{
1880 YY_BUFFER_STATE b;
1881
1882 if ( size < 2 ||
1883 base[size-2] != YY_END_OF_BUFFER_CHAR ||
1884 base[size-1] != YY_END_OF_BUFFER_CHAR )
1885 /* They forgot to leave room for the EOB's. */
1886 return 0;
1887
1888 b = (YY_BUFFER_STATE) ppalloc(sizeof( struct yy_buffer_state ) ,yyscanner );
1889 if ( ! b )
1890 YY_FATAL_ERROR( "out of dynamic memory in pp_scan_buffer()" );
1891
1892 b->yy_buf_size = size - 2; /* "- 2" to take care of EOB's */
1893 b->yy_buf_pos = b->yy_ch_buf = base;
1894 b->yy_is_our_buffer = 0;
1895 b->yy_input_file = 0;
1896 b->yy_n_chars = b->yy_buf_size;
1897 b->yy_is_interactive = 0;
1898 b->yy_at_bol = 1;
1899 b->yy_fill_buffer = 0;
1900 b->yy_buffer_status = YY_BUFFER_NEW;
1901
1902 pp_switch_to_buffer(b ,yyscanner );
1903
1904 return b;
1905}
1906
1907/** Setup the input buffer state to scan a string. The next call to pplex() will
1908 * scan from a @e copy of @a str.
1909 * @param yystr a NUL-terminated string to scan
1910 * @param yyscanner The scanner object.
1911 * @return the newly allocated buffer state object.
1912 * @note If you want to scan bytes that may contain NUL values, then use
1913 * pp_scan_bytes() instead.
1914 */
1915YY_BUFFER_STATE pp_scan_string (yyconst char * yystr , yyscan_t yyscanner)
1916{
1917
1918 return pp_scan_bytes(yystr,strlen(yystr) ,yyscanner);
1919}
1920
1921/** Setup the input buffer state to scan the given bytes. The next call to pplex() will
1922 * scan from a @e copy of @a bytes.
Zhenyao Mof1d723c2013-09-23 14:57:07 -04001923 * @param yybytes the byte buffer to scan
1924 * @param _yybytes_len the number of bytes in the buffer pointed to by @a bytes.
alokp@chromium.org04d7d222012-05-16 19:24:07 +00001925 * @param yyscanner The scanner object.
1926 * @return the newly allocated buffer state object.
1927 */
shannonwoods@chromium.orgb0757162013-05-30 00:21:27 +00001928YY_BUFFER_STATE pp_scan_bytes (yyconst char * yybytes, yy_size_t _yybytes_len , yyscan_t yyscanner)
alokp@chromium.org04d7d222012-05-16 19:24:07 +00001929{
1930 YY_BUFFER_STATE b;
1931 char *buf;
Zhenyao Mof1d723c2013-09-23 14:57:07 -04001932 yy_size_t n;
1933 yy_size_t i;
alokp@chromium.org04d7d222012-05-16 19:24:07 +00001934
1935 /* Get memory for full buffer, including space for trailing EOB's. */
1936 n = _yybytes_len + 2;
1937 buf = (char *) ppalloc(n ,yyscanner );
1938 if ( ! buf )
1939 YY_FATAL_ERROR( "out of dynamic memory in pp_scan_bytes()" );
1940
1941 for ( i = 0; i < _yybytes_len; ++i )
1942 buf[i] = yybytes[i];
1943
1944 buf[_yybytes_len] = buf[_yybytes_len+1] = YY_END_OF_BUFFER_CHAR;
1945
1946 b = pp_scan_buffer(buf,n ,yyscanner);
1947 if ( ! b )
1948 YY_FATAL_ERROR( "bad buffer in pp_scan_bytes()" );
1949
1950 /* It's okay to grow etc. this buffer, and we should throw it
1951 * away when we're done.
1952 */
1953 b->yy_is_our_buffer = 1;
1954
1955 return b;
1956}
1957
1958#ifndef YY_EXIT_FAILURE
1959#define YY_EXIT_FAILURE 2
1960#endif
1961
1962static void yy_fatal_error (yyconst char* msg , yyscan_t yyscanner)
1963{
1964 (void) fprintf( stderr, "%s\n", msg );
1965 exit( YY_EXIT_FAILURE );
1966}
1967
1968/* Redefine yyless() so it works in section 3 code. */
1969
1970#undef yyless
1971#define yyless(n) \
1972 do \
1973 { \
1974 /* Undo effects of setting up yytext. */ \
1975 int yyless_macro_arg = (n); \
1976 YY_LESS_LINENO(yyless_macro_arg);\
1977 yytext[yyleng] = yyg->yy_hold_char; \
1978 yyg->yy_c_buf_p = yytext + yyless_macro_arg; \
1979 yyg->yy_hold_char = *yyg->yy_c_buf_p; \
1980 *yyg->yy_c_buf_p = '\0'; \
1981 yyleng = yyless_macro_arg; \
1982 } \
1983 while ( 0 )
1984
1985/* Accessor methods (get/set functions) to struct members. */
1986
1987/** Get the user-defined data for this scanner.
1988 * @param yyscanner The scanner object.
1989 */
1990YY_EXTRA_TYPE ppget_extra (yyscan_t yyscanner)
1991{
1992 struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
1993 return yyextra;
1994}
1995
1996/** Get the current line number.
1997 * @param yyscanner The scanner object.
1998 */
1999int ppget_lineno (yyscan_t yyscanner)
2000{
2001 struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
2002
2003 if (! YY_CURRENT_BUFFER)
2004 return 0;
2005
2006 return yylineno;
2007}
2008
2009/** Get the current column number.
2010 * @param yyscanner The scanner object.
2011 */
2012int ppget_column (yyscan_t yyscanner)
2013{
2014 struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
2015
2016 if (! YY_CURRENT_BUFFER)
2017 return 0;
2018
2019 return yycolumn;
2020}
2021
2022/** Get the input stream.
2023 * @param yyscanner The scanner object.
2024 */
2025FILE *ppget_in (yyscan_t yyscanner)
2026{
2027 struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
2028 return yyin;
2029}
2030
2031/** Get the output stream.
2032 * @param yyscanner The scanner object.
2033 */
2034FILE *ppget_out (yyscan_t yyscanner)
2035{
2036 struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
2037 return yyout;
2038}
2039
2040/** Get the length of the current token.
2041 * @param yyscanner The scanner object.
2042 */
shannonwoods@chromium.orgb0757162013-05-30 00:21:27 +00002043yy_size_t ppget_leng (yyscan_t yyscanner)
alokp@chromium.org04d7d222012-05-16 19:24:07 +00002044{
2045 struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
2046 return yyleng;
2047}
2048
2049/** Get the current token.
2050 * @param yyscanner The scanner object.
2051 */
2052
2053char *ppget_text (yyscan_t yyscanner)
2054{
2055 struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
2056 return yytext;
2057}
2058
2059/** Set the user-defined data. This data is never touched by the scanner.
2060 * @param user_defined The data to be associated with this scanner.
2061 * @param yyscanner The scanner object.
2062 */
2063void ppset_extra (YY_EXTRA_TYPE user_defined , yyscan_t yyscanner)
2064{
2065 struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
2066 yyextra = user_defined ;
2067}
2068
2069/** Set the current line number.
2070 * @param line_number
2071 * @param yyscanner The scanner object.
2072 */
2073void ppset_lineno (int line_number , yyscan_t yyscanner)
2074{
2075 struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
2076
2077 /* lineno is only valid if an input buffer exists. */
2078 if (! YY_CURRENT_BUFFER )
Zhenyao Mof1d723c2013-09-23 14:57:07 -04002079 YY_FATAL_ERROR( "ppset_lineno called with no buffer" );
alokp@chromium.org04d7d222012-05-16 19:24:07 +00002080
2081 yylineno = line_number;
2082}
2083
2084/** Set the current column.
2085 * @param line_number
2086 * @param yyscanner The scanner object.
2087 */
2088void ppset_column (int column_no , yyscan_t yyscanner)
2089{
2090 struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
2091
2092 /* column is only valid if an input buffer exists. */
2093 if (! YY_CURRENT_BUFFER )
Zhenyao Mof1d723c2013-09-23 14:57:07 -04002094 YY_FATAL_ERROR( "ppset_column called with no buffer" );
alokp@chromium.org04d7d222012-05-16 19:24:07 +00002095
2096 yycolumn = column_no;
2097}
2098
2099/** Set the input stream. This does not discard the current
2100 * input buffer.
2101 * @param in_str A readable stream.
2102 * @param yyscanner The scanner object.
2103 * @see pp_switch_to_buffer
2104 */
2105void ppset_in (FILE * in_str , yyscan_t yyscanner)
2106{
2107 struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
2108 yyin = in_str ;
2109}
2110
2111void ppset_out (FILE * out_str , yyscan_t yyscanner)
2112{
2113 struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
2114 yyout = out_str ;
2115}
2116
2117int ppget_debug (yyscan_t yyscanner)
2118{
2119 struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
2120 return yy_flex_debug;
2121}
2122
2123void ppset_debug (int bdebug , yyscan_t yyscanner)
2124{
2125 struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
2126 yy_flex_debug = bdebug ;
2127}
2128
2129/* Accessor methods for yylval and yylloc */
2130
2131YYSTYPE * ppget_lval (yyscan_t yyscanner)
2132{
2133 struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
2134 return yylval;
2135}
2136
2137void ppset_lval (YYSTYPE * yylval_param , yyscan_t yyscanner)
2138{
2139 struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
2140 yylval = yylval_param;
2141}
2142
2143YYLTYPE *ppget_lloc (yyscan_t yyscanner)
2144{
2145 struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
2146 return yylloc;
2147}
2148
2149void ppset_lloc (YYLTYPE * yylloc_param , yyscan_t yyscanner)
2150{
2151 struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
2152 yylloc = yylloc_param;
2153}
2154
2155/* User-visible API */
2156
2157/* pplex_init is special because it creates the scanner itself, so it is
2158 * the ONLY reentrant function that doesn't take the scanner as the last argument.
2159 * That's why we explicitly handle the declaration, instead of using our macros.
2160 */
2161
2162int pplex_init(yyscan_t* ptr_yy_globals)
2163
2164{
2165 if (ptr_yy_globals == NULL){
2166 errno = EINVAL;
2167 return 1;
2168 }
2169
2170 *ptr_yy_globals = (yyscan_t) ppalloc ( sizeof( struct yyguts_t ), NULL );
2171
2172 if (*ptr_yy_globals == NULL){
2173 errno = ENOMEM;
2174 return 1;
2175 }
2176
2177 /* By setting to 0xAA, we expose bugs in yy_init_globals. Leave at 0x00 for releases. */
2178 memset(*ptr_yy_globals,0x00,sizeof(struct yyguts_t));
2179
2180 return yy_init_globals ( *ptr_yy_globals );
2181}
2182
2183/* pplex_init_extra has the same functionality as pplex_init, but follows the
2184 * convention of taking the scanner as the last argument. Note however, that
2185 * this is a *pointer* to a scanner, as it will be allocated by this call (and
2186 * is the reason, too, why this function also must handle its own declaration).
2187 * The user defined value in the first argument will be available to ppalloc in
2188 * the yyextra field.
2189 */
2190
2191int pplex_init_extra(YY_EXTRA_TYPE yy_user_defined,yyscan_t* ptr_yy_globals )
2192
2193{
2194 struct yyguts_t dummy_yyguts;
2195
2196 ppset_extra (yy_user_defined, &dummy_yyguts);
2197
2198 if (ptr_yy_globals == NULL){
2199 errno = EINVAL;
2200 return 1;
2201 }
2202
2203 *ptr_yy_globals = (yyscan_t) ppalloc ( sizeof( struct yyguts_t ), &dummy_yyguts );
2204
2205 if (*ptr_yy_globals == NULL){
2206 errno = ENOMEM;
2207 return 1;
2208 }
2209
2210 /* By setting to 0xAA, we expose bugs in
2211 yy_init_globals. Leave at 0x00 for releases. */
2212 memset(*ptr_yy_globals,0x00,sizeof(struct yyguts_t));
2213
2214 ppset_extra (yy_user_defined, *ptr_yy_globals);
2215
2216 return yy_init_globals ( *ptr_yy_globals );
2217}
2218
2219static int yy_init_globals (yyscan_t yyscanner)
2220{
2221 struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
2222 /* Initialization is the same as for the non-reentrant scanner.
2223 * This function is called from pplex_destroy(), so don't allocate here.
2224 */
2225
2226 yyg->yy_buffer_stack = 0;
2227 yyg->yy_buffer_stack_top = 0;
2228 yyg->yy_buffer_stack_max = 0;
2229 yyg->yy_c_buf_p = (char *) 0;
2230 yyg->yy_init = 0;
2231 yyg->yy_start = 0;
2232
2233 yyg->yy_start_stack_ptr = 0;
2234 yyg->yy_start_stack_depth = 0;
2235 yyg->yy_start_stack = NULL;
2236
2237/* Defined in main.c */
2238#ifdef YY_STDINIT
2239 yyin = stdin;
2240 yyout = stdout;
2241#else
2242 yyin = (FILE *) 0;
2243 yyout = (FILE *) 0;
2244#endif
2245
2246 /* For future reference: Set errno on error, since we are called by
2247 * pplex_init()
2248 */
2249 return 0;
2250}
2251
2252/* pplex_destroy is for both reentrant and non-reentrant scanners. */
2253int pplex_destroy (yyscan_t yyscanner)
2254{
2255 struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
2256
2257 /* Pop the buffer stack, destroying each element. */
2258 while(YY_CURRENT_BUFFER){
2259 pp_delete_buffer(YY_CURRENT_BUFFER ,yyscanner );
2260 YY_CURRENT_BUFFER_LVALUE = NULL;
2261 pppop_buffer_state(yyscanner);
2262 }
2263
2264 /* Destroy the stack itself. */
2265 ppfree(yyg->yy_buffer_stack ,yyscanner);
2266 yyg->yy_buffer_stack = NULL;
2267
2268 /* Destroy the start condition stack. */
2269 ppfree(yyg->yy_start_stack ,yyscanner );
2270 yyg->yy_start_stack = NULL;
2271
2272 /* Reset the globals. This is important in a non-reentrant scanner so the next time
2273 * pplex() is called, initialization will occur. */
2274 yy_init_globals( yyscanner);
2275
2276 /* Destroy the main struct (reentrant only). */
2277 ppfree ( yyscanner , yyscanner );
2278 yyscanner = NULL;
2279 return 0;
2280}
2281
2282/*
2283 * Internal utility routines.
2284 */
2285
2286#ifndef yytext_ptr
2287static void yy_flex_strncpy (char* s1, yyconst char * s2, int n , yyscan_t yyscanner)
2288{
2289 register int i;
2290 for ( i = 0; i < n; ++i )
2291 s1[i] = s2[i];
2292}
2293#endif
2294
2295#ifdef YY_NEED_STRLEN
2296static int yy_flex_strlen (yyconst char * s , yyscan_t yyscanner)
2297{
2298 register int n;
2299 for ( n = 0; s[n]; ++n )
2300 ;
2301
2302 return n;
2303}
2304#endif
2305
2306void *ppalloc (yy_size_t size , yyscan_t yyscanner)
2307{
2308 return (void *) malloc( size );
2309}
2310
2311void *pprealloc (void * ptr, yy_size_t size , yyscan_t yyscanner)
2312{
2313 /* The cast to (char *) in the following accommodates both
2314 * implementations that use char* generic pointers, and those
2315 * that use void* generic pointers. It works with the latter
2316 * because both ANSI C and C++ allow castless assignment from
2317 * any pointer type to void*, and deal with argument conversions
2318 * as though doing an assignment.
2319 */
2320 return (void *) realloc( (char *) ptr, size );
2321}
2322
2323void ppfree (void * ptr , yyscan_t yyscanner)
2324{
2325 free( (char *) ptr ); /* see pprealloc() for (char *) cast */
2326}
2327
2328#define YYTABLES_NAME "yytables"
2329
2330namespace pp {
2331
Zhenyao Mod526f982014-05-13 14:51:19 -07002332Tokenizer::Tokenizer(Diagnostics *diagnostics)
Jamie Madill5508f392014-02-20 13:31:36 -05002333 : mHandle(0),
2334 mMaxTokenSize(256)
alokp@chromium.org04d7d222012-05-16 19:24:07 +00002335{
alokp@chromium.org2c958ee2012-05-17 20:35:42 +00002336 mContext.diagnostics = diagnostics;
alokp@chromium.org04d7d222012-05-16 19:24:07 +00002337}
2338
2339Tokenizer::~Tokenizer()
2340{
2341 destroyScanner();
2342}
2343
Zhenyao Mod526f982014-05-13 14:51:19 -07002344bool Tokenizer::init(size_t count, const char * const string[], const int length[])
alokp@chromium.org04d7d222012-05-16 19:24:07 +00002345{
Zhenyao Mod526f982014-05-13 14:51:19 -07002346 if ((count > 0) && (string == 0))
2347 return false;
alokp@chromium.org04d7d222012-05-16 19:24:07 +00002348
2349 mContext.input = Input(count, string, length);
2350 return initScanner();
2351}
2352
alokp@chromium.org46aa13d2012-06-15 15:40:27 +00002353void Tokenizer::setFileNumber(int file)
2354{
2355 // We use column number as file number.
2356 // See macro yyfileno.
2357 ppset_column(file,mHandle);
2358}
2359
2360void Tokenizer::setLineNumber(int line)
2361{
2362 ppset_lineno(line,mHandle);
2363}
2364
Jamie Madill5508f392014-02-20 13:31:36 -05002365void Tokenizer::setMaxTokenSize(size_t maxTokenSize)
2366{
2367 mMaxTokenSize = maxTokenSize;
2368}
2369
Zhenyao Mod526f982014-05-13 14:51:19 -07002370void Tokenizer::lex(Token *token)
alokp@chromium.org04d7d222012-05-16 19:24:07 +00002371{
alokp@chromium.org5b6a68e2012-06-28 20:29:13 +00002372 token->type = pplex(&token->text,&token->location,mHandle);
Jamie Madill5508f392014-02-20 13:31:36 -05002373 if (token->text.size() > mMaxTokenSize)
alokp@chromium.orgc022c3a2012-07-09 15:56:42 +00002374 {
Shannon Woods7f2d7942013-11-19 15:07:58 -05002375 mContext.diagnostics->report(Diagnostics::PP_TOKEN_TOO_LONG,
alokp@chromium.orgc022c3a2012-07-09 15:56:42 +00002376 token->location, token->text);
Jamie Madill5508f392014-02-20 13:31:36 -05002377 token->text.erase(mMaxTokenSize);
alokp@chromium.orgc022c3a2012-07-09 15:56:42 +00002378 }
2379
alokp@chromium.org7fc38dd2012-06-14 18:23:23 +00002380 token->flags = 0;
alokp@chromium.org04d7d222012-05-16 19:24:07 +00002381
alokp@chromium.org19d7aa62012-05-31 17:34:05 +00002382 token->setAtStartOfLine(mContext.lineStart);
2383 mContext.lineStart = token->type == '\n';
2384
alokp@chromium.org04d7d222012-05-16 19:24:07 +00002385 token->setHasLeadingSpace(mContext.leadingSpace);
2386 mContext.leadingSpace = false;
alokp@chromium.org04d7d222012-05-16 19:24:07 +00002387}
2388
2389bool Tokenizer::initScanner()
2390{
2391 if ((mHandle == NULL) && pplex_init_extra(&mContext,&mHandle))
2392 return false;
2393
2394 pprestart(0,mHandle);
2395 return true;
2396}
2397
2398void Tokenizer::destroyScanner()
2399{
2400 if (mHandle == NULL)
2401 return;
2402
2403 pplex_destroy(mHandle);
2404 mHandle = NULL;
2405}
2406
2407} // namespace pp
2408