blob: 0ccd6fda85fed3492e004f5cce69e9cc012ba39a [file] [log] [blame]
alokp@chromium.org04d7d222012-05-16 19:24:07 +00001#line 16 "./Tokenizer.l"
2//
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
12#line 13 "./Tokenizer.cpp"
13
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;
daniel@transgaming.comb3077d02013-01-11 04:12:09 +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
daniel@transgaming.comb3077d02013-01-11 04:12:09 +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 */
daniel@transgaming.comb3077d02013-01-11 04:12:09 +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 );
daniel@transgaming.comb3077d02013-01-11 04:12:09 +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; \
daniel@transgaming.comb3077d02013-01-11 04:12:09 +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 };
shannon.woods%transgaming.com@gtempaccount.combcde56f2013-04-13 03:32:12 +0000371static yyconst flex_int16_t yy_accept[87] =
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,
378 11, 11, 11, 9, 14, 16, 18, 17, 15, 8,
379 36, 36, 31, 21, 32, 22, 3, 5, 6, 11,
380 10, 11, 1, 10, 11, 0, 10, 9, 28, 29,
381 0, 10, 10, 10, 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,
394 23, 23, 23, 23, 23, 23, 23, 24, 23, 23,
shannon.woods%transgaming.com@gtempaccount.combcde56f2013-04-13 03:32:12 +0000395 9, 25, 9, 26, 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,
398 23, 23, 23, 23, 23, 23, 23, 23, 23, 24,
shannon.woods%transgaming.com@gtempaccount.combcde56f2013-04-13 03:32:12 +0000399 23, 23, 9, 27, 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
shannon.woods%transgaming.com@gtempaccount.combcde56f2013-04-13 03:32:12 +0000416static yyconst flex_int32_t yy_meta[28] =
alokp@chromium.org04d7d222012-05-16 19:24:07 +0000417 { 0,
418 1, 1, 2, 2, 1, 1, 1, 1, 1, 3,
419 1, 1, 4, 1, 5, 5, 5, 1, 1, 1,
shannon.woods%transgaming.com@gtempaccount.combcde56f2013-04-13 03:32:12 +0000420 5, 5, 5, 5, 1, 1, 1
alokp@chromium.org04d7d222012-05-16 19:24:07 +0000421 } ;
422
shannon.woods%transgaming.com@gtempaccount.combcde56f2013-04-13 03:32:12 +0000423static yyconst flex_int16_t yy_base[92] =
alokp@chromium.org04d7d222012-05-16 19:24:07 +0000424 { 0,
shannon.woods%transgaming.com@gtempaccount.combcde56f2013-04-13 03:32:12 +0000425 0, 0, 25, 27, 162, 163, 159, 163, 152, 132,
426 163, 131, 24, 163, 116, 22, 26, 31, 30, 37,
427 40, 44, 115, 46, 0, 64, 50, 15, 0, 163,
428 124, 91, 88, 163, 163, 163, 163, 163, 163, 163,
429 163, 163, 163, 64, 163, 0, 163, 76, 54, 58,
430 79, 91, 91, 0, 56, 163, 163, 163, 32, 0,
431 163, 36, 163, 163, 163, 163, 0, 163, 163, 94,
432 0, 106, 0, 0, 113, 55, 72, 113, 163, 163,
433 116, 101, 108, 123, 126, 163, 143, 31, 148, 153,
434 155
435
alokp@chromium.org04d7d222012-05-16 19:24:07 +0000436 } ;
437
shannon.woods%transgaming.com@gtempaccount.combcde56f2013-04-13 03:32:12 +0000438static yyconst flex_int16_t yy_def[92] =
alokp@chromium.org04d7d222012-05-16 19:24:07 +0000439 { 0,
shannon.woods%transgaming.com@gtempaccount.combcde56f2013-04-13 03:32:12 +0000440 86, 1, 87, 87, 86, 86, 86, 86, 86, 86,
441 86, 86, 86, 86, 86, 86, 86, 86, 86, 86,
442 20, 86, 86, 86, 88, 86, 86, 86, 89, 86,
443 86, 86, 86, 86, 86, 86, 86, 86, 86, 86,
444 86, 86, 86, 86, 86, 90, 86, 86, 20, 20,
445 48, 51, 91, 21, 86, 86, 86, 86, 86, 88,
446 86, 86, 86, 86, 86, 86, 89, 86, 86, 44,
447 44, 70, 90, 48, 51, 86, 52, 91, 86, 86,
448 86, 72, 75, 86, 86, 0, 86, 86, 86, 86,
449 86
450
alokp@chromium.org04d7d222012-05-16 19:24:07 +0000451 } ;
452
shannon.woods%transgaming.com@gtempaccount.combcde56f2013-04-13 03:32:12 +0000453static yyconst flex_int16_t yy_nxt[191] =
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,
shannon.woods%transgaming.com@gtempaccount.combcde56f2013-04-13 03:32:12 +0000457 25, 25, 25, 25, 26, 27, 28, 30, 31, 30,
458 31, 37, 40, 65, 32, 60, 32, 42, 61, 45,
459 41, 66, 38, 46, 43, 44, 44, 44, 47, 48,
460 80, 49, 49, 50, 54, 54, 54, 51, 52, 51,
461 53, 55, 56, 51, 58, 59, 61, 62, 63, 84,
462 84, 84, 50, 50, 79, 64, 70, 51, 71, 71,
463 71, 51, 86, 86, 70, 72, 70, 70, 51, 33,
464 74, 74, 74, 51, 51, 51, 51, 75, 51, 51,
alokp@chromium.org04d7d222012-05-16 19:24:07 +0000465
shannon.woods%transgaming.com@gtempaccount.combcde56f2013-04-13 03:32:12 +0000466 51, 76, 76, 51, 69, 77, 77, 77, 70, 70,
467 70, 86, 86, 51, 51, 70, 81, 81, 86, 86,
468 82, 82, 82, 81, 81, 51, 68, 83, 83, 83,
469 85, 85, 85, 57, 39, 51, 51, 84, 84, 84,
470 85, 85, 85, 29, 29, 29, 29, 29, 67, 36,
471 35, 67, 67, 73, 34, 73, 73, 73, 78, 78,
472 33, 86, 5, 86, 86, 86, 86, 86, 86, 86,
473 86, 86, 86, 86, 86, 86, 86, 86, 86, 86,
474 86, 86, 86, 86, 86, 86, 86, 86, 86, 86
alokp@chromium.org04d7d222012-05-16 19:24:07 +0000475 } ;
476
shannon.woods%transgaming.com@gtempaccount.combcde56f2013-04-13 03:32:12 +0000477static yyconst flex_int16_t yy_chk[191] =
alokp@chromium.org04d7d222012-05-16 19:24:07 +0000478 { 0,
479 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
480 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
shannon.woods%transgaming.com@gtempaccount.combcde56f2013-04-13 03:32:12 +0000481 1, 1, 1, 1, 1, 1, 1, 3, 3, 4,
482 4, 13, 16, 28, 3, 88, 4, 17, 62, 19,
483 16, 28, 13, 19, 17, 18, 18, 18, 19, 20,
484 59, 20, 20, 20, 21, 21, 21, 20, 20, 20,
485 20, 22, 22, 21, 24, 24, 26, 26, 27, 76,
486 76, 76, 50, 50, 55, 27, 44, 49, 44, 44,
487 44, 50, 77, 77, 44, 44, 44, 44, 48, 33,
488 48, 48, 48, 51, 51, 51, 48, 48, 48, 48,
alokp@chromium.org04d7d222012-05-16 19:24:07 +0000489
shannon.woods%transgaming.com@gtempaccount.combcde56f2013-04-13 03:32:12 +0000490 51, 52, 52, 53, 32, 52, 52, 52, 70, 70,
491 70, 82, 82, 53, 53, 70, 72, 72, 83, 83,
492 72, 72, 72, 75, 75, 78, 31, 75, 75, 75,
493 81, 81, 81, 23, 15, 78, 78, 84, 84, 84,
494 85, 85, 85, 87, 87, 87, 87, 87, 89, 12,
495 10, 89, 89, 90, 9, 90, 90, 90, 91, 91,
496 7, 5, 86, 86, 86, 86, 86, 86, 86, 86,
497 86, 86, 86, 86, 86, 86, 86, 86, 86, 86,
498 86, 86, 86, 86, 86, 86, 86, 86, 86, 86
alokp@chromium.org04d7d222012-05-16 19:24:07 +0000499 } ;
500
501/* The intent behind this definition is that it'll catch
502 * any uses of REJECT which flex missed.
503 */
504#define REJECT reject_used_but_not_detected
505#define yymore() yymore_used_but_not_detected
506#define YY_MORE_ADJ 0
507#define YY_RESTORE_YY_MORE_OFFSET
508/*
509//
shannon.woods%transgaming.com@gtempaccount.combcde56f2013-04-13 03:32:12 +0000510// Copyright (c) 2002-2013 The ANGLE Project Authors. All rights reserved.
alokp@chromium.org04d7d222012-05-16 19:24:07 +0000511// Use of this source code is governed by a BSD-style license that can be
512// found in the LICENSE file.
513//
514
515This file contains the Lex specification for GLSL ES preprocessor.
516Based on Microsoft Visual Studio 2010 Preprocessor Grammar:
517http://msdn.microsoft.com/en-us/library/2scxys89.aspx
518
519IF YOU MODIFY THIS FILE YOU ALSO NEED TO RUN generate_parser.sh.
520*/
521
522#include "Tokenizer.h"
alokp@chromium.org2c958ee2012-05-17 20:35:42 +0000523
daniel@transgaming.comb3077d02013-01-11 04:12:09 +0000524#include "DiagnosticsBase.h"
alokp@chromium.org04d7d222012-05-16 19:24:07 +0000525#include "Token.h"
526
maxvujovic@gmail.comc6b3b3c2012-06-27 22:49:39 +0000527#if defined(__GNUC__)
528// Triggered by the auto-generated yy_fatal_error function.
529#pragma GCC diagnostic ignored "-Wmissing-noreturn"
530#endif
531
alokp@chromium.org04d7d222012-05-16 19:24:07 +0000532typedef std::string YYSTYPE;
alokp@chromium.org2c958ee2012-05-17 20:35:42 +0000533typedef pp::SourceLocation YYLTYPE;
alokp@chromium.org04d7d222012-05-16 19:24:07 +0000534
535// Use the unused yycolumn variable to track file (string) number.
536#define yyfileno yycolumn
537
538#define YY_USER_INIT \
539 do { \
540 yyfileno = 0; \
541 yylineno = 1; \
542 yyextra->leadingSpace = false; \
543 yyextra->lineStart = true; \
544 } while(0);
545
alokp@chromium.org19d7aa62012-05-31 17:34:05 +0000546#define YY_USER_ACTION \
547 do \
548 { \
549 pp::Input* input = &yyextra->input; \
550 pp::Input::Location* scanLoc = &yyextra->scanLoc; \
551 while ((scanLoc->sIndex < input->count()) && \
552 (scanLoc->cIndex >= input->length(scanLoc->sIndex))) \
553 { \
554 scanLoc->cIndex -= input->length(scanLoc->sIndex++); \
555 ++yyfileno; yylineno = 1; \
556 } \
557 yylloc->file = yyfileno; \
558 yylloc->line = yylineno; \
559 scanLoc->cIndex += yyleng; \
alokp@chromium.org04d7d222012-05-16 19:24:07 +0000560 } while(0);
561
562#define YY_INPUT(buf, result, maxSize) \
563 result = yyextra->input.read(buf, maxSize);
564
565#define INITIAL 0
566#define COMMENT 1
567
568#define YY_EXTRA_TYPE pp::Tokenizer::Context*
569
570/* Holds the entire state of the reentrant scanner. */
571struct yyguts_t
572 {
573
574 /* User-defined. Not touched by flex. */
575 YY_EXTRA_TYPE yyextra_r;
576
577 /* The rest are the same as the globals declared in the non-reentrant scanner. */
578 FILE *yyin_r, *yyout_r;
579 size_t yy_buffer_stack_top; /**< index of top of stack. */
580 size_t yy_buffer_stack_max; /**< capacity of stack. */
581 YY_BUFFER_STATE * yy_buffer_stack; /**< Stack as an array. */
582 char yy_hold_char;
daniel@transgaming.comb3077d02013-01-11 04:12:09 +0000583 yy_size_t yy_n_chars;
584 yy_size_t yyleng_r;
alokp@chromium.org04d7d222012-05-16 19:24:07 +0000585 char *yy_c_buf_p;
586 int yy_init;
587 int yy_start;
588 int yy_did_buffer_switch_on_eof;
589 int yy_start_stack_ptr;
590 int yy_start_stack_depth;
591 int *yy_start_stack;
592 yy_state_type yy_last_accepting_state;
593 char* yy_last_accepting_cpos;
594
595 int yylineno_r;
596 int yy_flex_debug_r;
597
598 char *yytext_r;
599 int yy_more_flag;
600 int yy_more_len;
601
602 YYSTYPE * yylval_r;
603
604 YYLTYPE * yylloc_r;
605
606 }; /* end struct yyguts_t */
607
608static int yy_init_globals (yyscan_t yyscanner );
609
610 /* This must go here because YYSTYPE and YYLTYPE are included
611 * from bison output in section 1.*/
612 # define yylval yyg->yylval_r
613
614 # define yylloc yyg->yylloc_r
615
616int pplex_init (yyscan_t* scanner);
617
618int pplex_init_extra (YY_EXTRA_TYPE user_defined,yyscan_t* scanner);
619
620/* Accessor methods to globals.
621 These are made visible to non-reentrant scanners for convenience. */
622
623int pplex_destroy (yyscan_t yyscanner );
624
625int ppget_debug (yyscan_t yyscanner );
626
627void ppset_debug (int debug_flag ,yyscan_t yyscanner );
628
629YY_EXTRA_TYPE ppget_extra (yyscan_t yyscanner );
630
631void ppset_extra (YY_EXTRA_TYPE user_defined ,yyscan_t yyscanner );
632
633FILE *ppget_in (yyscan_t yyscanner );
634
635void ppset_in (FILE * in_str ,yyscan_t yyscanner );
636
637FILE *ppget_out (yyscan_t yyscanner );
638
639void ppset_out (FILE * out_str ,yyscan_t yyscanner );
640
daniel@transgaming.comb3077d02013-01-11 04:12:09 +0000641yy_size_t ppget_leng (yyscan_t yyscanner );
alokp@chromium.org04d7d222012-05-16 19:24:07 +0000642
643char *ppget_text (yyscan_t yyscanner );
644
645int ppget_lineno (yyscan_t yyscanner );
646
647void ppset_lineno (int line_number ,yyscan_t yyscanner );
648
649YYSTYPE * ppget_lval (yyscan_t yyscanner );
650
651void ppset_lval (YYSTYPE * yylval_param ,yyscan_t yyscanner );
652
653 YYLTYPE *ppget_lloc (yyscan_t yyscanner );
654
655 void ppset_lloc (YYLTYPE * yylloc_param ,yyscan_t yyscanner );
656
657/* Macros after this point can all be overridden by user definitions in
658 * section 1.
659 */
660
661#ifndef YY_SKIP_YYWRAP
662#ifdef __cplusplus
663extern "C" int ppwrap (yyscan_t yyscanner );
664#else
665extern int ppwrap (yyscan_t yyscanner );
666#endif
667#endif
668
669#ifndef yytext_ptr
670static void yy_flex_strncpy (char *,yyconst char *,int ,yyscan_t yyscanner);
671#endif
672
673#ifdef YY_NEED_STRLEN
674static int yy_flex_strlen (yyconst char * ,yyscan_t yyscanner);
675#endif
676
677#ifndef YY_NO_INPUT
678
679#ifdef __cplusplus
680static int yyinput (yyscan_t yyscanner );
681#else
682static int input (yyscan_t yyscanner );
683#endif
684
685#endif
686
687/* Amount of stuff to slurp up with each read. */
688#ifndef YY_READ_BUF_SIZE
689#define YY_READ_BUF_SIZE 8192
690#endif
691
692/* Copy whatever the last rule matched to the standard output. */
693#ifndef ECHO
694/* This used to be an fputs(), but since the string might contain NUL's,
695 * we now use fwrite().
696 */
697#define ECHO fwrite( yytext, yyleng, 1, yyout )
698#endif
699
700/* Gets input and stuffs it into "buf". number of characters read, or YY_NULL,
701 * is returned in "result".
702 */
703#ifndef YY_INPUT
704#define YY_INPUT(buf,result,max_size) \
705 if ( YY_CURRENT_BUFFER_LVALUE->yy_is_interactive ) \
706 { \
707 int c = '*'; \
daniel@transgaming.comb3077d02013-01-11 04:12:09 +0000708 yy_size_t n; \
alokp@chromium.org04d7d222012-05-16 19:24:07 +0000709 for ( n = 0; n < max_size && \
710 (c = getc( yyin )) != EOF && c != '\n'; ++n ) \
711 buf[n] = (char) c; \
712 if ( c == '\n' ) \
713 buf[n++] = (char) c; \
714 if ( c == EOF && ferror( yyin ) ) \
715 YY_FATAL_ERROR( "input in flex scanner failed" ); \
716 result = n; \
717 } \
718 else \
719 { \
720 errno=0; \
721 while ( (result = fread(buf, 1, max_size, yyin))==0 && ferror(yyin)) \
722 { \
723 if( errno != EINTR) \
724 { \
725 YY_FATAL_ERROR( "input in flex scanner failed" ); \
726 break; \
727 } \
728 errno=0; \
729 clearerr(yyin); \
730 } \
731 }\
732\
733
734#endif
735
736/* No semi-colon after return; correct usage is to write "yyterminate();" -
737 * we don't want an extra ';' after the "return" because that will cause
738 * some compilers to complain about unreachable statements.
739 */
740#ifndef yyterminate
741#define yyterminate() return YY_NULL
742#endif
743
744/* Number of entries by which start-condition stack grows. */
745#ifndef YY_START_STACK_INCR
746#define YY_START_STACK_INCR 25
747#endif
748
749/* Report a fatal error. */
750#ifndef YY_FATAL_ERROR
751#define YY_FATAL_ERROR(msg) yy_fatal_error( msg , yyscanner)
752#endif
753
754/* end tables serialization structures and prototypes */
755
756/* Default declaration of generated scanner - a define so the user can
757 * easily add parameters.
758 */
759#ifndef YY_DECL
760#define YY_DECL_IS_OURS 1
761
762extern int pplex \
763 (YYSTYPE * yylval_param,YYLTYPE * yylloc_param ,yyscan_t yyscanner);
764
765#define YY_DECL int pplex \
766 (YYSTYPE * yylval_param, YYLTYPE * yylloc_param , yyscan_t yyscanner)
767#endif /* !YY_DECL */
768
769/* Code executed at the beginning of each rule, after yytext and yyleng
770 * have been set up.
771 */
772#ifndef YY_USER_ACTION
773#define YY_USER_ACTION
774#endif
775
776/* Code executed at the end of each rule. */
777#ifndef YY_BREAK
778#define YY_BREAK break;
779#endif
780
781#define YY_RULE_SETUP \
782 YY_USER_ACTION
783
784/** The main scanner function which does all the work.
785 */
786YY_DECL
787{
788 register yy_state_type yy_current_state;
789 register char *yy_cp, *yy_bp;
790 register int yy_act;
791 struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
792
793 /* Line comment */
794
795 yylval = yylval_param;
796
797 yylloc = yylloc_param;
798
799 if ( !yyg->yy_init )
800 {
801 yyg->yy_init = 1;
802
803#ifdef YY_USER_INIT
804 YY_USER_INIT;
805#endif
806
807 if ( ! yyg->yy_start )
808 yyg->yy_start = 1; /* first start state */
809
810 if ( ! yyin )
811 yyin = stdin;
812
813 if ( ! yyout )
814 yyout = stdout;
815
816 if ( ! YY_CURRENT_BUFFER ) {
817 ppensure_buffer_stack (yyscanner);
818 YY_CURRENT_BUFFER_LVALUE =
819 pp_create_buffer(yyin,YY_BUF_SIZE ,yyscanner);
820 }
821
822 pp_load_buffer_state(yyscanner );
823 }
824
825 while ( 1 ) /* loops until end-of-file is reached */
826 {
827 yy_cp = yyg->yy_c_buf_p;
828
829 /* Support of yytext. */
830 *yy_cp = yyg->yy_hold_char;
831
832 /* yy_bp points to the position in yy_ch_buf of the start of
833 * the current run.
834 */
835 yy_bp = yy_cp;
836
837 yy_current_state = yyg->yy_start;
838yy_match:
839 do
840 {
841 register YY_CHAR yy_c = yy_ec[YY_SC_TO_UI(*yy_cp)];
842 if ( yy_accept[yy_current_state] )
843 {
844 yyg->yy_last_accepting_state = yy_current_state;
845 yyg->yy_last_accepting_cpos = yy_cp;
846 }
847 while ( yy_chk[yy_base[yy_current_state] + yy_c] != yy_current_state )
848 {
849 yy_current_state = (int) yy_def[yy_current_state];
shannon.woods%transgaming.com@gtempaccount.combcde56f2013-04-13 03:32:12 +0000850 if ( yy_current_state >= 87 )
alokp@chromium.org04d7d222012-05-16 19:24:07 +0000851 yy_c = yy_meta[(unsigned int) yy_c];
852 }
853 yy_current_state = yy_nxt[yy_base[yy_current_state] + (unsigned int) yy_c];
854 ++yy_cp;
855 }
shannon.woods%transgaming.com@gtempaccount.combcde56f2013-04-13 03:32:12 +0000856 while ( yy_current_state != 86 );
alokp@chromium.org04d7d222012-05-16 19:24:07 +0000857 yy_cp = yyg->yy_last_accepting_cpos;
858 yy_current_state = yyg->yy_last_accepting_state;
859
860yy_find_action:
861 yy_act = yy_accept[yy_current_state];
862
863 YY_DO_BEFORE_ACTION;
864
865do_action: /* This label is used only to access EOF actions. */
866
867 switch ( yy_act )
868 { /* beginning of action switch */
869 case 0: /* must back up */
870 /* undo the effects of YY_DO_BEFORE_ACTION */
871 *yy_cp = yyg->yy_hold_char;
872 yy_cp = yyg->yy_last_accepting_cpos;
873 yy_current_state = yyg->yy_last_accepting_state;
874 goto yy_find_action;
875
876case 1:
877YY_RULE_SETUP
878
879 YY_BREAK
880/* Block comment */
881/* Line breaks are just counted - not returned. */
882/* The comment is replaced by a single space. */
883case 2:
884YY_RULE_SETUP
885{ BEGIN(COMMENT); }
886 YY_BREAK
887case 3:
888YY_RULE_SETUP
889
890 YY_BREAK
891case 4:
892YY_RULE_SETUP
893
894 YY_BREAK
895case 5:
896/* rule 5 can match eol */
897YY_RULE_SETUP
898{ ++yylineno; }
899 YY_BREAK
alokp@chromium.org04d7d222012-05-16 19:24:07 +0000900case 6:
901YY_RULE_SETUP
alokp@chromium.org2c958ee2012-05-17 20:35:42 +0000902{
903 yyextra->leadingSpace = true;
904 BEGIN(INITIAL);
905}
alokp@chromium.org04d7d222012-05-16 19:24:07 +0000906 YY_BREAK
907case 7:
908YY_RULE_SETUP
909{
910 // # is only valid at start of line for preprocessor directives.
alokp@chromium.org432d6fc2012-06-27 22:13:21 +0000911 yylval->assign(1, yytext[0]);
912 return yyextra->lineStart ? pp::Token::PP_HASH : pp::Token::PP_OTHER;
alokp@chromium.org04d7d222012-05-16 19:24:07 +0000913}
914 YY_BREAK
915case 8:
916YY_RULE_SETUP
917{
918 yylval->assign(yytext, yyleng);
919 return pp::Token::IDENTIFIER;
920}
921 YY_BREAK
922case 9:
923YY_RULE_SETUP
924{
925 yylval->assign(yytext, yyleng);
926 return pp::Token::CONST_INT;
927}
928 YY_BREAK
929case 10:
930YY_RULE_SETUP
931{
932 yylval->assign(yytext, yyleng);
933 return pp::Token::CONST_FLOAT;
934}
935 YY_BREAK
936/* Anything that starts with a {DIGIT} or .{DIGIT} must be a number. */
937/* Rule to catch all invalid integers and floats. */
938case 11:
939YY_RULE_SETUP
940{
alokp@chromium.org432d6fc2012-06-27 22:13:21 +0000941 yylval->assign(yytext, yyleng);
942 return pp::Token::PP_NUMBER;
alokp@chromium.org04d7d222012-05-16 19:24:07 +0000943}
944 YY_BREAK
945case 12:
946YY_RULE_SETUP
alokp@chromium.org07d921d2012-05-22 20:22:08 +0000947{
948 yylval->assign(yytext, yyleng);
949 return pp::Token::OP_INC;
950}
alokp@chromium.org04d7d222012-05-16 19:24:07 +0000951 YY_BREAK
952case 13:
953YY_RULE_SETUP
alokp@chromium.org07d921d2012-05-22 20:22:08 +0000954{
955 yylval->assign(yytext, yyleng);
956 return pp::Token::OP_DEC;
957}
alokp@chromium.org04d7d222012-05-16 19:24:07 +0000958 YY_BREAK
959case 14:
960YY_RULE_SETUP
alokp@chromium.org07d921d2012-05-22 20:22:08 +0000961{
962 yylval->assign(yytext, yyleng);
963 return pp::Token::OP_LEFT;
964}
alokp@chromium.org04d7d222012-05-16 19:24:07 +0000965 YY_BREAK
966case 15:
967YY_RULE_SETUP
alokp@chromium.org07d921d2012-05-22 20:22:08 +0000968{
969 yylval->assign(yytext, yyleng);
970 return pp::Token::OP_RIGHT;
971}
alokp@chromium.org04d7d222012-05-16 19:24:07 +0000972 YY_BREAK
973case 16:
974YY_RULE_SETUP
alokp@chromium.org07d921d2012-05-22 20:22:08 +0000975{
976 yylval->assign(yytext, yyleng);
977 return pp::Token::OP_LE;
978}
alokp@chromium.org04d7d222012-05-16 19:24:07 +0000979 YY_BREAK
980case 17:
981YY_RULE_SETUP
alokp@chromium.org07d921d2012-05-22 20:22:08 +0000982{
983 yylval->assign(yytext, yyleng);
984 return pp::Token::OP_GE;
985}
alokp@chromium.org04d7d222012-05-16 19:24:07 +0000986 YY_BREAK
987case 18:
988YY_RULE_SETUP
alokp@chromium.org07d921d2012-05-22 20:22:08 +0000989{
990 yylval->assign(yytext, yyleng);
991 return pp::Token::OP_EQ;
992}
alokp@chromium.org04d7d222012-05-16 19:24:07 +0000993 YY_BREAK
994case 19:
995YY_RULE_SETUP
alokp@chromium.org07d921d2012-05-22 20:22:08 +0000996{
997 yylval->assign(yytext, yyleng);
998 return pp::Token::OP_NE;
999}
alokp@chromium.org04d7d222012-05-16 19:24:07 +00001000 YY_BREAK
1001case 20:
1002YY_RULE_SETUP
alokp@chromium.org07d921d2012-05-22 20:22:08 +00001003{
1004 yylval->assign(yytext, yyleng);
1005 return pp::Token::OP_AND;
1006}
alokp@chromium.org04d7d222012-05-16 19:24:07 +00001007 YY_BREAK
1008case 21:
1009YY_RULE_SETUP
alokp@chromium.org07d921d2012-05-22 20:22:08 +00001010{
1011 yylval->assign(yytext, yyleng);
1012 return pp::Token::OP_XOR;
1013}
alokp@chromium.org04d7d222012-05-16 19:24:07 +00001014 YY_BREAK
1015case 22:
1016YY_RULE_SETUP
alokp@chromium.org07d921d2012-05-22 20:22:08 +00001017{
1018 yylval->assign(yytext, yyleng);
1019 return pp::Token::OP_OR;
1020}
alokp@chromium.org04d7d222012-05-16 19:24:07 +00001021 YY_BREAK
1022case 23:
1023YY_RULE_SETUP
alokp@chromium.org07d921d2012-05-22 20:22:08 +00001024{
1025 yylval->assign(yytext, yyleng);
1026 return pp::Token::OP_ADD_ASSIGN;
1027}
alokp@chromium.org04d7d222012-05-16 19:24:07 +00001028 YY_BREAK
1029case 24:
1030YY_RULE_SETUP
alokp@chromium.org07d921d2012-05-22 20:22:08 +00001031{
1032 yylval->assign(yytext, yyleng);
1033 return pp::Token::OP_SUB_ASSIGN;
1034}
alokp@chromium.org04d7d222012-05-16 19:24:07 +00001035 YY_BREAK
1036case 25:
1037YY_RULE_SETUP
alokp@chromium.org07d921d2012-05-22 20:22:08 +00001038{
1039 yylval->assign(yytext, yyleng);
1040 return pp::Token::OP_MUL_ASSIGN;
1041}
alokp@chromium.org04d7d222012-05-16 19:24:07 +00001042 YY_BREAK
1043case 26:
1044YY_RULE_SETUP
alokp@chromium.org07d921d2012-05-22 20:22:08 +00001045{
1046 yylval->assign(yytext, yyleng);
1047 return pp::Token::OP_DIV_ASSIGN;
1048}
alokp@chromium.org04d7d222012-05-16 19:24:07 +00001049 YY_BREAK
1050case 27:
1051YY_RULE_SETUP
alokp@chromium.org07d921d2012-05-22 20:22:08 +00001052{
1053 yylval->assign(yytext, yyleng);
1054 return pp::Token::OP_MOD_ASSIGN;
1055}
alokp@chromium.org04d7d222012-05-16 19:24:07 +00001056 YY_BREAK
1057case 28:
1058YY_RULE_SETUP
alokp@chromium.org07d921d2012-05-22 20:22:08 +00001059{
1060 yylval->assign(yytext, yyleng);
1061 return pp::Token::OP_LEFT_ASSIGN;
1062}
alokp@chromium.org04d7d222012-05-16 19:24:07 +00001063 YY_BREAK
1064case 29:
1065YY_RULE_SETUP
alokp@chromium.org07d921d2012-05-22 20:22:08 +00001066{
1067 yylval->assign(yytext, yyleng);
1068 return pp::Token::OP_RIGHT_ASSIGN;
1069}
alokp@chromium.org04d7d222012-05-16 19:24:07 +00001070 YY_BREAK
1071case 30:
1072YY_RULE_SETUP
alokp@chromium.org07d921d2012-05-22 20:22:08 +00001073{
1074 yylval->assign(yytext, yyleng);
1075 return pp::Token::OP_AND_ASSIGN;
1076}
alokp@chromium.org04d7d222012-05-16 19:24:07 +00001077 YY_BREAK
1078case 31:
1079YY_RULE_SETUP
alokp@chromium.org07d921d2012-05-22 20:22:08 +00001080{
1081 yylval->assign(yytext, yyleng);
1082 return pp::Token::OP_XOR_ASSIGN;
1083}
alokp@chromium.org04d7d222012-05-16 19:24:07 +00001084 YY_BREAK
1085case 32:
1086YY_RULE_SETUP
alokp@chromium.org07d921d2012-05-22 20:22:08 +00001087{
1088 yylval->assign(yytext, yyleng);
1089 return pp::Token::OP_OR_ASSIGN;
1090}
alokp@chromium.org04d7d222012-05-16 19:24:07 +00001091 YY_BREAK
1092case 33:
1093YY_RULE_SETUP
alokp@chromium.org07d921d2012-05-22 20:22:08 +00001094{
1095 yylval->assign(1, yytext[0]);
1096 return yytext[0];
1097}
alokp@chromium.org04d7d222012-05-16 19:24:07 +00001098 YY_BREAK
1099case 34:
1100YY_RULE_SETUP
1101{ yyextra->leadingSpace = true; }
1102 YY_BREAK
1103case 35:
1104/* rule 35 can match eol */
1105YY_RULE_SETUP
1106{
1107 ++yylineno;
alokp@chromium.org07d921d2012-05-22 20:22:08 +00001108 yylval->assign(1, '\n');
alokp@chromium.org04d7d222012-05-16 19:24:07 +00001109 return '\n';
1110}
1111 YY_BREAK
1112case 36:
shannon.woods%transgaming.com@gtempaccount.combcde56f2013-04-13 03:32:12 +00001113/* rule 36 can match eol */
1114YY_RULE_SETUP
1115{ ++yylineno; }
1116 YY_BREAK
1117case 37:
alokp@chromium.org04d7d222012-05-16 19:24:07 +00001118YY_RULE_SETUP
1119{
alokp@chromium.org432d6fc2012-06-27 22:13:21 +00001120 yylval->assign(1, yytext[0]);
1121 return pp::Token::PP_OTHER;
alokp@chromium.org04d7d222012-05-16 19:24:07 +00001122}
1123 YY_BREAK
1124case YY_STATE_EOF(INITIAL):
alokp@chromium.org07d921d2012-05-22 20:22:08 +00001125case YY_STATE_EOF(COMMENT):
1126{
alokp@chromium.org19d7aa62012-05-31 17:34:05 +00001127 // YY_USER_ACTION is not invoked for handling EOF.
1128 // Set the location for EOF token manually.
1129 pp::Input* input = &yyextra->input;
1130 pp::Input::Location* scanLoc = &yyextra->scanLoc;
shannon.woods@transgaming.comd64b3da2013-02-28 23:19:26 +00001131 yy_size_t sIndexMax = input->count() ? input->count() - 1 : 0;
alokp@chromium.org19d7aa62012-05-31 17:34:05 +00001132 if (scanLoc->sIndex != sIndexMax)
1133 {
1134 // We can only reach here if there are empty strings at the
1135 // end of the input.
1136 scanLoc->sIndex = sIndexMax; scanLoc->cIndex = 0;
shannon.woods@transgaming.comd64b3da2013-02-28 23:19:26 +00001137 // FIXME: this is not 64-bit clean.
1138 yyfileno = static_cast<int>(sIndexMax); yylineno = 1;
alokp@chromium.org19d7aa62012-05-31 17:34:05 +00001139 }
1140 yylloc->file = yyfileno;
1141 yylloc->line = yylineno;
1142 yylval->clear();
1143
alokp@chromium.org07d921d2012-05-22 20:22:08 +00001144 if (YY_START == COMMENT)
1145 {
1146 yyextra->diagnostics->report(pp::Diagnostics::EOF_IN_COMMENT,
1147 pp::SourceLocation(yyfileno, yylineno),
1148 "");
1149 }
alokp@chromium.org07d921d2012-05-22 20:22:08 +00001150 yyterminate();
1151}
alokp@chromium.org04d7d222012-05-16 19:24:07 +00001152 YY_BREAK
shannon.woods%transgaming.com@gtempaccount.combcde56f2013-04-13 03:32:12 +00001153case 38:
alokp@chromium.org04d7d222012-05-16 19:24:07 +00001154YY_RULE_SETUP
1155ECHO;
1156 YY_BREAK
1157
1158 case YY_END_OF_BUFFER:
1159 {
1160 /* Amount of text matched not including the EOB char. */
1161 int yy_amount_of_matched_text = (int) (yy_cp - yyg->yytext_ptr) - 1;
1162
1163 /* Undo the effects of YY_DO_BEFORE_ACTION. */
1164 *yy_cp = yyg->yy_hold_char;
1165 YY_RESTORE_YY_MORE_OFFSET
1166
1167 if ( YY_CURRENT_BUFFER_LVALUE->yy_buffer_status == YY_BUFFER_NEW )
1168 {
1169 /* We're scanning a new file or input source. It's
1170 * possible that this happened because the user
1171 * just pointed yyin at a new source and called
1172 * pplex(). If so, then we have to assure
1173 * consistency between YY_CURRENT_BUFFER and our
1174 * globals. Here is the right place to do so, because
1175 * this is the first action (other than possibly a
1176 * back-up) that will match for the new input source.
1177 */
1178 yyg->yy_n_chars = YY_CURRENT_BUFFER_LVALUE->yy_n_chars;
1179 YY_CURRENT_BUFFER_LVALUE->yy_input_file = yyin;
1180 YY_CURRENT_BUFFER_LVALUE->yy_buffer_status = YY_BUFFER_NORMAL;
1181 }
1182
1183 /* Note that here we test for yy_c_buf_p "<=" to the position
1184 * of the first EOB in the buffer, since yy_c_buf_p will
1185 * already have been incremented past the NUL character
1186 * (since all states make transitions on EOB to the
1187 * end-of-buffer state). Contrast this with the test
1188 * in input().
1189 */
1190 if ( yyg->yy_c_buf_p <= &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[yyg->yy_n_chars] )
1191 { /* This was really a NUL. */
1192 yy_state_type yy_next_state;
1193
1194 yyg->yy_c_buf_p = yyg->yytext_ptr + yy_amount_of_matched_text;
1195
1196 yy_current_state = yy_get_previous_state( yyscanner );
1197
1198 /* Okay, we're now positioned to make the NUL
1199 * transition. We couldn't have
1200 * yy_get_previous_state() go ahead and do it
1201 * for us because it doesn't know how to deal
1202 * with the possibility of jamming (and we don't
1203 * want to build jamming into it because then it
1204 * will run more slowly).
1205 */
1206
1207 yy_next_state = yy_try_NUL_trans( yy_current_state , yyscanner);
1208
1209 yy_bp = yyg->yytext_ptr + YY_MORE_ADJ;
1210
1211 if ( yy_next_state )
1212 {
1213 /* Consume the NUL. */
1214 yy_cp = ++yyg->yy_c_buf_p;
1215 yy_current_state = yy_next_state;
1216 goto yy_match;
1217 }
1218
1219 else
1220 {
1221 yy_cp = yyg->yy_last_accepting_cpos;
1222 yy_current_state = yyg->yy_last_accepting_state;
1223 goto yy_find_action;
1224 }
1225 }
1226
1227 else switch ( yy_get_next_buffer( yyscanner ) )
1228 {
1229 case EOB_ACT_END_OF_FILE:
1230 {
1231 yyg->yy_did_buffer_switch_on_eof = 0;
1232
1233 if ( ppwrap(yyscanner ) )
1234 {
1235 /* Note: because we've taken care in
1236 * yy_get_next_buffer() to have set up
1237 * yytext, we can now set up
1238 * yy_c_buf_p so that if some total
1239 * hoser (like flex itself) wants to
1240 * call the scanner after we return the
1241 * YY_NULL, it'll still work - another
1242 * YY_NULL will get returned.
1243 */
1244 yyg->yy_c_buf_p = yyg->yytext_ptr + YY_MORE_ADJ;
1245
1246 yy_act = YY_STATE_EOF(YY_START);
1247 goto do_action;
1248 }
1249
1250 else
1251 {
1252 if ( ! yyg->yy_did_buffer_switch_on_eof )
1253 YY_NEW_FILE;
1254 }
1255 break;
1256 }
1257
1258 case EOB_ACT_CONTINUE_SCAN:
1259 yyg->yy_c_buf_p =
1260 yyg->yytext_ptr + yy_amount_of_matched_text;
1261
1262 yy_current_state = yy_get_previous_state( yyscanner );
1263
1264 yy_cp = yyg->yy_c_buf_p;
1265 yy_bp = yyg->yytext_ptr + YY_MORE_ADJ;
1266 goto yy_match;
1267
1268 case EOB_ACT_LAST_MATCH:
1269 yyg->yy_c_buf_p =
1270 &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[yyg->yy_n_chars];
1271
1272 yy_current_state = yy_get_previous_state( yyscanner );
1273
1274 yy_cp = yyg->yy_c_buf_p;
1275 yy_bp = yyg->yytext_ptr + YY_MORE_ADJ;
1276 goto yy_find_action;
1277 }
1278 break;
1279 }
1280
1281 default:
1282 YY_FATAL_ERROR(
1283 "fatal flex scanner internal error--no action found" );
1284 } /* end of action switch */
1285 } /* end of scanning one token */
1286} /* end of pplex */
1287
1288/* yy_get_next_buffer - try to read in a new buffer
1289 *
1290 * Returns a code representing an action:
1291 * EOB_ACT_LAST_MATCH -
1292 * EOB_ACT_CONTINUE_SCAN - continue scanning from current position
1293 * EOB_ACT_END_OF_FILE - end of file
1294 */
1295static int yy_get_next_buffer (yyscan_t yyscanner)
1296{
1297 struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
1298 register char *dest = YY_CURRENT_BUFFER_LVALUE->yy_ch_buf;
1299 register char *source = yyg->yytext_ptr;
1300 register int number_to_move, i;
1301 int ret_val;
1302
1303 if ( yyg->yy_c_buf_p > &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[yyg->yy_n_chars + 1] )
1304 YY_FATAL_ERROR(
1305 "fatal flex scanner internal error--end of buffer missed" );
1306
1307 if ( YY_CURRENT_BUFFER_LVALUE->yy_fill_buffer == 0 )
1308 { /* Don't try to fill the buffer, so this is an EOF. */
1309 if ( yyg->yy_c_buf_p - yyg->yytext_ptr - YY_MORE_ADJ == 1 )
1310 {
1311 /* We matched a single character, the EOB, so
1312 * treat this as a final EOF.
1313 */
1314 return EOB_ACT_END_OF_FILE;
1315 }
1316
1317 else
1318 {
1319 /* We matched some text prior to the EOB, first
1320 * process it.
1321 */
1322 return EOB_ACT_LAST_MATCH;
1323 }
1324 }
1325
1326 /* Try to read more data. */
1327
1328 /* First move last chars to start of buffer. */
1329 number_to_move = (int) (yyg->yy_c_buf_p - yyg->yytext_ptr) - 1;
1330
1331 for ( i = 0; i < number_to_move; ++i )
1332 *(dest++) = *(source++);
1333
1334 if ( YY_CURRENT_BUFFER_LVALUE->yy_buffer_status == YY_BUFFER_EOF_PENDING )
1335 /* don't do the read, it's not guaranteed to return an EOF,
1336 * just force an EOF
1337 */
1338 YY_CURRENT_BUFFER_LVALUE->yy_n_chars = yyg->yy_n_chars = 0;
1339
1340 else
1341 {
daniel@transgaming.comb3077d02013-01-11 04:12:09 +00001342 yy_size_t num_to_read =
alokp@chromium.org04d7d222012-05-16 19:24:07 +00001343 YY_CURRENT_BUFFER_LVALUE->yy_buf_size - number_to_move - 1;
1344
1345 while ( num_to_read <= 0 )
1346 { /* Not enough room in the buffer - grow it. */
1347
1348 /* just a shorter name for the current buffer */
1349 YY_BUFFER_STATE b = YY_CURRENT_BUFFER;
1350
1351 int yy_c_buf_p_offset =
1352 (int) (yyg->yy_c_buf_p - b->yy_ch_buf);
1353
1354 if ( b->yy_is_our_buffer )
1355 {
daniel@transgaming.comb3077d02013-01-11 04:12:09 +00001356 yy_size_t new_size = b->yy_buf_size * 2;
alokp@chromium.org04d7d222012-05-16 19:24:07 +00001357
1358 if ( new_size <= 0 )
1359 b->yy_buf_size += b->yy_buf_size / 8;
1360 else
1361 b->yy_buf_size *= 2;
1362
1363 b->yy_ch_buf = (char *)
1364 /* Include room in for 2 EOB chars. */
1365 pprealloc((void *) b->yy_ch_buf,b->yy_buf_size + 2 ,yyscanner );
1366 }
1367 else
1368 /* Can't grow it, we don't own it. */
1369 b->yy_ch_buf = 0;
1370
1371 if ( ! b->yy_ch_buf )
1372 YY_FATAL_ERROR(
1373 "fatal error - scanner input buffer overflow" );
1374
1375 yyg->yy_c_buf_p = &b->yy_ch_buf[yy_c_buf_p_offset];
1376
1377 num_to_read = YY_CURRENT_BUFFER_LVALUE->yy_buf_size -
1378 number_to_move - 1;
1379
1380 }
1381
1382 if ( num_to_read > YY_READ_BUF_SIZE )
1383 num_to_read = YY_READ_BUF_SIZE;
1384
1385 /* Read in more data. */
1386 YY_INPUT( (&YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[number_to_move]),
daniel@transgaming.comb3077d02013-01-11 04:12:09 +00001387 yyg->yy_n_chars, num_to_read );
alokp@chromium.org04d7d222012-05-16 19:24:07 +00001388
1389 YY_CURRENT_BUFFER_LVALUE->yy_n_chars = yyg->yy_n_chars;
1390 }
1391
1392 if ( yyg->yy_n_chars == 0 )
1393 {
1394 if ( number_to_move == YY_MORE_ADJ )
1395 {
1396 ret_val = EOB_ACT_END_OF_FILE;
1397 pprestart(yyin ,yyscanner);
1398 }
1399
1400 else
1401 {
1402 ret_val = EOB_ACT_LAST_MATCH;
1403 YY_CURRENT_BUFFER_LVALUE->yy_buffer_status =
1404 YY_BUFFER_EOF_PENDING;
1405 }
1406 }
1407
1408 else
1409 ret_val = EOB_ACT_CONTINUE_SCAN;
1410
1411 if ((yy_size_t) (yyg->yy_n_chars + number_to_move) > YY_CURRENT_BUFFER_LVALUE->yy_buf_size) {
1412 /* Extend the array by 50%, plus the number we really need. */
1413 yy_size_t new_size = yyg->yy_n_chars + number_to_move + (yyg->yy_n_chars >> 1);
1414 YY_CURRENT_BUFFER_LVALUE->yy_ch_buf = (char *) pprealloc((void *) YY_CURRENT_BUFFER_LVALUE->yy_ch_buf,new_size ,yyscanner );
1415 if ( ! YY_CURRENT_BUFFER_LVALUE->yy_ch_buf )
1416 YY_FATAL_ERROR( "out of dynamic memory in yy_get_next_buffer()" );
1417 }
1418
1419 yyg->yy_n_chars += number_to_move;
1420 YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[yyg->yy_n_chars] = YY_END_OF_BUFFER_CHAR;
1421 YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[yyg->yy_n_chars + 1] = YY_END_OF_BUFFER_CHAR;
1422
1423 yyg->yytext_ptr = &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[0];
1424
1425 return ret_val;
1426}
1427
1428/* yy_get_previous_state - get the state just before the EOB char was reached */
1429
1430 static yy_state_type yy_get_previous_state (yyscan_t yyscanner)
1431{
1432 register yy_state_type yy_current_state;
1433 register char *yy_cp;
1434 struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
1435
1436 yy_current_state = yyg->yy_start;
1437
1438 for ( yy_cp = yyg->yytext_ptr + YY_MORE_ADJ; yy_cp < yyg->yy_c_buf_p; ++yy_cp )
1439 {
1440 register YY_CHAR yy_c = (*yy_cp ? yy_ec[YY_SC_TO_UI(*yy_cp)] : 1);
1441 if ( yy_accept[yy_current_state] )
1442 {
1443 yyg->yy_last_accepting_state = yy_current_state;
1444 yyg->yy_last_accepting_cpos = yy_cp;
1445 }
1446 while ( yy_chk[yy_base[yy_current_state] + yy_c] != yy_current_state )
1447 {
1448 yy_current_state = (int) yy_def[yy_current_state];
shannon.woods%transgaming.com@gtempaccount.combcde56f2013-04-13 03:32:12 +00001449 if ( yy_current_state >= 87 )
alokp@chromium.org04d7d222012-05-16 19:24:07 +00001450 yy_c = yy_meta[(unsigned int) yy_c];
1451 }
1452 yy_current_state = yy_nxt[yy_base[yy_current_state] + (unsigned int) yy_c];
1453 }
1454
1455 return yy_current_state;
1456}
1457
1458/* yy_try_NUL_trans - try to make a transition on the NUL character
1459 *
1460 * synopsis
1461 * next_state = yy_try_NUL_trans( current_state );
1462 */
1463 static yy_state_type yy_try_NUL_trans (yy_state_type yy_current_state , yyscan_t yyscanner)
1464{
1465 register int yy_is_jam;
1466 struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; /* This var may be unused depending upon options. */
1467 register char *yy_cp = yyg->yy_c_buf_p;
1468
1469 register YY_CHAR yy_c = 1;
1470 if ( yy_accept[yy_current_state] )
1471 {
1472 yyg->yy_last_accepting_state = yy_current_state;
1473 yyg->yy_last_accepting_cpos = yy_cp;
1474 }
1475 while ( yy_chk[yy_base[yy_current_state] + yy_c] != yy_current_state )
1476 {
1477 yy_current_state = (int) yy_def[yy_current_state];
shannon.woods%transgaming.com@gtempaccount.combcde56f2013-04-13 03:32:12 +00001478 if ( yy_current_state >= 87 )
alokp@chromium.org04d7d222012-05-16 19:24:07 +00001479 yy_c = yy_meta[(unsigned int) yy_c];
1480 }
1481 yy_current_state = yy_nxt[yy_base[yy_current_state] + (unsigned int) yy_c];
shannon.woods%transgaming.com@gtempaccount.combcde56f2013-04-13 03:32:12 +00001482 yy_is_jam = (yy_current_state == 86);
alokp@chromium.org04d7d222012-05-16 19:24:07 +00001483
1484 return yy_is_jam ? 0 : yy_current_state;
1485}
1486
1487#ifndef YY_NO_INPUT
1488#ifdef __cplusplus
1489 static int yyinput (yyscan_t yyscanner)
1490#else
1491 static int input (yyscan_t yyscanner)
1492#endif
1493
1494{
1495 int c;
1496 struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
1497
1498 *yyg->yy_c_buf_p = yyg->yy_hold_char;
1499
1500 if ( *yyg->yy_c_buf_p == YY_END_OF_BUFFER_CHAR )
1501 {
1502 /* yy_c_buf_p now points to the character we want to return.
1503 * If this occurs *before* the EOB characters, then it's a
1504 * valid NUL; if not, then we've hit the end of the buffer.
1505 */
1506 if ( yyg->yy_c_buf_p < &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[yyg->yy_n_chars] )
1507 /* This was really a NUL. */
1508 *yyg->yy_c_buf_p = '\0';
1509
1510 else
1511 { /* need more input */
daniel@transgaming.comb3077d02013-01-11 04:12:09 +00001512 yy_size_t offset = yyg->yy_c_buf_p - yyg->yytext_ptr;
alokp@chromium.org04d7d222012-05-16 19:24:07 +00001513 ++yyg->yy_c_buf_p;
1514
1515 switch ( yy_get_next_buffer( yyscanner ) )
1516 {
1517 case EOB_ACT_LAST_MATCH:
1518 /* This happens because yy_g_n_b()
1519 * sees that we've accumulated a
1520 * token and flags that we need to
1521 * try matching the token before
1522 * proceeding. But for input(),
1523 * there's no matching to consider.
1524 * So convert the EOB_ACT_LAST_MATCH
1525 * to EOB_ACT_END_OF_FILE.
1526 */
1527
1528 /* Reset buffer status. */
1529 pprestart(yyin ,yyscanner);
1530
1531 /*FALLTHROUGH*/
1532
1533 case EOB_ACT_END_OF_FILE:
1534 {
1535 if ( ppwrap(yyscanner ) )
daniel@transgaming.comb3077d02013-01-11 04:12:09 +00001536 return 0;
alokp@chromium.org04d7d222012-05-16 19:24:07 +00001537
1538 if ( ! yyg->yy_did_buffer_switch_on_eof )
1539 YY_NEW_FILE;
1540#ifdef __cplusplus
1541 return yyinput(yyscanner);
1542#else
1543 return input(yyscanner);
1544#endif
1545 }
1546
1547 case EOB_ACT_CONTINUE_SCAN:
1548 yyg->yy_c_buf_p = yyg->yytext_ptr + offset;
1549 break;
1550 }
1551 }
1552 }
1553
1554 c = *(unsigned char *) yyg->yy_c_buf_p; /* cast for 8-bit char's */
1555 *yyg->yy_c_buf_p = '\0'; /* preserve yytext */
1556 yyg->yy_hold_char = *++yyg->yy_c_buf_p;
1557
1558 return c;
1559}
1560#endif /* ifndef YY_NO_INPUT */
1561
1562/** Immediately switch to a different input stream.
1563 * @param input_file A readable stream.
1564 * @param yyscanner The scanner object.
1565 * @note This function does not reset the start condition to @c INITIAL .
1566 */
1567 void pprestart (FILE * input_file , yyscan_t yyscanner)
1568{
1569 struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
1570
1571 if ( ! YY_CURRENT_BUFFER ){
1572 ppensure_buffer_stack (yyscanner);
1573 YY_CURRENT_BUFFER_LVALUE =
1574 pp_create_buffer(yyin,YY_BUF_SIZE ,yyscanner);
1575 }
1576
1577 pp_init_buffer(YY_CURRENT_BUFFER,input_file ,yyscanner);
1578 pp_load_buffer_state(yyscanner );
1579}
1580
1581/** Switch to a different input buffer.
1582 * @param new_buffer The new input buffer.
1583 * @param yyscanner The scanner object.
1584 */
1585 void pp_switch_to_buffer (YY_BUFFER_STATE new_buffer , yyscan_t yyscanner)
1586{
1587 struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
1588
1589 /* TODO. We should be able to replace this entire function body
1590 * with
1591 * pppop_buffer_state();
1592 * pppush_buffer_state(new_buffer);
1593 */
1594 ppensure_buffer_stack (yyscanner);
1595 if ( YY_CURRENT_BUFFER == new_buffer )
1596 return;
1597
1598 if ( YY_CURRENT_BUFFER )
1599 {
1600 /* Flush out information for old buffer. */
1601 *yyg->yy_c_buf_p = yyg->yy_hold_char;
1602 YY_CURRENT_BUFFER_LVALUE->yy_buf_pos = yyg->yy_c_buf_p;
1603 YY_CURRENT_BUFFER_LVALUE->yy_n_chars = yyg->yy_n_chars;
1604 }
1605
1606 YY_CURRENT_BUFFER_LVALUE = new_buffer;
1607 pp_load_buffer_state(yyscanner );
1608
1609 /* We don't actually know whether we did this switch during
1610 * EOF (ppwrap()) processing, but the only time this flag
1611 * is looked at is after ppwrap() is called, so it's safe
1612 * to go ahead and always set it.
1613 */
1614 yyg->yy_did_buffer_switch_on_eof = 1;
1615}
1616
1617static void pp_load_buffer_state (yyscan_t yyscanner)
1618{
1619 struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
1620 yyg->yy_n_chars = YY_CURRENT_BUFFER_LVALUE->yy_n_chars;
1621 yyg->yytext_ptr = yyg->yy_c_buf_p = YY_CURRENT_BUFFER_LVALUE->yy_buf_pos;
1622 yyin = YY_CURRENT_BUFFER_LVALUE->yy_input_file;
1623 yyg->yy_hold_char = *yyg->yy_c_buf_p;
1624}
1625
1626/** Allocate and initialize an input buffer state.
1627 * @param file A readable stream.
1628 * @param size The character buffer size in bytes. When in doubt, use @c YY_BUF_SIZE.
1629 * @param yyscanner The scanner object.
1630 * @return the allocated buffer state.
1631 */
1632 YY_BUFFER_STATE pp_create_buffer (FILE * file, int size , yyscan_t yyscanner)
1633{
1634 YY_BUFFER_STATE b;
1635
1636 b = (YY_BUFFER_STATE) ppalloc(sizeof( struct yy_buffer_state ) ,yyscanner );
1637 if ( ! b )
1638 YY_FATAL_ERROR( "out of dynamic memory in pp_create_buffer()" );
1639
1640 b->yy_buf_size = size;
1641
1642 /* yy_ch_buf has to be 2 characters longer than the size given because
1643 * we need to put in 2 end-of-buffer characters.
1644 */
1645 b->yy_ch_buf = (char *) ppalloc(b->yy_buf_size + 2 ,yyscanner );
1646 if ( ! b->yy_ch_buf )
1647 YY_FATAL_ERROR( "out of dynamic memory in pp_create_buffer()" );
1648
1649 b->yy_is_our_buffer = 1;
1650
1651 pp_init_buffer(b,file ,yyscanner);
1652
1653 return b;
1654}
1655
1656/** Destroy the buffer.
1657 * @param b a buffer created with pp_create_buffer()
1658 * @param yyscanner The scanner object.
1659 */
1660 void pp_delete_buffer (YY_BUFFER_STATE b , yyscan_t yyscanner)
1661{
1662 struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
1663
1664 if ( ! b )
1665 return;
1666
1667 if ( b == YY_CURRENT_BUFFER ) /* Not sure if we should pop here. */
1668 YY_CURRENT_BUFFER_LVALUE = (YY_BUFFER_STATE) 0;
1669
1670 if ( b->yy_is_our_buffer )
1671 ppfree((void *) b->yy_ch_buf ,yyscanner );
1672
1673 ppfree((void *) b ,yyscanner );
1674}
1675
1676/* Initializes or reinitializes a buffer.
1677 * This function is sometimes called more than once on the same buffer,
1678 * such as during a pprestart() or at EOF.
1679 */
1680 static void pp_init_buffer (YY_BUFFER_STATE b, FILE * file , yyscan_t yyscanner)
1681
1682{
1683 int oerrno = errno;
1684 struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
1685
1686 pp_flush_buffer(b ,yyscanner);
1687
1688 b->yy_input_file = file;
1689 b->yy_fill_buffer = 1;
1690
1691 /* If b is the current buffer, then pp_init_buffer was _probably_
1692 * called from pprestart() or through yy_get_next_buffer.
1693 * In that case, we don't want to reset the lineno or column.
1694 */
1695 if (b != YY_CURRENT_BUFFER){
1696 b->yy_bs_lineno = 1;
1697 b->yy_bs_column = 0;
1698 }
1699
1700 b->yy_is_interactive = 0;
1701
1702 errno = oerrno;
1703}
1704
1705/** Discard all buffered characters. On the next scan, YY_INPUT will be called.
1706 * @param b the buffer state to be flushed, usually @c YY_CURRENT_BUFFER.
1707 * @param yyscanner The scanner object.
1708 */
1709 void pp_flush_buffer (YY_BUFFER_STATE b , yyscan_t yyscanner)
1710{
1711 struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
1712 if ( ! b )
1713 return;
1714
1715 b->yy_n_chars = 0;
1716
1717 /* We always need two end-of-buffer characters. The first causes
1718 * a transition to the end-of-buffer state. The second causes
1719 * a jam in that state.
1720 */
1721 b->yy_ch_buf[0] = YY_END_OF_BUFFER_CHAR;
1722 b->yy_ch_buf[1] = YY_END_OF_BUFFER_CHAR;
1723
1724 b->yy_buf_pos = &b->yy_ch_buf[0];
1725
1726 b->yy_at_bol = 1;
1727 b->yy_buffer_status = YY_BUFFER_NEW;
1728
1729 if ( b == YY_CURRENT_BUFFER )
1730 pp_load_buffer_state(yyscanner );
1731}
1732
1733/** Pushes the new state onto the stack. The new state becomes
1734 * the current state. This function will allocate the stack
1735 * if necessary.
1736 * @param new_buffer The new state.
1737 * @param yyscanner The scanner object.
1738 */
1739void pppush_buffer_state (YY_BUFFER_STATE new_buffer , yyscan_t yyscanner)
1740{
1741 struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
1742 if (new_buffer == NULL)
1743 return;
1744
1745 ppensure_buffer_stack(yyscanner);
1746
1747 /* This block is copied from pp_switch_to_buffer. */
1748 if ( YY_CURRENT_BUFFER )
1749 {
1750 /* Flush out information for old buffer. */
1751 *yyg->yy_c_buf_p = yyg->yy_hold_char;
1752 YY_CURRENT_BUFFER_LVALUE->yy_buf_pos = yyg->yy_c_buf_p;
1753 YY_CURRENT_BUFFER_LVALUE->yy_n_chars = yyg->yy_n_chars;
1754 }
1755
1756 /* Only push if top exists. Otherwise, replace top. */
1757 if (YY_CURRENT_BUFFER)
1758 yyg->yy_buffer_stack_top++;
1759 YY_CURRENT_BUFFER_LVALUE = new_buffer;
1760
1761 /* copied from pp_switch_to_buffer. */
1762 pp_load_buffer_state(yyscanner );
1763 yyg->yy_did_buffer_switch_on_eof = 1;
1764}
1765
1766/** Removes and deletes the top of the stack, if present.
1767 * The next element becomes the new top.
1768 * @param yyscanner The scanner object.
1769 */
1770void pppop_buffer_state (yyscan_t yyscanner)
1771{
1772 struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
1773 if (!YY_CURRENT_BUFFER)
1774 return;
1775
1776 pp_delete_buffer(YY_CURRENT_BUFFER ,yyscanner);
1777 YY_CURRENT_BUFFER_LVALUE = NULL;
1778 if (yyg->yy_buffer_stack_top > 0)
1779 --yyg->yy_buffer_stack_top;
1780
1781 if (YY_CURRENT_BUFFER) {
1782 pp_load_buffer_state(yyscanner );
1783 yyg->yy_did_buffer_switch_on_eof = 1;
1784 }
1785}
1786
1787/* Allocates the stack if it does not exist.
1788 * Guarantees space for at least one push.
1789 */
1790static void ppensure_buffer_stack (yyscan_t yyscanner)
1791{
daniel@transgaming.comb3077d02013-01-11 04:12:09 +00001792 yy_size_t num_to_alloc;
alokp@chromium.org04d7d222012-05-16 19:24:07 +00001793 struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
1794
1795 if (!yyg->yy_buffer_stack) {
1796
1797 /* First allocation is just for 2 elements, since we don't know if this
1798 * scanner will even need a stack. We use 2 instead of 1 to avoid an
1799 * immediate realloc on the next call.
1800 */
1801 num_to_alloc = 1;
1802 yyg->yy_buffer_stack = (struct yy_buffer_state**)ppalloc
1803 (num_to_alloc * sizeof(struct yy_buffer_state*)
1804 , yyscanner);
1805 if ( ! yyg->yy_buffer_stack )
1806 YY_FATAL_ERROR( "out of dynamic memory in ppensure_buffer_stack()" );
1807
1808 memset(yyg->yy_buffer_stack, 0, num_to_alloc * sizeof(struct yy_buffer_state*));
1809
1810 yyg->yy_buffer_stack_max = num_to_alloc;
1811 yyg->yy_buffer_stack_top = 0;
1812 return;
1813 }
1814
1815 if (yyg->yy_buffer_stack_top >= (yyg->yy_buffer_stack_max) - 1){
1816
1817 /* Increase the buffer to prepare for a possible push. */
1818 int grow_size = 8 /* arbitrary grow size */;
1819
1820 num_to_alloc = yyg->yy_buffer_stack_max + grow_size;
1821 yyg->yy_buffer_stack = (struct yy_buffer_state**)pprealloc
1822 (yyg->yy_buffer_stack,
1823 num_to_alloc * sizeof(struct yy_buffer_state*)
1824 , yyscanner);
1825 if ( ! yyg->yy_buffer_stack )
1826 YY_FATAL_ERROR( "out of dynamic memory in ppensure_buffer_stack()" );
1827
1828 /* zero only the new slots.*/
1829 memset(yyg->yy_buffer_stack + yyg->yy_buffer_stack_max, 0, grow_size * sizeof(struct yy_buffer_state*));
1830 yyg->yy_buffer_stack_max = num_to_alloc;
1831 }
1832}
1833
1834/** Setup the input buffer state to scan directly from a user-specified character buffer.
1835 * @param base the character buffer
1836 * @param size the size in bytes of the character buffer
1837 * @param yyscanner The scanner object.
1838 * @return the newly allocated buffer state object.
1839 */
1840YY_BUFFER_STATE pp_scan_buffer (char * base, yy_size_t size , yyscan_t yyscanner)
1841{
1842 YY_BUFFER_STATE b;
1843
1844 if ( size < 2 ||
1845 base[size-2] != YY_END_OF_BUFFER_CHAR ||
1846 base[size-1] != YY_END_OF_BUFFER_CHAR )
1847 /* They forgot to leave room for the EOB's. */
1848 return 0;
1849
1850 b = (YY_BUFFER_STATE) ppalloc(sizeof( struct yy_buffer_state ) ,yyscanner );
1851 if ( ! b )
1852 YY_FATAL_ERROR( "out of dynamic memory in pp_scan_buffer()" );
1853
1854 b->yy_buf_size = size - 2; /* "- 2" to take care of EOB's */
1855 b->yy_buf_pos = b->yy_ch_buf = base;
1856 b->yy_is_our_buffer = 0;
1857 b->yy_input_file = 0;
1858 b->yy_n_chars = b->yy_buf_size;
1859 b->yy_is_interactive = 0;
1860 b->yy_at_bol = 1;
1861 b->yy_fill_buffer = 0;
1862 b->yy_buffer_status = YY_BUFFER_NEW;
1863
1864 pp_switch_to_buffer(b ,yyscanner );
1865
1866 return b;
1867}
1868
1869/** Setup the input buffer state to scan a string. The next call to pplex() will
1870 * scan from a @e copy of @a str.
1871 * @param yystr a NUL-terminated string to scan
1872 * @param yyscanner The scanner object.
1873 * @return the newly allocated buffer state object.
1874 * @note If you want to scan bytes that may contain NUL values, then use
1875 * pp_scan_bytes() instead.
1876 */
1877YY_BUFFER_STATE pp_scan_string (yyconst char * yystr , yyscan_t yyscanner)
1878{
1879
1880 return pp_scan_bytes(yystr,strlen(yystr) ,yyscanner);
1881}
1882
1883/** Setup the input buffer state to scan the given bytes. The next call to pplex() will
1884 * scan from a @e copy of @a bytes.
1885 * @param bytes the byte buffer to scan
1886 * @param len the number of bytes in the buffer pointed to by @a bytes.
1887 * @param yyscanner The scanner object.
1888 * @return the newly allocated buffer state object.
1889 */
daniel@transgaming.comb3077d02013-01-11 04:12:09 +00001890YY_BUFFER_STATE pp_scan_bytes (yyconst char * yybytes, yy_size_t _yybytes_len , yyscan_t yyscanner)
alokp@chromium.org04d7d222012-05-16 19:24:07 +00001891{
1892 YY_BUFFER_STATE b;
1893 char *buf;
daniel@transgaming.comb3077d02013-01-11 04:12:09 +00001894 yy_size_t n, i;
alokp@chromium.org04d7d222012-05-16 19:24:07 +00001895
1896 /* Get memory for full buffer, including space for trailing EOB's. */
1897 n = _yybytes_len + 2;
1898 buf = (char *) ppalloc(n ,yyscanner );
1899 if ( ! buf )
1900 YY_FATAL_ERROR( "out of dynamic memory in pp_scan_bytes()" );
1901
1902 for ( i = 0; i < _yybytes_len; ++i )
1903 buf[i] = yybytes[i];
1904
1905 buf[_yybytes_len] = buf[_yybytes_len+1] = YY_END_OF_BUFFER_CHAR;
1906
1907 b = pp_scan_buffer(buf,n ,yyscanner);
1908 if ( ! b )
1909 YY_FATAL_ERROR( "bad buffer in pp_scan_bytes()" );
1910
1911 /* It's okay to grow etc. this buffer, and we should throw it
1912 * away when we're done.
1913 */
1914 b->yy_is_our_buffer = 1;
1915
1916 return b;
1917}
1918
1919#ifndef YY_EXIT_FAILURE
1920#define YY_EXIT_FAILURE 2
1921#endif
1922
1923static void yy_fatal_error (yyconst char* msg , yyscan_t yyscanner)
1924{
1925 (void) fprintf( stderr, "%s\n", msg );
1926 exit( YY_EXIT_FAILURE );
1927}
1928
1929/* Redefine yyless() so it works in section 3 code. */
1930
1931#undef yyless
1932#define yyless(n) \
1933 do \
1934 { \
1935 /* Undo effects of setting up yytext. */ \
1936 int yyless_macro_arg = (n); \
1937 YY_LESS_LINENO(yyless_macro_arg);\
1938 yytext[yyleng] = yyg->yy_hold_char; \
1939 yyg->yy_c_buf_p = yytext + yyless_macro_arg; \
1940 yyg->yy_hold_char = *yyg->yy_c_buf_p; \
1941 *yyg->yy_c_buf_p = '\0'; \
1942 yyleng = yyless_macro_arg; \
1943 } \
1944 while ( 0 )
1945
1946/* Accessor methods (get/set functions) to struct members. */
1947
1948/** Get the user-defined data for this scanner.
1949 * @param yyscanner The scanner object.
1950 */
1951YY_EXTRA_TYPE ppget_extra (yyscan_t yyscanner)
1952{
1953 struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
1954 return yyextra;
1955}
1956
1957/** Get the current line number.
1958 * @param yyscanner The scanner object.
1959 */
1960int ppget_lineno (yyscan_t yyscanner)
1961{
1962 struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
1963
1964 if (! YY_CURRENT_BUFFER)
1965 return 0;
1966
1967 return yylineno;
1968}
1969
1970/** Get the current column number.
1971 * @param yyscanner The scanner object.
1972 */
1973int ppget_column (yyscan_t yyscanner)
1974{
1975 struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
1976
1977 if (! YY_CURRENT_BUFFER)
1978 return 0;
1979
1980 return yycolumn;
1981}
1982
1983/** Get the input stream.
1984 * @param yyscanner The scanner object.
1985 */
1986FILE *ppget_in (yyscan_t yyscanner)
1987{
1988 struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
1989 return yyin;
1990}
1991
1992/** Get the output stream.
1993 * @param yyscanner The scanner object.
1994 */
1995FILE *ppget_out (yyscan_t yyscanner)
1996{
1997 struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
1998 return yyout;
1999}
2000
2001/** Get the length of the current token.
2002 * @param yyscanner The scanner object.
2003 */
daniel@transgaming.comb3077d02013-01-11 04:12:09 +00002004yy_size_t ppget_leng (yyscan_t yyscanner)
alokp@chromium.org04d7d222012-05-16 19:24:07 +00002005{
2006 struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
2007 return yyleng;
2008}
2009
2010/** Get the current token.
2011 * @param yyscanner The scanner object.
2012 */
2013
2014char *ppget_text (yyscan_t yyscanner)
2015{
2016 struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
2017 return yytext;
2018}
2019
2020/** Set the user-defined data. This data is never touched by the scanner.
2021 * @param user_defined The data to be associated with this scanner.
2022 * @param yyscanner The scanner object.
2023 */
2024void ppset_extra (YY_EXTRA_TYPE user_defined , yyscan_t yyscanner)
2025{
2026 struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
2027 yyextra = user_defined ;
2028}
2029
2030/** Set the current line number.
2031 * @param line_number
2032 * @param yyscanner The scanner object.
2033 */
2034void ppset_lineno (int line_number , yyscan_t yyscanner)
2035{
2036 struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
2037
2038 /* lineno is only valid if an input buffer exists. */
2039 if (! YY_CURRENT_BUFFER )
2040 yy_fatal_error( "ppset_lineno called with no buffer" , yyscanner);
2041
2042 yylineno = line_number;
2043}
2044
2045/** Set the current column.
2046 * @param line_number
2047 * @param yyscanner The scanner object.
2048 */
2049void ppset_column (int column_no , yyscan_t yyscanner)
2050{
2051 struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
2052
2053 /* column is only valid if an input buffer exists. */
2054 if (! YY_CURRENT_BUFFER )
2055 yy_fatal_error( "ppset_column called with no buffer" , yyscanner);
2056
2057 yycolumn = column_no;
2058}
2059
2060/** Set the input stream. This does not discard the current
2061 * input buffer.
2062 * @param in_str A readable stream.
2063 * @param yyscanner The scanner object.
2064 * @see pp_switch_to_buffer
2065 */
2066void ppset_in (FILE * in_str , yyscan_t yyscanner)
2067{
2068 struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
2069 yyin = in_str ;
2070}
2071
2072void ppset_out (FILE * out_str , yyscan_t yyscanner)
2073{
2074 struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
2075 yyout = out_str ;
2076}
2077
2078int ppget_debug (yyscan_t yyscanner)
2079{
2080 struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
2081 return yy_flex_debug;
2082}
2083
2084void ppset_debug (int bdebug , yyscan_t yyscanner)
2085{
2086 struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
2087 yy_flex_debug = bdebug ;
2088}
2089
2090/* Accessor methods for yylval and yylloc */
2091
2092YYSTYPE * ppget_lval (yyscan_t yyscanner)
2093{
2094 struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
2095 return yylval;
2096}
2097
2098void ppset_lval (YYSTYPE * yylval_param , yyscan_t yyscanner)
2099{
2100 struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
2101 yylval = yylval_param;
2102}
2103
2104YYLTYPE *ppget_lloc (yyscan_t yyscanner)
2105{
2106 struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
2107 return yylloc;
2108}
2109
2110void ppset_lloc (YYLTYPE * yylloc_param , yyscan_t yyscanner)
2111{
2112 struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
2113 yylloc = yylloc_param;
2114}
2115
2116/* User-visible API */
2117
2118/* pplex_init is special because it creates the scanner itself, so it is
2119 * the ONLY reentrant function that doesn't take the scanner as the last argument.
2120 * That's why we explicitly handle the declaration, instead of using our macros.
2121 */
2122
2123int pplex_init(yyscan_t* ptr_yy_globals)
2124
2125{
2126 if (ptr_yy_globals == NULL){
2127 errno = EINVAL;
2128 return 1;
2129 }
2130
2131 *ptr_yy_globals = (yyscan_t) ppalloc ( sizeof( struct yyguts_t ), NULL );
2132
2133 if (*ptr_yy_globals == NULL){
2134 errno = ENOMEM;
2135 return 1;
2136 }
2137
2138 /* By setting to 0xAA, we expose bugs in yy_init_globals. Leave at 0x00 for releases. */
2139 memset(*ptr_yy_globals,0x00,sizeof(struct yyguts_t));
2140
2141 return yy_init_globals ( *ptr_yy_globals );
2142}
2143
2144/* pplex_init_extra has the same functionality as pplex_init, but follows the
2145 * convention of taking the scanner as the last argument. Note however, that
2146 * this is a *pointer* to a scanner, as it will be allocated by this call (and
2147 * is the reason, too, why this function also must handle its own declaration).
2148 * The user defined value in the first argument will be available to ppalloc in
2149 * the yyextra field.
2150 */
2151
2152int pplex_init_extra(YY_EXTRA_TYPE yy_user_defined,yyscan_t* ptr_yy_globals )
2153
2154{
2155 struct yyguts_t dummy_yyguts;
2156
2157 ppset_extra (yy_user_defined, &dummy_yyguts);
2158
2159 if (ptr_yy_globals == NULL){
2160 errno = EINVAL;
2161 return 1;
2162 }
2163
2164 *ptr_yy_globals = (yyscan_t) ppalloc ( sizeof( struct yyguts_t ), &dummy_yyguts );
2165
2166 if (*ptr_yy_globals == NULL){
2167 errno = ENOMEM;
2168 return 1;
2169 }
2170
2171 /* By setting to 0xAA, we expose bugs in
2172 yy_init_globals. Leave at 0x00 for releases. */
2173 memset(*ptr_yy_globals,0x00,sizeof(struct yyguts_t));
2174
2175 ppset_extra (yy_user_defined, *ptr_yy_globals);
2176
2177 return yy_init_globals ( *ptr_yy_globals );
2178}
2179
2180static int yy_init_globals (yyscan_t yyscanner)
2181{
2182 struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
2183 /* Initialization is the same as for the non-reentrant scanner.
2184 * This function is called from pplex_destroy(), so don't allocate here.
2185 */
2186
2187 yyg->yy_buffer_stack = 0;
2188 yyg->yy_buffer_stack_top = 0;
2189 yyg->yy_buffer_stack_max = 0;
2190 yyg->yy_c_buf_p = (char *) 0;
2191 yyg->yy_init = 0;
2192 yyg->yy_start = 0;
2193
2194 yyg->yy_start_stack_ptr = 0;
2195 yyg->yy_start_stack_depth = 0;
2196 yyg->yy_start_stack = NULL;
2197
2198/* Defined in main.c */
2199#ifdef YY_STDINIT
2200 yyin = stdin;
2201 yyout = stdout;
2202#else
2203 yyin = (FILE *) 0;
2204 yyout = (FILE *) 0;
2205#endif
2206
2207 /* For future reference: Set errno on error, since we are called by
2208 * pplex_init()
2209 */
2210 return 0;
2211}
2212
2213/* pplex_destroy is for both reentrant and non-reentrant scanners. */
2214int pplex_destroy (yyscan_t yyscanner)
2215{
2216 struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
2217
2218 /* Pop the buffer stack, destroying each element. */
2219 while(YY_CURRENT_BUFFER){
2220 pp_delete_buffer(YY_CURRENT_BUFFER ,yyscanner );
2221 YY_CURRENT_BUFFER_LVALUE = NULL;
2222 pppop_buffer_state(yyscanner);
2223 }
2224
2225 /* Destroy the stack itself. */
2226 ppfree(yyg->yy_buffer_stack ,yyscanner);
2227 yyg->yy_buffer_stack = NULL;
2228
2229 /* Destroy the start condition stack. */
2230 ppfree(yyg->yy_start_stack ,yyscanner );
2231 yyg->yy_start_stack = NULL;
2232
2233 /* Reset the globals. This is important in a non-reentrant scanner so the next time
2234 * pplex() is called, initialization will occur. */
2235 yy_init_globals( yyscanner);
2236
2237 /* Destroy the main struct (reentrant only). */
2238 ppfree ( yyscanner , yyscanner );
2239 yyscanner = NULL;
2240 return 0;
2241}
2242
2243/*
2244 * Internal utility routines.
2245 */
2246
2247#ifndef yytext_ptr
2248static void yy_flex_strncpy (char* s1, yyconst char * s2, int n , yyscan_t yyscanner)
2249{
2250 register int i;
2251 for ( i = 0; i < n; ++i )
2252 s1[i] = s2[i];
2253}
2254#endif
2255
2256#ifdef YY_NEED_STRLEN
2257static int yy_flex_strlen (yyconst char * s , yyscan_t yyscanner)
2258{
2259 register int n;
2260 for ( n = 0; s[n]; ++n )
2261 ;
2262
2263 return n;
2264}
2265#endif
2266
2267void *ppalloc (yy_size_t size , yyscan_t yyscanner)
2268{
2269 return (void *) malloc( size );
2270}
2271
2272void *pprealloc (void * ptr, yy_size_t size , yyscan_t yyscanner)
2273{
2274 /* The cast to (char *) in the following accommodates both
2275 * implementations that use char* generic pointers, and those
2276 * that use void* generic pointers. It works with the latter
2277 * because both ANSI C and C++ allow castless assignment from
2278 * any pointer type to void*, and deal with argument conversions
2279 * as though doing an assignment.
2280 */
2281 return (void *) realloc( (char *) ptr, size );
2282}
2283
2284void ppfree (void * ptr , yyscan_t yyscanner)
2285{
2286 free( (char *) ptr ); /* see pprealloc() for (char *) cast */
2287}
2288
2289#define YYTABLES_NAME "yytables"
2290
2291namespace pp {
2292
alokp@chromium.orgc022c3a2012-07-09 15:56:42 +00002293// TODO(alokp): Maximum token length should ideally be specified by
2294// the preprocessor client, i.e., the compiler.
2295const size_t Tokenizer::kMaxTokenLength = 256;
2296
alokp@chromium.org2c958ee2012-05-17 20:35:42 +00002297Tokenizer::Tokenizer(Diagnostics* diagnostics) : mHandle(0)
alokp@chromium.org04d7d222012-05-16 19:24:07 +00002298{
alokp@chromium.org2c958ee2012-05-17 20:35:42 +00002299 mContext.diagnostics = diagnostics;
alokp@chromium.org04d7d222012-05-16 19:24:07 +00002300}
2301
2302Tokenizer::~Tokenizer()
2303{
2304 destroyScanner();
2305}
2306
shannon.woods@transgaming.comd64b3da2013-02-28 23:19:26 +00002307bool Tokenizer::init(size_t count, const char* const string[], const int length[])
alokp@chromium.org04d7d222012-05-16 19:24:07 +00002308{
alokp@chromium.org04d7d222012-05-16 19:24:07 +00002309 if ((count > 0) && (string == 0)) return false;
2310
2311 mContext.input = Input(count, string, length);
2312 return initScanner();
2313}
2314
alokp@chromium.org46aa13d2012-06-15 15:40:27 +00002315void Tokenizer::setFileNumber(int file)
2316{
2317 // We use column number as file number.
2318 // See macro yyfileno.
2319 ppset_column(file,mHandle);
2320}
2321
2322void Tokenizer::setLineNumber(int line)
2323{
2324 ppset_lineno(line,mHandle);
2325}
2326
alokp@chromium.org04d7d222012-05-16 19:24:07 +00002327void Tokenizer::lex(Token* token)
2328{
alokp@chromium.org5b6a68e2012-06-28 20:29:13 +00002329 token->type = pplex(&token->text,&token->location,mHandle);
alokp@chromium.orgc022c3a2012-07-09 15:56:42 +00002330 if (token->text.size() > kMaxTokenLength)
2331 {
2332 mContext.diagnostics->report(Diagnostics::TOKEN_TOO_LONG,
2333 token->location, token->text);
2334 token->text.erase(kMaxTokenLength);
2335 }
2336
alokp@chromium.org7fc38dd2012-06-14 18:23:23 +00002337 token->flags = 0;
alokp@chromium.org04d7d222012-05-16 19:24:07 +00002338
alokp@chromium.org19d7aa62012-05-31 17:34:05 +00002339 token->setAtStartOfLine(mContext.lineStart);
2340 mContext.lineStart = token->type == '\n';
2341
alokp@chromium.org04d7d222012-05-16 19:24:07 +00002342 token->setHasLeadingSpace(mContext.leadingSpace);
2343 mContext.leadingSpace = false;
alokp@chromium.org04d7d222012-05-16 19:24:07 +00002344}
2345
2346bool Tokenizer::initScanner()
2347{
2348 if ((mHandle == NULL) && pplex_init_extra(&mContext,&mHandle))
2349 return false;
2350
2351 pprestart(0,mHandle);
2352 return true;
2353}
2354
2355void Tokenizer::destroyScanner()
2356{
2357 if (mHandle == NULL)
2358 return;
2359
2360 pplex_destroy(mHandle);
2361 mHandle = NULL;
2362}
2363
2364} // namespace pp
2365