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