blob: a48d241ef7b22a128b8d12a181261d9937d27341 [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;
59#else
60typedef signed char flex_int8_t;
61typedef short int flex_int16_t;
62typedef int flex_int32_t;
63typedef unsigned char flex_uint8_t;
64typedef unsigned short int flex_uint16_t;
65typedef unsigned int flex_uint32_t;
66#endif /* ! C99 */
67
68/* Limits of integral types. */
69#ifndef INT8_MIN
70#define INT8_MIN (-128)
71#endif
72#ifndef INT16_MIN
73#define INT16_MIN (-32767-1)
74#endif
75#ifndef INT32_MIN
76#define INT32_MIN (-2147483647-1)
77#endif
78#ifndef INT8_MAX
79#define INT8_MAX (127)
80#endif
81#ifndef INT16_MAX
82#define INT16_MAX (32767)
83#endif
84#ifndef INT32_MAX
85#define INT32_MAX (2147483647)
86#endif
87#ifndef UINT8_MAX
88#define UINT8_MAX (255U)
89#endif
90#ifndef UINT16_MAX
91#define UINT16_MAX (65535U)
92#endif
93#ifndef UINT32_MAX
94#define UINT32_MAX (4294967295U)
95#endif
96
97#endif /* ! FLEXINT_H */
98
99#ifdef __cplusplus
100
101/* The "const" storage-class-modifier is valid. */
102#define YY_USE_CONST
103
104#else /* ! __cplusplus */
105
106/* C99 requires __STDC__ to be defined as 1. */
107#if defined (__STDC__)
108
109#define YY_USE_CONST
110
111#endif /* defined (__STDC__) */
112#endif /* ! __cplusplus */
113
114#ifdef YY_USE_CONST
115#define yyconst const
116#else
117#define yyconst
118#endif
119
120/* Returned upon end-of-file. */
121#define YY_NULL 0
122
123/* Promotes a possibly negative, possibly signed char to an unsigned
124 * integer for use as an array index. If the signed char is negative,
125 * we want to instead treat it as an 8-bit unsigned char, hence the
126 * double cast.
127 */
128#define YY_SC_TO_UI(c) ((unsigned int) (unsigned char) c)
129
130/* An opaque pointer. */
131#ifndef YY_TYPEDEF_YY_SCANNER_T
132#define YY_TYPEDEF_YY_SCANNER_T
133typedef void* yyscan_t;
134#endif
135
136/* For convenience, these vars (plus the bison vars far below)
137 are macros in the reentrant scanner. */
138#define yyin yyg->yyin_r
139#define yyout yyg->yyout_r
140#define yyextra yyg->yyextra_r
141#define yyleng yyg->yyleng_r
142#define yytext yyg->yytext_r
143#define yylineno (YY_CURRENT_BUFFER_LVALUE->yy_bs_lineno)
144#define yycolumn (YY_CURRENT_BUFFER_LVALUE->yy_bs_column)
145#define yy_flex_debug yyg->yy_flex_debug_r
146
147/* Enter a start condition. This macro really ought to take a parameter,
148 * but we do it the disgusting crufty way forced on us by the ()-less
149 * definition of BEGIN.
150 */
151#define BEGIN yyg->yy_start = 1 + 2 *
152
153/* Translate the current start state into a value that can be later handed
154 * to BEGIN to return to the state. The YYSTATE alias is for lex
155 * compatibility.
156 */
157#define YY_START ((yyg->yy_start - 1) / 2)
158#define YYSTATE YY_START
159
160/* Action number for EOF rule of a given start state. */
161#define YY_STATE_EOF(state) (YY_END_OF_BUFFER + state + 1)
162
163/* Special action meaning "start processing a new file". */
164#define YY_NEW_FILE pprestart(yyin ,yyscanner )
165
166#define YY_END_OF_BUFFER_CHAR 0
167
168/* Size of default input buffer. */
169#ifndef YY_BUF_SIZE
170#define YY_BUF_SIZE 16384
171#endif
172
173/* The state buf must be large enough to hold one state per character in the main buffer.
174 */
175#define YY_STATE_BUF_SIZE ((YY_BUF_SIZE + 2) * sizeof(yy_state_type))
176
177#ifndef YY_TYPEDEF_YY_BUFFER_STATE
178#define YY_TYPEDEF_YY_BUFFER_STATE
179typedef struct yy_buffer_state *YY_BUFFER_STATE;
180#endif
181
182#define EOB_ACT_CONTINUE_SCAN 0
183#define EOB_ACT_END_OF_FILE 1
184#define EOB_ACT_LAST_MATCH 2
185
186 #define YY_LESS_LINENO(n)
187
188/* Return all but the first "n" matched characters back to the input stream. */
189#define yyless(n) \
190 do \
191 { \
192 /* Undo effects of setting up yytext. */ \
193 int yyless_macro_arg = (n); \
194 YY_LESS_LINENO(yyless_macro_arg);\
195 *yy_cp = yyg->yy_hold_char; \
196 YY_RESTORE_YY_MORE_OFFSET \
197 yyg->yy_c_buf_p = yy_cp = yy_bp + yyless_macro_arg - YY_MORE_ADJ; \
198 YY_DO_BEFORE_ACTION; /* set up yytext again */ \
199 } \
200 while ( 0 )
201
202#define unput(c) yyunput( c, yyg->yytext_ptr , yyscanner )
203
shannonwoods@chromium.org4b8a3112013-05-30 00:13:01 +0000204#ifndef YY_TYPEDEF_YY_SIZE_T
205#define YY_TYPEDEF_YY_SIZE_T
206typedef size_t yy_size_t;
207#endif
208
alokp@chromium.org04d7d222012-05-16 19:24:07 +0000209#ifndef YY_STRUCT_YY_BUFFER_STATE
210#define YY_STRUCT_YY_BUFFER_STATE
211struct yy_buffer_state
212 {
213 FILE *yy_input_file;
214
215 char *yy_ch_buf; /* input buffer */
216 char *yy_buf_pos; /* current position in input buffer */
217
218 /* Size of input buffer in bytes, not including room for EOB
219 * characters.
220 */
221 yy_size_t yy_buf_size;
222
223 /* Number of characters read into yy_ch_buf, not including EOB
224 * characters.
225 */
shannonwoods@chromium.org4b8a3112013-05-30 00:13:01 +0000226 int yy_n_chars;
alokp@chromium.org04d7d222012-05-16 19:24:07 +0000227
228 /* Whether we "own" the buffer - i.e., we know we created it,
229 * and can realloc() it to grow it, and should free() it to
230 * delete it.
231 */
232 int yy_is_our_buffer;
233
234 /* Whether this is an "interactive" input source; if so, and
235 * if we're using stdio for input, then we want to use getc()
236 * instead of fread(), to make sure we stop fetching input after
237 * each newline.
238 */
239 int yy_is_interactive;
240
241 /* Whether we're considered to be at the beginning of a line.
242 * If so, '^' rules will be active on the next match, otherwise
243 * not.
244 */
245 int yy_at_bol;
246
247 int yy_bs_lineno; /**< The line count. */
248 int yy_bs_column; /**< The column count. */
249
250 /* Whether to try to fill the input buffer when we reach the
251 * end of it.
252 */
253 int yy_fill_buffer;
254
255 int yy_buffer_status;
256
257#define YY_BUFFER_NEW 0
258#define YY_BUFFER_NORMAL 1
259 /* When an EOF's been seen but there's still some text to process
260 * then we mark the buffer as YY_EOF_PENDING, to indicate that we
261 * shouldn't try reading from the input source any more. We might
262 * still have a bunch of tokens to match, though, because of
263 * possible backing-up.
264 *
265 * When we actually see the EOF, we change the status to "new"
266 * (via pprestart()), so that the user can continue scanning by
267 * just pointing yyin at a new input file.
268 */
269#define YY_BUFFER_EOF_PENDING 2
270
271 };
272#endif /* !YY_STRUCT_YY_BUFFER_STATE */
273
274/* We provide macros for accessing buffer states in case in the
275 * future we want to put the buffer states in a more general
276 * "scanner state".
277 *
278 * Returns the top of the stack, or NULL.
279 */
280#define YY_CURRENT_BUFFER ( yyg->yy_buffer_stack \
281 ? yyg->yy_buffer_stack[yyg->yy_buffer_stack_top] \
282 : NULL)
283
284/* Same as previous macro, but useful when we know that the buffer stack is not
285 * NULL or when we need an lvalue. For internal use only.
286 */
287#define YY_CURRENT_BUFFER_LVALUE yyg->yy_buffer_stack[yyg->yy_buffer_stack_top]
288
289void pprestart (FILE *input_file ,yyscan_t yyscanner );
290void pp_switch_to_buffer (YY_BUFFER_STATE new_buffer ,yyscan_t yyscanner );
291YY_BUFFER_STATE pp_create_buffer (FILE *file,int size ,yyscan_t yyscanner );
292void pp_delete_buffer (YY_BUFFER_STATE b ,yyscan_t yyscanner );
293void pp_flush_buffer (YY_BUFFER_STATE b ,yyscan_t yyscanner );
294void pppush_buffer_state (YY_BUFFER_STATE new_buffer ,yyscan_t yyscanner );
295void pppop_buffer_state (yyscan_t yyscanner );
296
297static void ppensure_buffer_stack (yyscan_t yyscanner );
298static void pp_load_buffer_state (yyscan_t yyscanner );
299static void pp_init_buffer (YY_BUFFER_STATE b,FILE *file ,yyscan_t yyscanner );
300
301#define YY_FLUSH_BUFFER pp_flush_buffer(YY_CURRENT_BUFFER ,yyscanner)
302
303YY_BUFFER_STATE pp_scan_buffer (char *base,yy_size_t size ,yyscan_t yyscanner );
304YY_BUFFER_STATE pp_scan_string (yyconst char *yy_str ,yyscan_t yyscanner );
shannonwoods@chromium.org4b8a3112013-05-30 00:13:01 +0000305YY_BUFFER_STATE pp_scan_bytes (yyconst char *bytes,int len ,yyscan_t yyscanner );
alokp@chromium.org04d7d222012-05-16 19:24:07 +0000306
307void *ppalloc (yy_size_t ,yyscan_t yyscanner );
308void *pprealloc (void *,yy_size_t ,yyscan_t yyscanner );
309void ppfree (void * ,yyscan_t yyscanner );
310
311#define yy_new_buffer pp_create_buffer
312
313#define yy_set_interactive(is_interactive) \
314 { \
315 if ( ! YY_CURRENT_BUFFER ){ \
316 ppensure_buffer_stack (yyscanner); \
317 YY_CURRENT_BUFFER_LVALUE = \
318 pp_create_buffer(yyin,YY_BUF_SIZE ,yyscanner); \
319 } \
320 YY_CURRENT_BUFFER_LVALUE->yy_is_interactive = is_interactive; \
321 }
322
323#define yy_set_bol(at_bol) \
324 { \
325 if ( ! YY_CURRENT_BUFFER ){\
326 ppensure_buffer_stack (yyscanner); \
327 YY_CURRENT_BUFFER_LVALUE = \
328 pp_create_buffer(yyin,YY_BUF_SIZE ,yyscanner); \
329 } \
330 YY_CURRENT_BUFFER_LVALUE->yy_at_bol = at_bol; \
331 }
332
333#define YY_AT_BOL() (YY_CURRENT_BUFFER_LVALUE->yy_at_bol)
334
335/* Begin user sect3 */
336
337#define ppwrap(n) 1
338#define YY_SKIP_YYWRAP
339
340typedef unsigned char YY_CHAR;
341
342typedef int yy_state_type;
343
344#define yytext_ptr yytext_r
345
346static yy_state_type yy_get_previous_state (yyscan_t yyscanner );
347static yy_state_type yy_try_NUL_trans (yy_state_type current_state ,yyscan_t yyscanner);
348static int yy_get_next_buffer (yyscan_t yyscanner );
349static void yy_fatal_error (yyconst char msg[] ,yyscan_t yyscanner );
350
351/* Done after the current pattern has been matched and before the
352 * corresponding action - sets up yytext.
353 */
354#define YY_DO_BEFORE_ACTION \
355 yyg->yytext_ptr = yy_bp; \
shannonwoods@chromium.org4b8a3112013-05-30 00:13:01 +0000356 yyleng = (size_t) (yy_cp - yy_bp); \
alokp@chromium.org04d7d222012-05-16 19:24:07 +0000357 yyg->yy_hold_char = *yy_cp; \
358 *yy_cp = '\0'; \
359 yyg->yy_c_buf_p = yy_cp;
360
shannon.woods%transgaming.com@gtempaccount.combcde56f2013-04-13 03:32:12 +0000361#define YY_NUM_RULES 38
362#define YY_END_OF_BUFFER 39
alokp@chromium.org04d7d222012-05-16 19:24:07 +0000363/* This struct is not used in this scanner,
364 but its presence is necessary. */
365struct yy_trans_info
366 {
367 flex_int32_t yy_verify;
368 flex_int32_t yy_nxt;
369 };
shannon.woods%transgaming.com@gtempaccount.combcde56f2013-04-13 03:32:12 +0000370static yyconst flex_int16_t yy_accept[87] =
alokp@chromium.org04d7d222012-05-16 19:24:07 +0000371 { 0,
shannon.woods%transgaming.com@gtempaccount.combcde56f2013-04-13 03:32:12 +0000372 0, 0, 0, 0, 39, 37, 34, 35, 35, 33,
alokp@chromium.org04d7d222012-05-16 19:24:07 +0000373 7, 33, 33, 33, 33, 33, 33, 33, 33, 9,
shannon.woods%transgaming.com@gtempaccount.combcde56f2013-04-13 03:32:12 +0000374 9, 33, 33, 33, 8, 37, 33, 33, 3, 5,
375 5, 4, 34, 35, 19, 27, 20, 30, 25, 12,
376 23, 13, 24, 10, 2, 1, 26, 10, 9, 11,
377 11, 11, 11, 9, 14, 16, 18, 17, 15, 8,
378 36, 36, 31, 21, 32, 22, 3, 5, 6, 11,
379 10, 11, 1, 10, 11, 0, 10, 9, 28, 29,
380 0, 10, 10, 10, 10, 0
alokp@chromium.org04d7d222012-05-16 19:24:07 +0000381 } ;
382
383static yyconst flex_int32_t yy_ec[256] =
384 { 0,
385 1, 1, 1, 1, 1, 1, 1, 1, 2, 3,
386 2, 2, 4, 1, 1, 1, 1, 1, 1, 1,
387 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
388 1, 2, 5, 1, 6, 1, 7, 8, 1, 9,
389 9, 10, 11, 9, 12, 13, 14, 15, 16, 16,
390 16, 16, 16, 16, 16, 17, 17, 9, 9, 18,
391 19, 20, 9, 1, 21, 21, 21, 21, 22, 21,
392 23, 23, 23, 23, 23, 23, 23, 23, 23, 23,
393 23, 23, 23, 23, 23, 23, 23, 24, 23, 23,
shannon.woods%transgaming.com@gtempaccount.combcde56f2013-04-13 03:32:12 +0000394 9, 25, 9, 26, 23, 1, 21, 21, 21, 21,
alokp@chromium.org04d7d222012-05-16 19:24:07 +0000395
396 22, 21, 23, 23, 23, 23, 23, 23, 23, 23,
397 23, 23, 23, 23, 23, 23, 23, 23, 23, 24,
shannon.woods%transgaming.com@gtempaccount.combcde56f2013-04-13 03:32:12 +0000398 23, 23, 9, 27, 9, 9, 1, 1, 1, 1,
alokp@chromium.org04d7d222012-05-16 19:24:07 +0000399 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
400 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
407 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
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
413 } ;
414
shannon.woods%transgaming.com@gtempaccount.combcde56f2013-04-13 03:32:12 +0000415static yyconst flex_int32_t yy_meta[28] =
alokp@chromium.org04d7d222012-05-16 19:24:07 +0000416 { 0,
417 1, 1, 2, 2, 1, 1, 1, 1, 1, 3,
418 1, 1, 4, 1, 5, 5, 5, 1, 1, 1,
shannon.woods%transgaming.com@gtempaccount.combcde56f2013-04-13 03:32:12 +0000419 5, 5, 5, 5, 1, 1, 1
alokp@chromium.org04d7d222012-05-16 19:24:07 +0000420 } ;
421
shannon.woods%transgaming.com@gtempaccount.combcde56f2013-04-13 03:32:12 +0000422static yyconst flex_int16_t yy_base[92] =
alokp@chromium.org04d7d222012-05-16 19:24:07 +0000423 { 0,
shannon.woods%transgaming.com@gtempaccount.combcde56f2013-04-13 03:32:12 +0000424 0, 0, 25, 27, 162, 163, 159, 163, 152, 132,
425 163, 131, 24, 163, 116, 22, 26, 31, 30, 37,
426 40, 44, 115, 46, 0, 64, 50, 15, 0, 163,
427 124, 91, 88, 163, 163, 163, 163, 163, 163, 163,
428 163, 163, 163, 64, 163, 0, 163, 76, 54, 58,
429 79, 91, 91, 0, 56, 163, 163, 163, 32, 0,
430 163, 36, 163, 163, 163, 163, 0, 163, 163, 94,
431 0, 106, 0, 0, 113, 55, 72, 113, 163, 163,
432 116, 101, 108, 123, 126, 163, 143, 31, 148, 153,
433 155
434
alokp@chromium.org04d7d222012-05-16 19:24:07 +0000435 } ;
436
shannon.woods%transgaming.com@gtempaccount.combcde56f2013-04-13 03:32:12 +0000437static yyconst flex_int16_t yy_def[92] =
alokp@chromium.org04d7d222012-05-16 19:24:07 +0000438 { 0,
shannon.woods%transgaming.com@gtempaccount.combcde56f2013-04-13 03:32:12 +0000439 86, 1, 87, 87, 86, 86, 86, 86, 86, 86,
440 86, 86, 86, 86, 86, 86, 86, 86, 86, 86,
441 20, 86, 86, 86, 88, 86, 86, 86, 89, 86,
442 86, 86, 86, 86, 86, 86, 86, 86, 86, 86,
443 86, 86, 86, 86, 86, 90, 86, 86, 20, 20,
444 48, 51, 91, 21, 86, 86, 86, 86, 86, 88,
445 86, 86, 86, 86, 86, 86, 89, 86, 86, 44,
446 44, 70, 90, 48, 51, 86, 52, 91, 86, 86,
447 86, 72, 75, 86, 86, 0, 86, 86, 86, 86,
448 86
449
alokp@chromium.org04d7d222012-05-16 19:24:07 +0000450 } ;
451
shannon.woods%transgaming.com@gtempaccount.combcde56f2013-04-13 03:32:12 +0000452static yyconst flex_int16_t yy_nxt[191] =
alokp@chromium.org04d7d222012-05-16 19:24:07 +0000453 { 0,
454 6, 7, 8, 9, 10, 11, 12, 13, 14, 15,
455 16, 17, 18, 19, 20, 21, 21, 22, 23, 24,
shannon.woods%transgaming.com@gtempaccount.combcde56f2013-04-13 03:32:12 +0000456 25, 25, 25, 25, 26, 27, 28, 30, 31, 30,
457 31, 37, 40, 65, 32, 60, 32, 42, 61, 45,
458 41, 66, 38, 46, 43, 44, 44, 44, 47, 48,
459 80, 49, 49, 50, 54, 54, 54, 51, 52, 51,
460 53, 55, 56, 51, 58, 59, 61, 62, 63, 84,
461 84, 84, 50, 50, 79, 64, 70, 51, 71, 71,
462 71, 51, 86, 86, 70, 72, 70, 70, 51, 33,
463 74, 74, 74, 51, 51, 51, 51, 75, 51, 51,
alokp@chromium.org04d7d222012-05-16 19:24:07 +0000464
shannon.woods%transgaming.com@gtempaccount.combcde56f2013-04-13 03:32:12 +0000465 51, 76, 76, 51, 69, 77, 77, 77, 70, 70,
466 70, 86, 86, 51, 51, 70, 81, 81, 86, 86,
467 82, 82, 82, 81, 81, 51, 68, 83, 83, 83,
468 85, 85, 85, 57, 39, 51, 51, 84, 84, 84,
469 85, 85, 85, 29, 29, 29, 29, 29, 67, 36,
470 35, 67, 67, 73, 34, 73, 73, 73, 78, 78,
471 33, 86, 5, 86, 86, 86, 86, 86, 86, 86,
472 86, 86, 86, 86, 86, 86, 86, 86, 86, 86,
473 86, 86, 86, 86, 86, 86, 86, 86, 86, 86
alokp@chromium.org04d7d222012-05-16 19:24:07 +0000474 } ;
475
shannon.woods%transgaming.com@gtempaccount.combcde56f2013-04-13 03:32:12 +0000476static yyconst flex_int16_t yy_chk[191] =
alokp@chromium.org04d7d222012-05-16 19:24:07 +0000477 { 0,
478 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
479 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
shannon.woods%transgaming.com@gtempaccount.combcde56f2013-04-13 03:32:12 +0000480 1, 1, 1, 1, 1, 1, 1, 3, 3, 4,
481 4, 13, 16, 28, 3, 88, 4, 17, 62, 19,
482 16, 28, 13, 19, 17, 18, 18, 18, 19, 20,
483 59, 20, 20, 20, 21, 21, 21, 20, 20, 20,
484 20, 22, 22, 21, 24, 24, 26, 26, 27, 76,
485 76, 76, 50, 50, 55, 27, 44, 49, 44, 44,
486 44, 50, 77, 77, 44, 44, 44, 44, 48, 33,
487 48, 48, 48, 51, 51, 51, 48, 48, 48, 48,
alokp@chromium.org04d7d222012-05-16 19:24:07 +0000488
shannon.woods%transgaming.com@gtempaccount.combcde56f2013-04-13 03:32:12 +0000489 51, 52, 52, 53, 32, 52, 52, 52, 70, 70,
490 70, 82, 82, 53, 53, 70, 72, 72, 83, 83,
491 72, 72, 72, 75, 75, 78, 31, 75, 75, 75,
492 81, 81, 81, 23, 15, 78, 78, 84, 84, 84,
493 85, 85, 85, 87, 87, 87, 87, 87, 89, 12,
494 10, 89, 89, 90, 9, 90, 90, 90, 91, 91,
495 7, 5, 86, 86, 86, 86, 86, 86, 86, 86,
496 86, 86, 86, 86, 86, 86, 86, 86, 86, 86,
497 86, 86, 86, 86, 86, 86, 86, 86, 86, 86
alokp@chromium.org04d7d222012-05-16 19:24:07 +0000498 } ;
499
500/* The intent behind this definition is that it'll catch
501 * any uses of REJECT which flex missed.
502 */
503#define REJECT reject_used_but_not_detected
504#define yymore() yymore_used_but_not_detected
505#define YY_MORE_ADJ 0
506#define YY_RESTORE_YY_MORE_OFFSET
507/*
508//
shannon.woods%transgaming.com@gtempaccount.combcde56f2013-04-13 03:32:12 +0000509// Copyright (c) 2002-2013 The ANGLE Project Authors. All rights reserved.
alokp@chromium.org04d7d222012-05-16 19:24:07 +0000510// Use of this source code is governed by a BSD-style license that can be
511// found in the LICENSE file.
512//
513
514This file contains the Lex specification for GLSL ES preprocessor.
515Based on Microsoft Visual Studio 2010 Preprocessor Grammar:
516http://msdn.microsoft.com/en-us/library/2scxys89.aspx
517
518IF YOU MODIFY THIS FILE YOU ALSO NEED TO RUN generate_parser.sh.
519*/
520
521#include "Tokenizer.h"
alokp@chromium.org2c958ee2012-05-17 20:35:42 +0000522
daniel@transgaming.comb3077d02013-01-11 04:12:09 +0000523#include "DiagnosticsBase.h"
alokp@chromium.org04d7d222012-05-16 19:24:07 +0000524#include "Token.h"
525
maxvujovic@gmail.comc6b3b3c2012-06-27 22:49:39 +0000526#if defined(__GNUC__)
527// Triggered by the auto-generated yy_fatal_error function.
528#pragma GCC diagnostic ignored "-Wmissing-noreturn"
529#endif
530
alokp@chromium.org04d7d222012-05-16 19:24:07 +0000531typedef std::string YYSTYPE;
alokp@chromium.org2c958ee2012-05-17 20:35:42 +0000532typedef pp::SourceLocation YYLTYPE;
alokp@chromium.org04d7d222012-05-16 19:24:07 +0000533
534// Use the unused yycolumn variable to track file (string) number.
535#define yyfileno yycolumn
536
537#define YY_USER_INIT \
538 do { \
539 yyfileno = 0; \
540 yylineno = 1; \
541 yyextra->leadingSpace = false; \
542 yyextra->lineStart = true; \
543 } while(0);
544
alokp@chromium.org19d7aa62012-05-31 17:34:05 +0000545#define YY_USER_ACTION \
546 do \
547 { \
548 pp::Input* input = &yyextra->input; \
549 pp::Input::Location* scanLoc = &yyextra->scanLoc; \
550 while ((scanLoc->sIndex < input->count()) && \
551 (scanLoc->cIndex >= input->length(scanLoc->sIndex))) \
552 { \
553 scanLoc->cIndex -= input->length(scanLoc->sIndex++); \
554 ++yyfileno; yylineno = 1; \
555 } \
556 yylloc->file = yyfileno; \
557 yylloc->line = yylineno; \
558 scanLoc->cIndex += yyleng; \
alokp@chromium.org04d7d222012-05-16 19:24:07 +0000559 } while(0);
560
561#define YY_INPUT(buf, result, maxSize) \
562 result = yyextra->input.read(buf, maxSize);
563
564#define INITIAL 0
565#define COMMENT 1
566
567#define YY_EXTRA_TYPE pp::Tokenizer::Context*
568
569/* Holds the entire state of the reentrant scanner. */
570struct yyguts_t
571 {
572
573 /* User-defined. Not touched by flex. */
574 YY_EXTRA_TYPE yyextra_r;
575
576 /* The rest are the same as the globals declared in the non-reentrant scanner. */
577 FILE *yyin_r, *yyout_r;
578 size_t yy_buffer_stack_top; /**< index of top of stack. */
579 size_t yy_buffer_stack_max; /**< capacity of stack. */
580 YY_BUFFER_STATE * yy_buffer_stack; /**< Stack as an array. */
581 char yy_hold_char;
shannonwoods@chromium.org4b8a3112013-05-30 00:13:01 +0000582 int yy_n_chars;
583 int yyleng_r;
alokp@chromium.org04d7d222012-05-16 19:24:07 +0000584 char *yy_c_buf_p;
585 int yy_init;
586 int yy_start;
587 int yy_did_buffer_switch_on_eof;
588 int yy_start_stack_ptr;
589 int yy_start_stack_depth;
590 int *yy_start_stack;
591 yy_state_type yy_last_accepting_state;
592 char* yy_last_accepting_cpos;
593
594 int yylineno_r;
595 int yy_flex_debug_r;
596
597 char *yytext_r;
598 int yy_more_flag;
599 int yy_more_len;
600
601 YYSTYPE * yylval_r;
602
603 YYLTYPE * yylloc_r;
604
605 }; /* end struct yyguts_t */
606
607static int yy_init_globals (yyscan_t yyscanner );
608
609 /* This must go here because YYSTYPE and YYLTYPE are included
610 * from bison output in section 1.*/
611 # define yylval yyg->yylval_r
612
613 # define yylloc yyg->yylloc_r
614
615int pplex_init (yyscan_t* scanner);
616
617int pplex_init_extra (YY_EXTRA_TYPE user_defined,yyscan_t* scanner);
618
619/* Accessor methods to globals.
620 These are made visible to non-reentrant scanners for convenience. */
621
622int pplex_destroy (yyscan_t yyscanner );
623
624int ppget_debug (yyscan_t yyscanner );
625
626void ppset_debug (int debug_flag ,yyscan_t yyscanner );
627
628YY_EXTRA_TYPE ppget_extra (yyscan_t yyscanner );
629
630void ppset_extra (YY_EXTRA_TYPE user_defined ,yyscan_t yyscanner );
631
632FILE *ppget_in (yyscan_t yyscanner );
633
634void ppset_in (FILE * in_str ,yyscan_t yyscanner );
635
636FILE *ppget_out (yyscan_t yyscanner );
637
638void ppset_out (FILE * out_str ,yyscan_t yyscanner );
639
shannonwoods@chromium.org4b8a3112013-05-30 00:13:01 +0000640int ppget_leng (yyscan_t yyscanner );
alokp@chromium.org04d7d222012-05-16 19:24:07 +0000641
642char *ppget_text (yyscan_t yyscanner );
643
644int ppget_lineno (yyscan_t yyscanner );
645
646void ppset_lineno (int line_number ,yyscan_t yyscanner );
647
648YYSTYPE * ppget_lval (yyscan_t yyscanner );
649
650void ppset_lval (YYSTYPE * yylval_param ,yyscan_t yyscanner );
651
652 YYLTYPE *ppget_lloc (yyscan_t yyscanner );
653
654 void ppset_lloc (YYLTYPE * yylloc_param ,yyscan_t yyscanner );
655
656/* Macros after this point can all be overridden by user definitions in
657 * section 1.
658 */
659
660#ifndef YY_SKIP_YYWRAP
661#ifdef __cplusplus
662extern "C" int ppwrap (yyscan_t yyscanner );
663#else
664extern int ppwrap (yyscan_t yyscanner );
665#endif
666#endif
667
668#ifndef yytext_ptr
669static void yy_flex_strncpy (char *,yyconst char *,int ,yyscan_t yyscanner);
670#endif
671
672#ifdef YY_NEED_STRLEN
673static int yy_flex_strlen (yyconst char * ,yyscan_t yyscanner);
674#endif
675
676#ifndef YY_NO_INPUT
677
678#ifdef __cplusplus
679static int yyinput (yyscan_t yyscanner );
680#else
681static int input (yyscan_t yyscanner );
682#endif
683
684#endif
685
686/* Amount of stuff to slurp up with each read. */
687#ifndef YY_READ_BUF_SIZE
688#define YY_READ_BUF_SIZE 8192
689#endif
690
691/* Copy whatever the last rule matched to the standard output. */
692#ifndef ECHO
693/* This used to be an fputs(), but since the string might contain NUL's,
694 * we now use fwrite().
695 */
696#define ECHO fwrite( yytext, yyleng, 1, yyout )
697#endif
698
699/* Gets input and stuffs it into "buf". number of characters read, or YY_NULL,
700 * is returned in "result".
701 */
702#ifndef YY_INPUT
703#define YY_INPUT(buf,result,max_size) \
704 if ( YY_CURRENT_BUFFER_LVALUE->yy_is_interactive ) \
705 { \
706 int c = '*'; \
shannonwoods@chromium.org4b8a3112013-05-30 00:13:01 +0000707 int n; \
alokp@chromium.org04d7d222012-05-16 19:24:07 +0000708 for ( n = 0; n < max_size && \
709 (c = getc( yyin )) != EOF && c != '\n'; ++n ) \
710 buf[n] = (char) c; \
711 if ( c == '\n' ) \
712 buf[n++] = (char) c; \
713 if ( c == EOF && ferror( yyin ) ) \
714 YY_FATAL_ERROR( "input in flex scanner failed" ); \
715 result = n; \
716 } \
717 else \
718 { \
719 errno=0; \
720 while ( (result = fread(buf, 1, max_size, yyin))==0 && ferror(yyin)) \
721 { \
722 if( errno != EINTR) \
723 { \
724 YY_FATAL_ERROR( "input in flex scanner failed" ); \
725 break; \
726 } \
727 errno=0; \
728 clearerr(yyin); \
729 } \
730 }\
731\
732
733#endif
734
735/* No semi-colon after return; correct usage is to write "yyterminate();" -
736 * we don't want an extra ';' after the "return" because that will cause
737 * some compilers to complain about unreachable statements.
738 */
739#ifndef yyterminate
740#define yyterminate() return YY_NULL
741#endif
742
743/* Number of entries by which start-condition stack grows. */
744#ifndef YY_START_STACK_INCR
745#define YY_START_STACK_INCR 25
746#endif
747
748/* Report a fatal error. */
749#ifndef YY_FATAL_ERROR
750#define YY_FATAL_ERROR(msg) yy_fatal_error( msg , yyscanner)
751#endif
752
753/* end tables serialization structures and prototypes */
754
755/* Default declaration of generated scanner - a define so the user can
756 * easily add parameters.
757 */
758#ifndef YY_DECL
759#define YY_DECL_IS_OURS 1
760
761extern int pplex \
762 (YYSTYPE * yylval_param,YYLTYPE * yylloc_param ,yyscan_t yyscanner);
763
764#define YY_DECL int pplex \
765 (YYSTYPE * yylval_param, YYLTYPE * yylloc_param , yyscan_t yyscanner)
766#endif /* !YY_DECL */
767
768/* Code executed at the beginning of each rule, after yytext and yyleng
769 * have been set up.
770 */
771#ifndef YY_USER_ACTION
772#define YY_USER_ACTION
773#endif
774
775/* Code executed at the end of each rule. */
776#ifndef YY_BREAK
777#define YY_BREAK break;
778#endif
779
780#define YY_RULE_SETUP \
781 YY_USER_ACTION
782
783/** The main scanner function which does all the work.
784 */
785YY_DECL
786{
787 register yy_state_type yy_current_state;
788 register char *yy_cp, *yy_bp;
789 register int yy_act;
790 struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
791
792 /* Line comment */
793
794 yylval = yylval_param;
795
796 yylloc = yylloc_param;
797
798 if ( !yyg->yy_init )
799 {
800 yyg->yy_init = 1;
801
802#ifdef YY_USER_INIT
803 YY_USER_INIT;
804#endif
805
806 if ( ! yyg->yy_start )
807 yyg->yy_start = 1; /* first start state */
808
809 if ( ! yyin )
810 yyin = stdin;
811
812 if ( ! yyout )
813 yyout = stdout;
814
815 if ( ! YY_CURRENT_BUFFER ) {
816 ppensure_buffer_stack (yyscanner);
817 YY_CURRENT_BUFFER_LVALUE =
818 pp_create_buffer(yyin,YY_BUF_SIZE ,yyscanner);
819 }
820
821 pp_load_buffer_state(yyscanner );
822 }
823
824 while ( 1 ) /* loops until end-of-file is reached */
825 {
826 yy_cp = yyg->yy_c_buf_p;
827
828 /* Support of yytext. */
829 *yy_cp = yyg->yy_hold_char;
830
831 /* yy_bp points to the position in yy_ch_buf of the start of
832 * the current run.
833 */
834 yy_bp = yy_cp;
835
836 yy_current_state = yyg->yy_start;
837yy_match:
838 do
839 {
840 register YY_CHAR yy_c = yy_ec[YY_SC_TO_UI(*yy_cp)];
841 if ( yy_accept[yy_current_state] )
842 {
843 yyg->yy_last_accepting_state = yy_current_state;
844 yyg->yy_last_accepting_cpos = yy_cp;
845 }
846 while ( yy_chk[yy_base[yy_current_state] + yy_c] != yy_current_state )
847 {
848 yy_current_state = (int) yy_def[yy_current_state];
shannon.woods%transgaming.com@gtempaccount.combcde56f2013-04-13 03:32:12 +0000849 if ( yy_current_state >= 87 )
alokp@chromium.org04d7d222012-05-16 19:24:07 +0000850 yy_c = yy_meta[(unsigned int) yy_c];
851 }
852 yy_current_state = yy_nxt[yy_base[yy_current_state] + (unsigned int) yy_c];
853 ++yy_cp;
854 }
shannon.woods%transgaming.com@gtempaccount.combcde56f2013-04-13 03:32:12 +0000855 while ( yy_current_state != 86 );
alokp@chromium.org04d7d222012-05-16 19:24:07 +0000856 yy_cp = yyg->yy_last_accepting_cpos;
857 yy_current_state = yyg->yy_last_accepting_state;
858
859yy_find_action:
860 yy_act = yy_accept[yy_current_state];
861
862 YY_DO_BEFORE_ACTION;
863
864do_action: /* This label is used only to access EOF actions. */
865
866 switch ( yy_act )
867 { /* beginning of action switch */
868 case 0: /* must back up */
869 /* undo the effects of YY_DO_BEFORE_ACTION */
870 *yy_cp = yyg->yy_hold_char;
871 yy_cp = yyg->yy_last_accepting_cpos;
872 yy_current_state = yyg->yy_last_accepting_state;
873 goto yy_find_action;
874
875case 1:
876YY_RULE_SETUP
877
878 YY_BREAK
879/* Block comment */
880/* Line breaks are just counted - not returned. */
881/* The comment is replaced by a single space. */
882case 2:
883YY_RULE_SETUP
884{ BEGIN(COMMENT); }
885 YY_BREAK
886case 3:
887YY_RULE_SETUP
888
889 YY_BREAK
890case 4:
891YY_RULE_SETUP
892
893 YY_BREAK
894case 5:
895/* rule 5 can match eol */
896YY_RULE_SETUP
897{ ++yylineno; }
898 YY_BREAK
alokp@chromium.org04d7d222012-05-16 19:24:07 +0000899case 6:
900YY_RULE_SETUP
alokp@chromium.org2c958ee2012-05-17 20:35:42 +0000901{
902 yyextra->leadingSpace = true;
903 BEGIN(INITIAL);
904}
alokp@chromium.org04d7d222012-05-16 19:24:07 +0000905 YY_BREAK
906case 7:
907YY_RULE_SETUP
908{
909 // # is only valid at start of line for preprocessor directives.
alokp@chromium.org432d6fc2012-06-27 22:13:21 +0000910 yylval->assign(1, yytext[0]);
911 return yyextra->lineStart ? pp::Token::PP_HASH : pp::Token::PP_OTHER;
alokp@chromium.org04d7d222012-05-16 19:24:07 +0000912}
913 YY_BREAK
914case 8:
915YY_RULE_SETUP
916{
917 yylval->assign(yytext, yyleng);
918 return pp::Token::IDENTIFIER;
919}
920 YY_BREAK
921case 9:
922YY_RULE_SETUP
923{
924 yylval->assign(yytext, yyleng);
925 return pp::Token::CONST_INT;
926}
927 YY_BREAK
928case 10:
929YY_RULE_SETUP
930{
931 yylval->assign(yytext, yyleng);
932 return pp::Token::CONST_FLOAT;
933}
934 YY_BREAK
935/* Anything that starts with a {DIGIT} or .{DIGIT} must be a number. */
936/* Rule to catch all invalid integers and floats. */
937case 11:
938YY_RULE_SETUP
939{
alokp@chromium.org432d6fc2012-06-27 22:13:21 +0000940 yylval->assign(yytext, yyleng);
941 return pp::Token::PP_NUMBER;
alokp@chromium.org04d7d222012-05-16 19:24:07 +0000942}
943 YY_BREAK
944case 12:
945YY_RULE_SETUP
alokp@chromium.org07d921d2012-05-22 20:22:08 +0000946{
947 yylval->assign(yytext, yyleng);
948 return pp::Token::OP_INC;
949}
alokp@chromium.org04d7d222012-05-16 19:24:07 +0000950 YY_BREAK
951case 13:
952YY_RULE_SETUP
alokp@chromium.org07d921d2012-05-22 20:22:08 +0000953{
954 yylval->assign(yytext, yyleng);
955 return pp::Token::OP_DEC;
956}
alokp@chromium.org04d7d222012-05-16 19:24:07 +0000957 YY_BREAK
958case 14:
959YY_RULE_SETUP
alokp@chromium.org07d921d2012-05-22 20:22:08 +0000960{
961 yylval->assign(yytext, yyleng);
962 return pp::Token::OP_LEFT;
963}
alokp@chromium.org04d7d222012-05-16 19:24:07 +0000964 YY_BREAK
965case 15:
966YY_RULE_SETUP
alokp@chromium.org07d921d2012-05-22 20:22:08 +0000967{
968 yylval->assign(yytext, yyleng);
969 return pp::Token::OP_RIGHT;
970}
alokp@chromium.org04d7d222012-05-16 19:24:07 +0000971 YY_BREAK
972case 16:
973YY_RULE_SETUP
alokp@chromium.org07d921d2012-05-22 20:22:08 +0000974{
975 yylval->assign(yytext, yyleng);
976 return pp::Token::OP_LE;
977}
alokp@chromium.org04d7d222012-05-16 19:24:07 +0000978 YY_BREAK
979case 17:
980YY_RULE_SETUP
alokp@chromium.org07d921d2012-05-22 20:22:08 +0000981{
982 yylval->assign(yytext, yyleng);
983 return pp::Token::OP_GE;
984}
alokp@chromium.org04d7d222012-05-16 19:24:07 +0000985 YY_BREAK
986case 18:
987YY_RULE_SETUP
alokp@chromium.org07d921d2012-05-22 20:22:08 +0000988{
989 yylval->assign(yytext, yyleng);
990 return pp::Token::OP_EQ;
991}
alokp@chromium.org04d7d222012-05-16 19:24:07 +0000992 YY_BREAK
993case 19:
994YY_RULE_SETUP
alokp@chromium.org07d921d2012-05-22 20:22:08 +0000995{
996 yylval->assign(yytext, yyleng);
997 return pp::Token::OP_NE;
998}
alokp@chromium.org04d7d222012-05-16 19:24:07 +0000999 YY_BREAK
1000case 20:
1001YY_RULE_SETUP
alokp@chromium.org07d921d2012-05-22 20:22:08 +00001002{
1003 yylval->assign(yytext, yyleng);
1004 return pp::Token::OP_AND;
1005}
alokp@chromium.org04d7d222012-05-16 19:24:07 +00001006 YY_BREAK
1007case 21:
1008YY_RULE_SETUP
alokp@chromium.org07d921d2012-05-22 20:22:08 +00001009{
1010 yylval->assign(yytext, yyleng);
1011 return pp::Token::OP_XOR;
1012}
alokp@chromium.org04d7d222012-05-16 19:24:07 +00001013 YY_BREAK
1014case 22:
1015YY_RULE_SETUP
alokp@chromium.org07d921d2012-05-22 20:22:08 +00001016{
1017 yylval->assign(yytext, yyleng);
1018 return pp::Token::OP_OR;
1019}
alokp@chromium.org04d7d222012-05-16 19:24:07 +00001020 YY_BREAK
1021case 23:
1022YY_RULE_SETUP
alokp@chromium.org07d921d2012-05-22 20:22:08 +00001023{
1024 yylval->assign(yytext, yyleng);
1025 return pp::Token::OP_ADD_ASSIGN;
1026}
alokp@chromium.org04d7d222012-05-16 19:24:07 +00001027 YY_BREAK
1028case 24:
1029YY_RULE_SETUP
alokp@chromium.org07d921d2012-05-22 20:22:08 +00001030{
1031 yylval->assign(yytext, yyleng);
1032 return pp::Token::OP_SUB_ASSIGN;
1033}
alokp@chromium.org04d7d222012-05-16 19:24:07 +00001034 YY_BREAK
1035case 25:
1036YY_RULE_SETUP
alokp@chromium.org07d921d2012-05-22 20:22:08 +00001037{
1038 yylval->assign(yytext, yyleng);
1039 return pp::Token::OP_MUL_ASSIGN;
1040}
alokp@chromium.org04d7d222012-05-16 19:24:07 +00001041 YY_BREAK
1042case 26:
1043YY_RULE_SETUP
alokp@chromium.org07d921d2012-05-22 20:22:08 +00001044{
1045 yylval->assign(yytext, yyleng);
1046 return pp::Token::OP_DIV_ASSIGN;
1047}
alokp@chromium.org04d7d222012-05-16 19:24:07 +00001048 YY_BREAK
1049case 27:
1050YY_RULE_SETUP
alokp@chromium.org07d921d2012-05-22 20:22:08 +00001051{
1052 yylval->assign(yytext, yyleng);
1053 return pp::Token::OP_MOD_ASSIGN;
1054}
alokp@chromium.org04d7d222012-05-16 19:24:07 +00001055 YY_BREAK
1056case 28:
1057YY_RULE_SETUP
alokp@chromium.org07d921d2012-05-22 20:22:08 +00001058{
1059 yylval->assign(yytext, yyleng);
1060 return pp::Token::OP_LEFT_ASSIGN;
1061}
alokp@chromium.org04d7d222012-05-16 19:24:07 +00001062 YY_BREAK
1063case 29:
1064YY_RULE_SETUP
alokp@chromium.org07d921d2012-05-22 20:22:08 +00001065{
1066 yylval->assign(yytext, yyleng);
1067 return pp::Token::OP_RIGHT_ASSIGN;
1068}
alokp@chromium.org04d7d222012-05-16 19:24:07 +00001069 YY_BREAK
1070case 30:
1071YY_RULE_SETUP
alokp@chromium.org07d921d2012-05-22 20:22:08 +00001072{
1073 yylval->assign(yytext, yyleng);
1074 return pp::Token::OP_AND_ASSIGN;
1075}
alokp@chromium.org04d7d222012-05-16 19:24:07 +00001076 YY_BREAK
1077case 31:
1078YY_RULE_SETUP
alokp@chromium.org07d921d2012-05-22 20:22:08 +00001079{
1080 yylval->assign(yytext, yyleng);
1081 return pp::Token::OP_XOR_ASSIGN;
1082}
alokp@chromium.org04d7d222012-05-16 19:24:07 +00001083 YY_BREAK
1084case 32:
1085YY_RULE_SETUP
alokp@chromium.org07d921d2012-05-22 20:22:08 +00001086{
1087 yylval->assign(yytext, yyleng);
1088 return pp::Token::OP_OR_ASSIGN;
1089}
alokp@chromium.org04d7d222012-05-16 19:24:07 +00001090 YY_BREAK
1091case 33:
1092YY_RULE_SETUP
alokp@chromium.org07d921d2012-05-22 20:22:08 +00001093{
1094 yylval->assign(1, yytext[0]);
1095 return yytext[0];
1096}
alokp@chromium.org04d7d222012-05-16 19:24:07 +00001097 YY_BREAK
1098case 34:
1099YY_RULE_SETUP
1100{ yyextra->leadingSpace = true; }
1101 YY_BREAK
1102case 35:
1103/* rule 35 can match eol */
1104YY_RULE_SETUP
1105{
1106 ++yylineno;
alokp@chromium.org07d921d2012-05-22 20:22:08 +00001107 yylval->assign(1, '\n');
alokp@chromium.org04d7d222012-05-16 19:24:07 +00001108 return '\n';
1109}
1110 YY_BREAK
1111case 36:
shannon.woods%transgaming.com@gtempaccount.combcde56f2013-04-13 03:32:12 +00001112/* rule 36 can match eol */
1113YY_RULE_SETUP
1114{ ++yylineno; }
1115 YY_BREAK
1116case 37:
alokp@chromium.org04d7d222012-05-16 19:24:07 +00001117YY_RULE_SETUP
1118{
alokp@chromium.org432d6fc2012-06-27 22:13:21 +00001119 yylval->assign(1, yytext[0]);
1120 return pp::Token::PP_OTHER;
alokp@chromium.org04d7d222012-05-16 19:24:07 +00001121}
1122 YY_BREAK
1123case YY_STATE_EOF(INITIAL):
alokp@chromium.org07d921d2012-05-22 20:22:08 +00001124case YY_STATE_EOF(COMMENT):
1125{
alokp@chromium.org19d7aa62012-05-31 17:34:05 +00001126 // YY_USER_ACTION is not invoked for handling EOF.
1127 // Set the location for EOF token manually.
1128 pp::Input* input = &yyextra->input;
1129 pp::Input::Location* scanLoc = &yyextra->scanLoc;
shannon.woods@transgaming.comd64b3da2013-02-28 23:19:26 +00001130 yy_size_t sIndexMax = input->count() ? input->count() - 1 : 0;
alokp@chromium.org19d7aa62012-05-31 17:34:05 +00001131 if (scanLoc->sIndex != sIndexMax)
1132 {
1133 // We can only reach here if there are empty strings at the
1134 // end of the input.
1135 scanLoc->sIndex = sIndexMax; scanLoc->cIndex = 0;
shannon.woods@transgaming.comd64b3da2013-02-28 23:19:26 +00001136 // FIXME: this is not 64-bit clean.
1137 yyfileno = static_cast<int>(sIndexMax); yylineno = 1;
alokp@chromium.org19d7aa62012-05-31 17:34:05 +00001138 }
1139 yylloc->file = yyfileno;
1140 yylloc->line = yylineno;
1141 yylval->clear();
1142
alokp@chromium.org07d921d2012-05-22 20:22:08 +00001143 if (YY_START == COMMENT)
1144 {
1145 yyextra->diagnostics->report(pp::Diagnostics::EOF_IN_COMMENT,
1146 pp::SourceLocation(yyfileno, yylineno),
1147 "");
1148 }
alokp@chromium.org07d921d2012-05-22 20:22:08 +00001149 yyterminate();
1150}
alokp@chromium.org04d7d222012-05-16 19:24:07 +00001151 YY_BREAK
shannon.woods%transgaming.com@gtempaccount.combcde56f2013-04-13 03:32:12 +00001152case 38:
alokp@chromium.org04d7d222012-05-16 19:24:07 +00001153YY_RULE_SETUP
1154ECHO;
1155 YY_BREAK
1156
1157 case YY_END_OF_BUFFER:
1158 {
1159 /* Amount of text matched not including the EOB char. */
1160 int yy_amount_of_matched_text = (int) (yy_cp - yyg->yytext_ptr) - 1;
1161
1162 /* Undo the effects of YY_DO_BEFORE_ACTION. */
1163 *yy_cp = yyg->yy_hold_char;
1164 YY_RESTORE_YY_MORE_OFFSET
1165
1166 if ( YY_CURRENT_BUFFER_LVALUE->yy_buffer_status == YY_BUFFER_NEW )
1167 {
1168 /* We're scanning a new file or input source. It's
1169 * possible that this happened because the user
1170 * just pointed yyin at a new source and called
1171 * pplex(). If so, then we have to assure
1172 * consistency between YY_CURRENT_BUFFER and our
1173 * globals. Here is the right place to do so, because
1174 * this is the first action (other than possibly a
1175 * back-up) that will match for the new input source.
1176 */
1177 yyg->yy_n_chars = YY_CURRENT_BUFFER_LVALUE->yy_n_chars;
1178 YY_CURRENT_BUFFER_LVALUE->yy_input_file = yyin;
1179 YY_CURRENT_BUFFER_LVALUE->yy_buffer_status = YY_BUFFER_NORMAL;
1180 }
1181
1182 /* Note that here we test for yy_c_buf_p "<=" to the position
1183 * of the first EOB in the buffer, since yy_c_buf_p will
1184 * already have been incremented past the NUL character
1185 * (since all states make transitions on EOB to the
1186 * end-of-buffer state). Contrast this with the test
1187 * in input().
1188 */
1189 if ( yyg->yy_c_buf_p <= &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[yyg->yy_n_chars] )
1190 { /* This was really a NUL. */
1191 yy_state_type yy_next_state;
1192
1193 yyg->yy_c_buf_p = yyg->yytext_ptr + yy_amount_of_matched_text;
1194
1195 yy_current_state = yy_get_previous_state( yyscanner );
1196
1197 /* Okay, we're now positioned to make the NUL
1198 * transition. We couldn't have
1199 * yy_get_previous_state() go ahead and do it
1200 * for us because it doesn't know how to deal
1201 * with the possibility of jamming (and we don't
1202 * want to build jamming into it because then it
1203 * will run more slowly).
1204 */
1205
1206 yy_next_state = yy_try_NUL_trans( yy_current_state , yyscanner);
1207
1208 yy_bp = yyg->yytext_ptr + YY_MORE_ADJ;
1209
1210 if ( yy_next_state )
1211 {
1212 /* Consume the NUL. */
1213 yy_cp = ++yyg->yy_c_buf_p;
1214 yy_current_state = yy_next_state;
1215 goto yy_match;
1216 }
1217
1218 else
1219 {
1220 yy_cp = yyg->yy_last_accepting_cpos;
1221 yy_current_state = yyg->yy_last_accepting_state;
1222 goto yy_find_action;
1223 }
1224 }
1225
1226 else switch ( yy_get_next_buffer( yyscanner ) )
1227 {
1228 case EOB_ACT_END_OF_FILE:
1229 {
1230 yyg->yy_did_buffer_switch_on_eof = 0;
1231
1232 if ( ppwrap(yyscanner ) )
1233 {
1234 /* Note: because we've taken care in
1235 * yy_get_next_buffer() to have set up
1236 * yytext, we can now set up
1237 * yy_c_buf_p so that if some total
1238 * hoser (like flex itself) wants to
1239 * call the scanner after we return the
1240 * YY_NULL, it'll still work - another
1241 * YY_NULL will get returned.
1242 */
1243 yyg->yy_c_buf_p = yyg->yytext_ptr + YY_MORE_ADJ;
1244
1245 yy_act = YY_STATE_EOF(YY_START);
1246 goto do_action;
1247 }
1248
1249 else
1250 {
1251 if ( ! yyg->yy_did_buffer_switch_on_eof )
1252 YY_NEW_FILE;
1253 }
1254 break;
1255 }
1256
1257 case EOB_ACT_CONTINUE_SCAN:
1258 yyg->yy_c_buf_p =
1259 yyg->yytext_ptr + yy_amount_of_matched_text;
1260
1261 yy_current_state = yy_get_previous_state( yyscanner );
1262
1263 yy_cp = yyg->yy_c_buf_p;
1264 yy_bp = yyg->yytext_ptr + YY_MORE_ADJ;
1265 goto yy_match;
1266
1267 case EOB_ACT_LAST_MATCH:
1268 yyg->yy_c_buf_p =
1269 &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[yyg->yy_n_chars];
1270
1271 yy_current_state = yy_get_previous_state( yyscanner );
1272
1273 yy_cp = yyg->yy_c_buf_p;
1274 yy_bp = yyg->yytext_ptr + YY_MORE_ADJ;
1275 goto yy_find_action;
1276 }
1277 break;
1278 }
1279
1280 default:
1281 YY_FATAL_ERROR(
1282 "fatal flex scanner internal error--no action found" );
1283 } /* end of action switch */
1284 } /* end of scanning one token */
1285} /* end of pplex */
1286
1287/* yy_get_next_buffer - try to read in a new buffer
1288 *
1289 * Returns a code representing an action:
1290 * EOB_ACT_LAST_MATCH -
1291 * EOB_ACT_CONTINUE_SCAN - continue scanning from current position
1292 * EOB_ACT_END_OF_FILE - end of file
1293 */
1294static int yy_get_next_buffer (yyscan_t yyscanner)
1295{
1296 struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
1297 register char *dest = YY_CURRENT_BUFFER_LVALUE->yy_ch_buf;
1298 register char *source = yyg->yytext_ptr;
1299 register int number_to_move, i;
1300 int ret_val;
1301
1302 if ( yyg->yy_c_buf_p > &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[yyg->yy_n_chars + 1] )
1303 YY_FATAL_ERROR(
1304 "fatal flex scanner internal error--end of buffer missed" );
1305
1306 if ( YY_CURRENT_BUFFER_LVALUE->yy_fill_buffer == 0 )
1307 { /* Don't try to fill the buffer, so this is an EOF. */
1308 if ( yyg->yy_c_buf_p - yyg->yytext_ptr - YY_MORE_ADJ == 1 )
1309 {
1310 /* We matched a single character, the EOB, so
1311 * treat this as a final EOF.
1312 */
1313 return EOB_ACT_END_OF_FILE;
1314 }
1315
1316 else
1317 {
1318 /* We matched some text prior to the EOB, first
1319 * process it.
1320 */
1321 return EOB_ACT_LAST_MATCH;
1322 }
1323 }
1324
1325 /* Try to read more data. */
1326
1327 /* First move last chars to start of buffer. */
1328 number_to_move = (int) (yyg->yy_c_buf_p - yyg->yytext_ptr) - 1;
1329
1330 for ( i = 0; i < number_to_move; ++i )
1331 *(dest++) = *(source++);
1332
1333 if ( YY_CURRENT_BUFFER_LVALUE->yy_buffer_status == YY_BUFFER_EOF_PENDING )
1334 /* don't do the read, it's not guaranteed to return an EOF,
1335 * just force an EOF
1336 */
1337 YY_CURRENT_BUFFER_LVALUE->yy_n_chars = yyg->yy_n_chars = 0;
1338
1339 else
1340 {
shannonwoods@chromium.org4b8a3112013-05-30 00:13:01 +00001341 int num_to_read =
alokp@chromium.org04d7d222012-05-16 19:24:07 +00001342 YY_CURRENT_BUFFER_LVALUE->yy_buf_size - number_to_move - 1;
1343
1344 while ( num_to_read <= 0 )
1345 { /* Not enough room in the buffer - grow it. */
1346
1347 /* just a shorter name for the current buffer */
1348 YY_BUFFER_STATE b = YY_CURRENT_BUFFER;
1349
1350 int yy_c_buf_p_offset =
1351 (int) (yyg->yy_c_buf_p - b->yy_ch_buf);
1352
1353 if ( b->yy_is_our_buffer )
1354 {
shannonwoods@chromium.org4b8a3112013-05-30 00:13:01 +00001355 int new_size = b->yy_buf_size * 2;
alokp@chromium.org04d7d222012-05-16 19:24:07 +00001356
1357 if ( new_size <= 0 )
1358 b->yy_buf_size += b->yy_buf_size / 8;
1359 else
1360 b->yy_buf_size *= 2;
1361
1362 b->yy_ch_buf = (char *)
1363 /* Include room in for 2 EOB chars. */
1364 pprealloc((void *) b->yy_ch_buf,b->yy_buf_size + 2 ,yyscanner );
1365 }
1366 else
1367 /* Can't grow it, we don't own it. */
1368 b->yy_ch_buf = 0;
1369
1370 if ( ! b->yy_ch_buf )
1371 YY_FATAL_ERROR(
1372 "fatal error - scanner input buffer overflow" );
1373
1374 yyg->yy_c_buf_p = &b->yy_ch_buf[yy_c_buf_p_offset];
1375
1376 num_to_read = YY_CURRENT_BUFFER_LVALUE->yy_buf_size -
1377 number_to_move - 1;
1378
1379 }
1380
1381 if ( num_to_read > YY_READ_BUF_SIZE )
1382 num_to_read = YY_READ_BUF_SIZE;
1383
1384 /* Read in more data. */
1385 YY_INPUT( (&YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[number_to_move]),
shannonwoods@chromium.org4b8a3112013-05-30 00:13:01 +00001386 yyg->yy_n_chars, (size_t) num_to_read );
alokp@chromium.org04d7d222012-05-16 19:24:07 +00001387
1388 YY_CURRENT_BUFFER_LVALUE->yy_n_chars = yyg->yy_n_chars;
1389 }
1390
1391 if ( yyg->yy_n_chars == 0 )
1392 {
1393 if ( number_to_move == YY_MORE_ADJ )
1394 {
1395 ret_val = EOB_ACT_END_OF_FILE;
1396 pprestart(yyin ,yyscanner);
1397 }
1398
1399 else
1400 {
1401 ret_val = EOB_ACT_LAST_MATCH;
1402 YY_CURRENT_BUFFER_LVALUE->yy_buffer_status =
1403 YY_BUFFER_EOF_PENDING;
1404 }
1405 }
1406
1407 else
1408 ret_val = EOB_ACT_CONTINUE_SCAN;
1409
1410 if ((yy_size_t) (yyg->yy_n_chars + number_to_move) > YY_CURRENT_BUFFER_LVALUE->yy_buf_size) {
1411 /* Extend the array by 50%, plus the number we really need. */
1412 yy_size_t new_size = yyg->yy_n_chars + number_to_move + (yyg->yy_n_chars >> 1);
1413 YY_CURRENT_BUFFER_LVALUE->yy_ch_buf = (char *) pprealloc((void *) YY_CURRENT_BUFFER_LVALUE->yy_ch_buf,new_size ,yyscanner );
1414 if ( ! YY_CURRENT_BUFFER_LVALUE->yy_ch_buf )
1415 YY_FATAL_ERROR( "out of dynamic memory in yy_get_next_buffer()" );
1416 }
1417
1418 yyg->yy_n_chars += number_to_move;
1419 YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[yyg->yy_n_chars] = YY_END_OF_BUFFER_CHAR;
1420 YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[yyg->yy_n_chars + 1] = YY_END_OF_BUFFER_CHAR;
1421
1422 yyg->yytext_ptr = &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[0];
1423
1424 return ret_val;
1425}
1426
1427/* yy_get_previous_state - get the state just before the EOB char was reached */
1428
1429 static yy_state_type yy_get_previous_state (yyscan_t yyscanner)
1430{
1431 register yy_state_type yy_current_state;
1432 register char *yy_cp;
1433 struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
1434
1435 yy_current_state = yyg->yy_start;
1436
1437 for ( yy_cp = yyg->yytext_ptr + YY_MORE_ADJ; yy_cp < yyg->yy_c_buf_p; ++yy_cp )
1438 {
1439 register YY_CHAR yy_c = (*yy_cp ? yy_ec[YY_SC_TO_UI(*yy_cp)] : 1);
1440 if ( yy_accept[yy_current_state] )
1441 {
1442 yyg->yy_last_accepting_state = yy_current_state;
1443 yyg->yy_last_accepting_cpos = yy_cp;
1444 }
1445 while ( yy_chk[yy_base[yy_current_state] + yy_c] != yy_current_state )
1446 {
1447 yy_current_state = (int) yy_def[yy_current_state];
shannon.woods%transgaming.com@gtempaccount.combcde56f2013-04-13 03:32:12 +00001448 if ( yy_current_state >= 87 )
alokp@chromium.org04d7d222012-05-16 19:24:07 +00001449 yy_c = yy_meta[(unsigned int) yy_c];
1450 }
1451 yy_current_state = yy_nxt[yy_base[yy_current_state] + (unsigned int) yy_c];
1452 }
1453
1454 return yy_current_state;
1455}
1456
1457/* yy_try_NUL_trans - try to make a transition on the NUL character
1458 *
1459 * synopsis
1460 * next_state = yy_try_NUL_trans( current_state );
1461 */
1462 static yy_state_type yy_try_NUL_trans (yy_state_type yy_current_state , yyscan_t yyscanner)
1463{
1464 register int yy_is_jam;
1465 struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; /* This var may be unused depending upon options. */
1466 register char *yy_cp = yyg->yy_c_buf_p;
1467
1468 register YY_CHAR yy_c = 1;
1469 if ( yy_accept[yy_current_state] )
1470 {
1471 yyg->yy_last_accepting_state = yy_current_state;
1472 yyg->yy_last_accepting_cpos = yy_cp;
1473 }
1474 while ( yy_chk[yy_base[yy_current_state] + yy_c] != yy_current_state )
1475 {
1476 yy_current_state = (int) yy_def[yy_current_state];
shannon.woods%transgaming.com@gtempaccount.combcde56f2013-04-13 03:32:12 +00001477 if ( yy_current_state >= 87 )
alokp@chromium.org04d7d222012-05-16 19:24:07 +00001478 yy_c = yy_meta[(unsigned int) yy_c];
1479 }
1480 yy_current_state = yy_nxt[yy_base[yy_current_state] + (unsigned int) yy_c];
shannon.woods%transgaming.com@gtempaccount.combcde56f2013-04-13 03:32:12 +00001481 yy_is_jam = (yy_current_state == 86);
alokp@chromium.org04d7d222012-05-16 19:24:07 +00001482
1483 return yy_is_jam ? 0 : yy_current_state;
1484}
1485
1486#ifndef YY_NO_INPUT
1487#ifdef __cplusplus
1488 static int yyinput (yyscan_t yyscanner)
1489#else
1490 static int input (yyscan_t yyscanner)
1491#endif
1492
1493{
1494 int c;
1495 struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
1496
1497 *yyg->yy_c_buf_p = yyg->yy_hold_char;
1498
1499 if ( *yyg->yy_c_buf_p == YY_END_OF_BUFFER_CHAR )
1500 {
1501 /* yy_c_buf_p now points to the character we want to return.
1502 * If this occurs *before* the EOB characters, then it's a
1503 * valid NUL; if not, then we've hit the end of the buffer.
1504 */
1505 if ( yyg->yy_c_buf_p < &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[yyg->yy_n_chars] )
1506 /* This was really a NUL. */
1507 *yyg->yy_c_buf_p = '\0';
1508
1509 else
1510 { /* need more input */
shannonwoods@chromium.org4b8a3112013-05-30 00:13:01 +00001511 int offset = yyg->yy_c_buf_p - yyg->yytext_ptr;
alokp@chromium.org04d7d222012-05-16 19:24:07 +00001512 ++yyg->yy_c_buf_p;
1513
1514 switch ( yy_get_next_buffer( yyscanner ) )
1515 {
1516 case EOB_ACT_LAST_MATCH:
1517 /* This happens because yy_g_n_b()
1518 * sees that we've accumulated a
1519 * token and flags that we need to
1520 * try matching the token before
1521 * proceeding. But for input(),
1522 * there's no matching to consider.
1523 * So convert the EOB_ACT_LAST_MATCH
1524 * to EOB_ACT_END_OF_FILE.
1525 */
1526
1527 /* Reset buffer status. */
1528 pprestart(yyin ,yyscanner);
1529
1530 /*FALLTHROUGH*/
1531
1532 case EOB_ACT_END_OF_FILE:
1533 {
1534 if ( ppwrap(yyscanner ) )
shannonwoods@chromium.org4b8a3112013-05-30 00:13:01 +00001535 return EOF;
alokp@chromium.org04d7d222012-05-16 19:24:07 +00001536
1537 if ( ! yyg->yy_did_buffer_switch_on_eof )
1538 YY_NEW_FILE;
1539#ifdef __cplusplus
1540 return yyinput(yyscanner);
1541#else
1542 return input(yyscanner);
1543#endif
1544 }
1545
1546 case EOB_ACT_CONTINUE_SCAN:
1547 yyg->yy_c_buf_p = yyg->yytext_ptr + offset;
1548 break;
1549 }
1550 }
1551 }
1552
1553 c = *(unsigned char *) yyg->yy_c_buf_p; /* cast for 8-bit char's */
1554 *yyg->yy_c_buf_p = '\0'; /* preserve yytext */
1555 yyg->yy_hold_char = *++yyg->yy_c_buf_p;
1556
1557 return c;
1558}
1559#endif /* ifndef YY_NO_INPUT */
1560
1561/** Immediately switch to a different input stream.
1562 * @param input_file A readable stream.
1563 * @param yyscanner The scanner object.
1564 * @note This function does not reset the start condition to @c INITIAL .
1565 */
1566 void pprestart (FILE * input_file , yyscan_t yyscanner)
1567{
1568 struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
1569
1570 if ( ! YY_CURRENT_BUFFER ){
1571 ppensure_buffer_stack (yyscanner);
1572 YY_CURRENT_BUFFER_LVALUE =
1573 pp_create_buffer(yyin,YY_BUF_SIZE ,yyscanner);
1574 }
1575
1576 pp_init_buffer(YY_CURRENT_BUFFER,input_file ,yyscanner);
1577 pp_load_buffer_state(yyscanner );
1578}
1579
1580/** Switch to a different input buffer.
1581 * @param new_buffer The new input buffer.
1582 * @param yyscanner The scanner object.
1583 */
1584 void pp_switch_to_buffer (YY_BUFFER_STATE new_buffer , yyscan_t yyscanner)
1585{
1586 struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
1587
1588 /* TODO. We should be able to replace this entire function body
1589 * with
1590 * pppop_buffer_state();
1591 * pppush_buffer_state(new_buffer);
1592 */
1593 ppensure_buffer_stack (yyscanner);
1594 if ( YY_CURRENT_BUFFER == new_buffer )
1595 return;
1596
1597 if ( YY_CURRENT_BUFFER )
1598 {
1599 /* Flush out information for old buffer. */
1600 *yyg->yy_c_buf_p = yyg->yy_hold_char;
1601 YY_CURRENT_BUFFER_LVALUE->yy_buf_pos = yyg->yy_c_buf_p;
1602 YY_CURRENT_BUFFER_LVALUE->yy_n_chars = yyg->yy_n_chars;
1603 }
1604
1605 YY_CURRENT_BUFFER_LVALUE = new_buffer;
1606 pp_load_buffer_state(yyscanner );
1607
1608 /* We don't actually know whether we did this switch during
1609 * EOF (ppwrap()) processing, but the only time this flag
1610 * is looked at is after ppwrap() is called, so it's safe
1611 * to go ahead and always set it.
1612 */
1613 yyg->yy_did_buffer_switch_on_eof = 1;
1614}
1615
1616static void pp_load_buffer_state (yyscan_t yyscanner)
1617{
1618 struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
1619 yyg->yy_n_chars = YY_CURRENT_BUFFER_LVALUE->yy_n_chars;
1620 yyg->yytext_ptr = yyg->yy_c_buf_p = YY_CURRENT_BUFFER_LVALUE->yy_buf_pos;
1621 yyin = YY_CURRENT_BUFFER_LVALUE->yy_input_file;
1622 yyg->yy_hold_char = *yyg->yy_c_buf_p;
1623}
1624
1625/** Allocate and initialize an input buffer state.
1626 * @param file A readable stream.
1627 * @param size The character buffer size in bytes. When in doubt, use @c YY_BUF_SIZE.
1628 * @param yyscanner The scanner object.
1629 * @return the allocated buffer state.
1630 */
1631 YY_BUFFER_STATE pp_create_buffer (FILE * file, int size , yyscan_t yyscanner)
1632{
1633 YY_BUFFER_STATE b;
1634
1635 b = (YY_BUFFER_STATE) ppalloc(sizeof( struct yy_buffer_state ) ,yyscanner );
1636 if ( ! b )
1637 YY_FATAL_ERROR( "out of dynamic memory in pp_create_buffer()" );
1638
1639 b->yy_buf_size = size;
1640
1641 /* yy_ch_buf has to be 2 characters longer than the size given because
1642 * we need to put in 2 end-of-buffer characters.
1643 */
1644 b->yy_ch_buf = (char *) ppalloc(b->yy_buf_size + 2 ,yyscanner );
1645 if ( ! b->yy_ch_buf )
1646 YY_FATAL_ERROR( "out of dynamic memory in pp_create_buffer()" );
1647
1648 b->yy_is_our_buffer = 1;
1649
1650 pp_init_buffer(b,file ,yyscanner);
1651
1652 return b;
1653}
1654
1655/** Destroy the buffer.
1656 * @param b a buffer created with pp_create_buffer()
1657 * @param yyscanner The scanner object.
1658 */
1659 void pp_delete_buffer (YY_BUFFER_STATE b , yyscan_t yyscanner)
1660{
1661 struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
1662
1663 if ( ! b )
1664 return;
1665
1666 if ( b == YY_CURRENT_BUFFER ) /* Not sure if we should pop here. */
1667 YY_CURRENT_BUFFER_LVALUE = (YY_BUFFER_STATE) 0;
1668
1669 if ( b->yy_is_our_buffer )
1670 ppfree((void *) b->yy_ch_buf ,yyscanner );
1671
1672 ppfree((void *) b ,yyscanner );
1673}
1674
1675/* Initializes or reinitializes a buffer.
1676 * This function is sometimes called more than once on the same buffer,
1677 * such as during a pprestart() or at EOF.
1678 */
1679 static void pp_init_buffer (YY_BUFFER_STATE b, FILE * file , yyscan_t yyscanner)
1680
1681{
1682 int oerrno = errno;
1683 struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
1684
1685 pp_flush_buffer(b ,yyscanner);
1686
1687 b->yy_input_file = file;
1688 b->yy_fill_buffer = 1;
1689
1690 /* If b is the current buffer, then pp_init_buffer was _probably_
1691 * called from pprestart() or through yy_get_next_buffer.
1692 * In that case, we don't want to reset the lineno or column.
1693 */
1694 if (b != YY_CURRENT_BUFFER){
1695 b->yy_bs_lineno = 1;
1696 b->yy_bs_column = 0;
1697 }
1698
1699 b->yy_is_interactive = 0;
1700
1701 errno = oerrno;
1702}
1703
1704/** Discard all buffered characters. On the next scan, YY_INPUT will be called.
1705 * @param b the buffer state to be flushed, usually @c YY_CURRENT_BUFFER.
1706 * @param yyscanner The scanner object.
1707 */
1708 void pp_flush_buffer (YY_BUFFER_STATE b , yyscan_t yyscanner)
1709{
1710 struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
1711 if ( ! b )
1712 return;
1713
1714 b->yy_n_chars = 0;
1715
1716 /* We always need two end-of-buffer characters. The first causes
1717 * a transition to the end-of-buffer state. The second causes
1718 * a jam in that state.
1719 */
1720 b->yy_ch_buf[0] = YY_END_OF_BUFFER_CHAR;
1721 b->yy_ch_buf[1] = YY_END_OF_BUFFER_CHAR;
1722
1723 b->yy_buf_pos = &b->yy_ch_buf[0];
1724
1725 b->yy_at_bol = 1;
1726 b->yy_buffer_status = YY_BUFFER_NEW;
1727
1728 if ( b == YY_CURRENT_BUFFER )
1729 pp_load_buffer_state(yyscanner );
1730}
1731
1732/** Pushes the new state onto the stack. The new state becomes
1733 * the current state. This function will allocate the stack
1734 * if necessary.
1735 * @param new_buffer The new state.
1736 * @param yyscanner The scanner object.
1737 */
1738void pppush_buffer_state (YY_BUFFER_STATE new_buffer , yyscan_t yyscanner)
1739{
1740 struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
1741 if (new_buffer == NULL)
1742 return;
1743
1744 ppensure_buffer_stack(yyscanner);
1745
1746 /* This block is copied from pp_switch_to_buffer. */
1747 if ( YY_CURRENT_BUFFER )
1748 {
1749 /* Flush out information for old buffer. */
1750 *yyg->yy_c_buf_p = yyg->yy_hold_char;
1751 YY_CURRENT_BUFFER_LVALUE->yy_buf_pos = yyg->yy_c_buf_p;
1752 YY_CURRENT_BUFFER_LVALUE->yy_n_chars = yyg->yy_n_chars;
1753 }
1754
1755 /* Only push if top exists. Otherwise, replace top. */
1756 if (YY_CURRENT_BUFFER)
1757 yyg->yy_buffer_stack_top++;
1758 YY_CURRENT_BUFFER_LVALUE = new_buffer;
1759
1760 /* copied from pp_switch_to_buffer. */
1761 pp_load_buffer_state(yyscanner );
1762 yyg->yy_did_buffer_switch_on_eof = 1;
1763}
1764
1765/** Removes and deletes the top of the stack, if present.
1766 * The next element becomes the new top.
1767 * @param yyscanner The scanner object.
1768 */
1769void pppop_buffer_state (yyscan_t yyscanner)
1770{
1771 struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
1772 if (!YY_CURRENT_BUFFER)
1773 return;
1774
1775 pp_delete_buffer(YY_CURRENT_BUFFER ,yyscanner);
1776 YY_CURRENT_BUFFER_LVALUE = NULL;
1777 if (yyg->yy_buffer_stack_top > 0)
1778 --yyg->yy_buffer_stack_top;
1779
1780 if (YY_CURRENT_BUFFER) {
1781 pp_load_buffer_state(yyscanner );
1782 yyg->yy_did_buffer_switch_on_eof = 1;
1783 }
1784}
1785
1786/* Allocates the stack if it does not exist.
1787 * Guarantees space for at least one push.
1788 */
1789static void ppensure_buffer_stack (yyscan_t yyscanner)
1790{
shannonwoods@chromium.org4b8a3112013-05-30 00:13:01 +00001791 int num_to_alloc;
alokp@chromium.org04d7d222012-05-16 19:24:07 +00001792 struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
1793
1794 if (!yyg->yy_buffer_stack) {
1795
1796 /* First allocation is just for 2 elements, since we don't know if this
1797 * scanner will even need a stack. We use 2 instead of 1 to avoid an
1798 * immediate realloc on the next call.
1799 */
1800 num_to_alloc = 1;
1801 yyg->yy_buffer_stack = (struct yy_buffer_state**)ppalloc
1802 (num_to_alloc * sizeof(struct yy_buffer_state*)
1803 , yyscanner);
1804 if ( ! yyg->yy_buffer_stack )
1805 YY_FATAL_ERROR( "out of dynamic memory in ppensure_buffer_stack()" );
1806
1807 memset(yyg->yy_buffer_stack, 0, num_to_alloc * sizeof(struct yy_buffer_state*));
1808
1809 yyg->yy_buffer_stack_max = num_to_alloc;
1810 yyg->yy_buffer_stack_top = 0;
1811 return;
1812 }
1813
1814 if (yyg->yy_buffer_stack_top >= (yyg->yy_buffer_stack_max) - 1){
1815
1816 /* Increase the buffer to prepare for a possible push. */
1817 int grow_size = 8 /* arbitrary grow size */;
1818
1819 num_to_alloc = yyg->yy_buffer_stack_max + grow_size;
1820 yyg->yy_buffer_stack = (struct yy_buffer_state**)pprealloc
1821 (yyg->yy_buffer_stack,
1822 num_to_alloc * sizeof(struct yy_buffer_state*)
1823 , yyscanner);
1824 if ( ! yyg->yy_buffer_stack )
1825 YY_FATAL_ERROR( "out of dynamic memory in ppensure_buffer_stack()" );
1826
1827 /* zero only the new slots.*/
1828 memset(yyg->yy_buffer_stack + yyg->yy_buffer_stack_max, 0, grow_size * sizeof(struct yy_buffer_state*));
1829 yyg->yy_buffer_stack_max = num_to_alloc;
1830 }
1831}
1832
1833/** Setup the input buffer state to scan directly from a user-specified character buffer.
1834 * @param base the character buffer
1835 * @param size the size in bytes of the character buffer
1836 * @param yyscanner The scanner object.
1837 * @return the newly allocated buffer state object.
1838 */
1839YY_BUFFER_STATE pp_scan_buffer (char * base, yy_size_t size , yyscan_t yyscanner)
1840{
1841 YY_BUFFER_STATE b;
1842
1843 if ( size < 2 ||
1844 base[size-2] != YY_END_OF_BUFFER_CHAR ||
1845 base[size-1] != YY_END_OF_BUFFER_CHAR )
1846 /* They forgot to leave room for the EOB's. */
1847 return 0;
1848
1849 b = (YY_BUFFER_STATE) ppalloc(sizeof( struct yy_buffer_state ) ,yyscanner );
1850 if ( ! b )
1851 YY_FATAL_ERROR( "out of dynamic memory in pp_scan_buffer()" );
1852
1853 b->yy_buf_size = size - 2; /* "- 2" to take care of EOB's */
1854 b->yy_buf_pos = b->yy_ch_buf = base;
1855 b->yy_is_our_buffer = 0;
1856 b->yy_input_file = 0;
1857 b->yy_n_chars = b->yy_buf_size;
1858 b->yy_is_interactive = 0;
1859 b->yy_at_bol = 1;
1860 b->yy_fill_buffer = 0;
1861 b->yy_buffer_status = YY_BUFFER_NEW;
1862
1863 pp_switch_to_buffer(b ,yyscanner );
1864
1865 return b;
1866}
1867
1868/** Setup the input buffer state to scan a string. The next call to pplex() will
1869 * scan from a @e copy of @a str.
1870 * @param yystr a NUL-terminated string to scan
1871 * @param yyscanner The scanner object.
1872 * @return the newly allocated buffer state object.
1873 * @note If you want to scan bytes that may contain NUL values, then use
1874 * pp_scan_bytes() instead.
1875 */
1876YY_BUFFER_STATE pp_scan_string (yyconst char * yystr , yyscan_t yyscanner)
1877{
1878
1879 return pp_scan_bytes(yystr,strlen(yystr) ,yyscanner);
1880}
1881
1882/** Setup the input buffer state to scan the given bytes. The next call to pplex() will
1883 * scan from a @e copy of @a bytes.
1884 * @param bytes the byte buffer to scan
1885 * @param len the number of bytes in the buffer pointed to by @a bytes.
1886 * @param yyscanner The scanner object.
1887 * @return the newly allocated buffer state object.
1888 */
shannonwoods@chromium.org4b8a3112013-05-30 00:13:01 +00001889YY_BUFFER_STATE pp_scan_bytes (yyconst char * yybytes, int _yybytes_len , yyscan_t yyscanner)
alokp@chromium.org04d7d222012-05-16 19:24:07 +00001890{
1891 YY_BUFFER_STATE b;
1892 char *buf;
shannonwoods@chromium.org4b8a3112013-05-30 00:13:01 +00001893 yy_size_t n;
1894 int 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 */
shannonwoods@chromium.org4b8a3112013-05-30 00:13:01 +00002004int 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