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