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