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