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