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