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