Debian Codegraph @

CodeLite/include_finder.cpp

raw
1 //////////////////////////////////////////////////////////////////////////////
2 //////////////////////////////////////////////////////////////////////////////
3 //
4 // copyright : (C) 2014 Eran Ifrah
5 // file name : include_finder.cpp
6 //
7 // -------------------------------------------------------------------------
8 // A
9 // _____ _ _ _ _
10 // / __ \ | | | | (_) |
11 // | / \/ ___ __| | ___| | _| |_ ___
12 // | | / _ \ / _ |/ _ \ | | | __/ _ )
13 // | \__/\ (_) | (_| | __/ |___| | || __/
14 // \____/\___/ \__,_|\___\_____/_|\__\___|
15 //
16 // F i l e
17 //
18 // This program is free software; you can redistribute it and/or modify
19 // it under the terms of the GNU General Public License as published by
20 // the Free Software Foundation; either version 2 of the License, or
21 // (at your option) any later version.
22 //
23 //////////////////////////////////////////////////////////////////////////////
24 //////////////////////////////////////////////////////////////////////////////
25
26 #define yy_create_buffer inclf__create_buffer
27 #define yy_delete_buffer inclf__delete_buffer
28 #define yy_scan_buffer inclf__scan_buffer
29 #define yy_scan_string inclf__scan_string
30 #define yy_scan_bytes inclf__scan_bytes
31 #define yy_flex_debug inclf__flex_debug
32 #define yy_init_buffer inclf__init_buffer
33 #define yy_flush_buffer inclf__flush_buffer
34 #define yy_load_buffer_state inclf__load_buffer_state
35 #define yy_switch_to_buffer inclf__switch_to_buffer
36 #define yyin inclf_in
37 #define yyleng inclf_leng
38 #define yylex inclf_lex
39 #define yyout inclf_out
40 #define yyrestart inclf_restart
41 #define yytext inclf_text
42 #define yylineno inclf_lineno
43 #define yywrap inclf_wrap
44
45 /* A lexical scanner generated by flex */
46
47 /* Scanner skeleton version:
48 * $Header: /home/daffy/u0/vern/flex/RCS/flex.skl,v 2.91 96/09/10 16:58:48 vern Exp $
49 */
50
51 #define FLEX_SCANNER
52 #define YY_FLEX_MAJOR_VERSION 2
53 #define YY_FLEX_MINOR_VERSION 5
54
55 #include <stdio.h>
56
57
58 /* cfront 1.2 defines "c_plusplus" instead of "__cplusplus" */
59 #ifdef c_plusplus
60 #ifndef __cplusplus
61 #define __cplusplus
62 #endif
63 #endif
64
65
66 #ifdef __cplusplus
67
68 #include <stdlib.h>
69 #include <unistd.h>
70
71 /* Use prototypes in function declarations. */
72 #define YY_USE_PROTOS
73
74 /* The "const" storage-class-modifier is valid. */
75 #define YY_USE_CONST
76
77 #else /* ! __cplusplus */
78
79 #if __STDC__
80
81 #define YY_USE_PROTOS
82 #define YY_USE_CONST
83
84 #endif /* __STDC__ */
85 #endif /* ! __cplusplus */
86
87 #ifdef __TURBOC__
88 #pragma warn -rch
89 #pragma warn -use
90 #include <io.h>
91 #include <stdlib.h>
92 #define YY_USE_CONST
93 #define YY_USE_PROTOS
94 #endif
95
96 #ifdef YY_USE_CONST
97 #define yyconst const
98 #else
99 #define yyconst
100 #endif
101
102
103 #ifdef YY_USE_PROTOS
104 #define YY_PROTO(proto) proto
105 #else
106 #define YY_PROTO(proto) ()
107 #endif
108
109 /* Returned upon end-of-file. */
110 #define YY_NULL 0
111
112 /* Promotes a possibly negative, possibly signed char to an unsigned
113 * integer for use as an array index. If the signed char is negative,
114 * we want to instead treat it as an 8-bit unsigned char, hence the
115 * double cast.
116 */
117 #define YY_SC_TO_UI(c) ((unsigned int) (unsigned char) c)
118
119 /* Enter a start condition. This macro really ought to take a parameter,
120 * but we do it the disgusting crufty way forced on us by the ()-less
121 * definition of BEGIN.
122 */
123 #define BEGIN yy_start = 1 + 2 *
124
125 /* Translate the current start state into a value that can be later handed
126 * to BEGIN to return to the state. The YYSTATE alias is for lex
127 * compatibility.
128 */
129 #define YY_START ((yy_start - 1) / 2)
130 #define YYSTATE YY_START
131
132 /* Action number for EOF rule of a given start state. */
133 #define YY_STATE_EOF(state) (YY_END_OF_BUFFER + state + 1)
134
135 /* Special action meaning "start processing a new file". */
136 #define YY_NEW_FILE yyrestart( yyin )
137
138 #define YY_END_OF_BUFFER_CHAR 0
139
140 /* Size of default input buffer. */
141 #define YY_BUF_SIZE 16384
142
143 typedef struct yy_buffer_state *YY_BUFFER_STATE;
144
145 extern int yyleng;
146 extern FILE *yyin, *yyout;
147
148 #define EOB_ACT_CONTINUE_SCAN 0
149 #define EOB_ACT_END_OF_FILE 1
150 #define EOB_ACT_LAST_MATCH 2
151
152 /* The funky do-while in the following #define is used to turn the definition
153 * int a single C statement (which needs a semi-colon terminator). This
154 * avoids problems with code like:
155 *
156 * if ( condition_holds )
157 * yyless( 5 );
158 * else
159 * do_something_else();
160 *
161 * Prior to using the do-while the compiler would get upset at the
162 * "else" because it interpreted the "if" statement as being all
163 * done when it reached the ';' after the yyless() call.
164 */
165
166 /* Return all but the first 'n' matched characters back to the input stream. */
167
168 #define yyless(n) \
169 do \
170 { \
171 /* Undo effects of setting up yytext. */ \
172 *yy_cp = yy_hold_char; \
173 YY_RESTORE_YY_MORE_OFFSET \
174 yy_c_buf_p = yy_cp = yy_bp + n - YY_MORE_ADJ; \
175 YY_DO_BEFORE_ACTION; /* set up yytext again */ \
176 } \
177 while ( 0 )
178
179 #define unput(c) yyunput( c, yytext_ptr )
180
181 /* The following is because we cannot portably get our hands on size_t
182 * (without autoconf's help, which isn't available because we want
183 * flex-generated scanners to compile on their own).
184 */
185 typedef unsigned int yy_size_t;
186
187
188 struct yy_buffer_state
189 {
190 FILE *yy_input_file;
191
192 char *yy_ch_buf; /* input buffer */
193 char *yy_buf_pos; /* current position in input buffer */
194
195 /* Size of input buffer in bytes, not including room for EOB
196 * characters.
197 */
198 yy_size_t yy_buf_size;
199
200 /* Number of characters read into yy_ch_buf, not including EOB
201 * characters.
202 */
203 int yy_n_chars;
204
205 /* Whether we "own" the buffer - i.e., we know we created it,
206 * and can realloc() it to grow it, and should free() it to
207 * delete it.
208 */
209 int yy_is_our_buffer;
210
211 /* Whether this is an "interactive" input source; if so, and
212 * if we're using stdio for input, then we want to use getc()
213 * instead of fread(), to make sure we stop fetching input after
214 * each newline.
215 */
216 int yy_is_interactive;
217
218 /* Whether we're considered to be at the beginning of a line.
219 * If so, '^' rules will be active on the next match, otherwise
220 * not.
221 */
222 int yy_at_bol;
223
224 /* Whether to try to fill the input buffer when we reach the
225 * end of it.
226 */
227 int yy_fill_buffer;
228
229 int yy_buffer_status;
230 #define YY_BUFFER_NEW 0
231 #define YY_BUFFER_NORMAL 1
232 /* When an EOF's been seen but there's still some text to process
233 * then we mark the buffer as YY_EOF_PENDING, to indicate that we
234 * shouldn't try reading from the input source any more. We might
235 * still have a bunch of tokens to match, though, because of
236 * possible backing-up.
237 *
238 * When we actually see the EOF, we change the status to "new"
239 * (via yyrestart()), so that the user can continue scanning by
240 * just pointing yyin at a new input file.
241 */
242 #define YY_BUFFER_EOF_PENDING 2
243 };
244
245 static YY_BUFFER_STATE yy_current_buffer = 0;
246
247 /* We provide macros for accessing buffer states in case in the
248 * future we want to put the buffer states in a more general
249 * "scanner state".
250 */
251 #define YY_CURRENT_BUFFER yy_current_buffer
252
253
254 /* yy_hold_char holds the character lost when yytext is formed. */
255 static char yy_hold_char;
256
257 static int yy_n_chars; /* number of characters read into yy_ch_buf */
258
259
260 int yyleng;
261
262 /* Points to current character in buffer. */
263 static char *yy_c_buf_p = (char *) 0;
264 static int yy_init = 1; /* whether we need to initialize */
265 static int yy_start = 0; /* start state number */
266
267 /* Flag which is used to allow yywrap()'s to do buffer switches
268 * instead of setting up a fresh yyin. A bit of a hack ...
269 */
270 static int yy_did_buffer_switch_on_eof;
271
272 void yyrestart YY_PROTO(( FILE *input_file ));
273
274 void yy_switch_to_buffer YY_PROTO(( YY_BUFFER_STATE new_buffer ));
275 void yy_load_buffer_state YY_PROTO(( void ));
276 YY_BUFFER_STATE yy_create_buffer YY_PROTO(( FILE *file, int size ));
277 void yy_delete_buffer YY_PROTO(( YY_BUFFER_STATE b ));
278 void yy_init_buffer YY_PROTO(( YY_BUFFER_STATE b, FILE *file ));
279 void yy_flush_buffer YY_PROTO(( YY_BUFFER_STATE b ));
280 #define YY_FLUSH_BUFFER yy_flush_buffer( yy_current_buffer )
281
282 YY_BUFFER_STATE yy_scan_buffer YY_PROTO(( char *base, yy_size_t size ));
283 YY_BUFFER_STATE yy_scan_string YY_PROTO(( yyconst char *yy_str ));
284 YY_BUFFER_STATE yy_scan_bytes YY_PROTO(( yyconst char *bytes, int len ));
285
286 static void *yy_flex_alloc YY_PROTO(( yy_size_t ));
287 static void *yy_flex_realloc YY_PROTO(( void *, yy_size_t ));
288 static void yy_flex_free YY_PROTO(( void * ));
289
290 #define yy_new_buffer yy_create_buffer
291
292 #define yy_set_interactive(is_interactive) \
293 { \
294 if ( ! yy_current_buffer ) \
295 yy_current_buffer = yy_create_buffer( yyin, YY_BUF_SIZE ); \
296 yy_current_buffer->yy_is_interactive = is_interactive; \
297 }
298
299 #define yy_set_bol(at_bol) \
300 { \
301 if ( ! yy_current_buffer ) \
302 yy_current_buffer = yy_create_buffer( yyin, YY_BUF_SIZE ); \
303 yy_current_buffer->yy_at_bol = at_bol; \
304 }
305
306 #define YY_AT_BOL() (yy_current_buffer->yy_at_bol)
307
308
309 #define YY_USES_REJECT
310 typedef unsigned char YY_CHAR;
311 FILE *yyin = (FILE *) 0, *yyout = (FILE *) 0;
312 typedef int yy_state_type;
313 extern int yylineno;
314 int yylineno = 1;
315 extern char *yytext;
316 #define yytext_ptr yytext
317
318 static yy_state_type yy_get_previous_state YY_PROTO(( void ));
319 static yy_state_type yy_try_NUL_trans YY_PROTO(( yy_state_type current_state ));
320 static int yy_get_next_buffer YY_PROTO(( void ));
321 static void yy_fatal_error YY_PROTO(( yyconst char msg[] ));
322
323 /* Done after the current pattern has been matched and before the
324 * corresponding action - sets up yytext.
325 */
326 #define YY_DO_BEFORE_ACTION \
327 yytext_ptr = yy_bp; \
328 yyleng = (int) (yy_cp - yy_bp); \
329 yy_hold_char = *yy_cp; \
330 *yy_cp = '\0'; \
331 yy_c_buf_p = yy_cp;
332
333 #define YY_NUM_RULES 14
334 #define YY_END_OF_BUFFER 15
335 static yyconst short int yy_acclist[38] =
336 { 0,
337 8, 8, 15, 6, 14, 14, 6, 14, 6, 14,
338 6, 14, 6, 14, 6, 14, 8, 14, 7, 14,
339 14, 13, 14, 13, 14, 11, 14, 10, 14, 4,
340 2, 1, 8, 12, 3, 9, 5
341 } ;
342
343 static yyconst short int yy_accept[60] =
344 { 0,
345 1, 1, 1, 2, 3, 3, 3, 3, 3, 4,
346 6, 7, 9, 11, 13, 15, 17, 19, 21, 22,
347 24, 26, 28, 30, 30, 31, 31, 31, 31, 31,
348 31, 32, 33, 33, 33, 34, 34, 35, 35, 35,
349 35, 36, 36, 36, 37, 37, 37, 37, 37, 37,
350 37, 37, 37, 37, 37, 37, 37, 38, 38
351 } ;
352
353 static yyconst int yy_ec[256] =
354 { 0,
355 1, 1, 1, 1, 1, 1, 1, 1, 2, 3,
356 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
357 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
358 1, 2, 1, 4, 5, 1, 1, 1, 6, 1,
359 1, 7, 1, 1, 1, 1, 8, 9, 9, 9,
360 9, 9, 9, 9, 9, 10, 10, 1, 1, 11,
361 1, 12, 13, 1, 10, 10, 10, 10, 10, 10,
362 1, 1, 1, 1, 1, 14, 1, 1, 1, 1,
363 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
364 1, 15, 1, 1, 1, 1, 16, 16, 17, 18,
365
366 19, 16, 1, 1, 20, 1, 1, 21, 1, 22,
367 1, 1, 1, 13, 1, 13, 23, 13, 1, 24,
368 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
369 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
370 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
371 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
372 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
373 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
374 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
375 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
376
377 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
378 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
379 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
380 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
381 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
382 1, 1, 1, 1, 1
383 } ;
384
385 static yyconst int yy_meta[25] =
386 { 0,
387 1, 2, 3, 4, 1, 5, 1, 1, 6, 7,
388 1, 1, 4, 1, 4, 6, 7, 7, 7, 1,
389 1, 4, 1, 4
390 } ;
391
392 static yyconst short int yy_base[70] =
393 { 0,
394 0, 12, 25, 35, 4, 6, 88, 85, 87, 159,
395 159, 6, 10, 65, 15, 27, 77, 159, 0, 159,
396 70, 159, 159, 20, 159, 10, 23, 55, 26, 31,
397 159, 159, 38, 59, 70, 40, 159, 41, 0, 54,
398 159, 42, 0, 50, 54, 66, 45, 58, 80, 45,
399 0, 42, 53, 0, 43, 28, 159, 159, 99, 106,
400 113, 120, 127, 134, 141, 145, 148, 149, 151
401 } ;
402
403 static yyconst short int yy_def[70] =
404 { 0,
405 59, 59, 60, 60, 61, 61, 62, 62, 58, 58,
406 58, 63, 58, 64, 58, 58, 58, 58, 65, 58,
407 58, 58, 58, 63, 58, 66, 58, 58, 64, 67,
408 58, 58, 63, 64, 58, 65, 58, 63, 68, 58,
409 58, 64, 69, 65, 63, 63, 58, 64, 64, 63,
410 46, 58, 64, 49, 58, 58, 58, 0, 58, 58,
411 58, 58, 58, 58, 58, 58, 58, 58, 58
412 } ;
413
414 static yyconst short int yy_nxt[184] =
415 { 0,
416 58, 58, 11, 12, 13, 14, 11, 15, 11, 25,
417 21, 27, 21, 16, 11, 12, 13, 14, 38, 15,
418 26, 31, 32, 25, 27, 16, 17, 18, 19, 28,
419 33, 41, 34, 39, 26, 19, 17, 18, 19, 42,
420 30, 25, 28, 44, 25, 19, 57, 41, 25, 45,
421 48, 44, 26, 44, 43, 26, 30, 25, 41, 26,
422 56, 44, 50, 41, 55, 52, 53, 30, 26, 25,
423 47, 35, 30, 30, 51, 51, 40, 37, 35, 30,
424 26, 51, 51, 51, 51, 41, 58, 23, 54, 54,
425 23, 58, 58, 58, 30, 54, 54, 54, 54, 10,
426
427 10, 10, 10, 10, 10, 10, 11, 11, 11, 11,
428 11, 11, 11, 20, 20, 20, 20, 20, 20, 20,
429 22, 22, 22, 22, 22, 22, 22, 24, 24, 58,
430 24, 24, 24, 24, 29, 29, 58, 29, 58, 29,
431 29, 36, 58, 58, 36, 36, 36, 36, 24, 24,
432 24, 29, 29, 29, 46, 46, 49, 49, 9, 58,
433 58, 58, 58, 58, 58, 58, 58, 58, 58, 58,
434 58, 58, 58, 58, 58, 58, 58, 58, 58, 58,
435 58, 58, 58
436 } ;
437
438 static yyconst short int yy_chk[184] =
439 { 0,
440 0, 0, 1, 1, 1, 1, 5, 1, 6, 12,
441 5, 13, 6, 1, 2, 2, 2, 2, 26, 2,
442 12, 15, 15, 24, 27, 2, 3, 3, 3, 13,
443 16, 29, 16, 26, 24, 3, 4, 4, 4, 30,
444 29, 33, 27, 36, 38, 4, 56, 42, 50, 38,
445 42, 36, 33, 44, 30, 38, 42, 45, 53, 50,
446 55, 44, 45, 48, 52, 47, 48, 53, 45, 46,
447 40, 35, 48, 34, 46, 46, 28, 21, 17, 14,
448 46, 46, 46, 46, 46, 49, 9, 8, 49, 49,
449 7, 0, 0, 0, 49, 49, 49, 49, 49, 59,
450
451 59, 59, 59, 59, 59, 59, 60, 60, 60, 60,
452 60, 60, 60, 61, 61, 61, 61, 61, 61, 61,
453 62, 62, 62, 62, 62, 62, 62, 63, 63, 0,
454 63, 63, 63, 63, 64, 64, 0, 64, 0, 64,
455 64, 65, 0, 0, 65, 65, 65, 65, 66, 66,
456 66, 67, 67, 67, 68, 68, 69, 69, 58, 58,
457 58, 58, 58, 58, 58, 58, 58, 58, 58, 58,
458 58, 58, 58, 58, 58, 58, 58, 58, 58, 58,
459 58, 58, 58
460 } ;
461
462 static yy_state_type yy_state_buf[YY_BUF_SIZE + 2], *yy_state_ptr;
463 static char *yy_full_match;
464 static int yy_lp;
465 #define REJECT \
466 { \
467 *yy_cp = yy_hold_char; /* undo effects of setting up yytext */ \
468 yy_cp = yy_full_match; /* restore poss. backed-over text */ \
469 ++yy_lp; \
470 goto find_rule; \
471 }
472 #define yymore() yymore_used_but_not_detected
473 #define YY_MORE_ADJ 0
474 #define YY_RESTORE_YY_MORE_OFFSET
475 char *yytext;
476 #define INITIAL 0
477 /**
478 * the "incl" state is used for picking up the name
479 * of an include file
480 */
481 #define incl 1
482
483 #define c_comment 2
484
485 #define cpp_comment 3
486
487 // Avoid spam output
488 #ifdef ECHO
489 #undef ECHO
490 #endif
491 #define ECHO
492
493 // Never exit
494 #ifdef YY_FATAL_ERROR
495 #undef YY_FATAL_ERROR
496 #endif
497 #define YY_FATAL_ERROR(msg)
498
499 #include <list>
500 #include "include_finder.h"
501
502 static std::vector<IncludeStatement>* pIncludes = NULL;
503 static std::string currentFile;
504
505
506 /* Macros after this point can all be overridden by user definitions in
507 * section 1.
508 */
509
510 #ifndef YY_SKIP_YYWRAP
511 #ifdef __cplusplus
512 extern "C" int yywrap YY_PROTO(( void ));
513 #else
514 extern int yywrap YY_PROTO(( void ));
515 #endif
516 #endif
517
518 #ifndef YY_NO_UNPUT
519 static void yyunput YY_PROTO(( int c, char *buf_ptr ));
520 #endif
521
522 #ifndef yytext_ptr
523 static void yy_flex_strncpy YY_PROTO(( char *, yyconst char *, int ));
524 #endif
525
526 #ifdef YY_NEED_STRLEN
527 static int yy_flex_strlen YY_PROTO(( yyconst char * ));
528 #endif
529
530 #ifndef YY_NO_INPUT
531 #ifdef __cplusplus
532 static int yyinput YY_PROTO(( void ));
533 #else
534 static int input YY_PROTO(( void ));
535 #endif
536 #endif
537
538 #if YY_STACK_USED
539 static int yy_start_stack_ptr = 0;
540 static int yy_start_stack_depth = 0;
541 static int *yy_start_stack = 0;
542 #ifndef YY_NO_PUSH_STATE
543 static void yy_push_state YY_PROTO(( int new_state ));
544 #endif
545 #ifndef YY_NO_POP_STATE
546 static void yy_pop_state YY_PROTO(( void ));
547 #endif
548 #ifndef YY_NO_TOP_STATE
549 static int yy_top_state YY_PROTO(( void ));
550 #endif
551
552 #else
553 #define YY_NO_PUSH_STATE 1
554 #define YY_NO_POP_STATE 1
555 #define YY_NO_TOP_STATE 1
556 #endif
557
558 #ifdef YY_MALLOC_DECL
559 YY_MALLOC_DECL
560 #else
561 #if __STDC__
562 #ifndef __cplusplus
563 #include <stdlib.h>
564 #endif
565 #else
566 /* Just try to get by without declaring the routines. This will fail
567 * miserably on non-ANSI systems for which sizeof(size_t) != sizeof(int)
568 * or sizeof(void*) != sizeof(int).
569 */
570 #endif
571 #endif
572
573 /* Amount of stuff to slurp up with each read. */
574 #ifndef YY_READ_BUF_SIZE
575 #define YY_READ_BUF_SIZE 8192
576 #endif
577
578 /* Copy whatever the last rule matched to the standard output. */
579
580 #ifndef ECHO
581 /* This used to be an fputs(), but since the string might contain NUL's,
582 * we now use fwrite().
583 */
584 #define ECHO (void) fwrite( yytext, yyleng, 1, yyout )
585 #endif
586
587 /* Gets input and stuffs it into "buf". number of characters read, or YY_NULL,
588 * is returned in "result".
589 */
590 #ifndef YY_INPUT
591 #define YY_INPUT(buf,result,max_size) \
592 if ( yy_current_buffer->yy_is_interactive ) \
593 { \
594 int c = '*', n; \
595 for ( n = 0; n < max_size && \
596 (c = getc( yyin )) != EOF && c != '\n'; ++n ) \
597 buf[n] = (char) c; \
598 if ( c == '\n' ) \
599 buf[n++] = (char) c; \
600 if ( c == EOF && ferror( yyin ) ) \
601 YY_FATAL_ERROR( "input in flex scanner failed" ); \
602 result = n; \
603 } \
604 else if ( ((result = fread( buf, 1, max_size, yyin )) == 0) \
605 && ferror( yyin ) ) \
606 YY_FATAL_ERROR( "input in flex scanner failed" );
607 #endif
608
609 /* No semi-colon after return; correct usage is to write "yyterminate();" -
610 * we don't want an extra ';' after the "return" because that will cause
611 * some compilers to complain about unreachable statements.
612 */
613 #ifndef yyterminate
614 #define yyterminate() return YY_NULL
615 #endif
616
617 /* Number of entries by which start-condition stack grows. */
618 #ifndef YY_START_STACK_INCR
619 #define YY_START_STACK_INCR 25
620 #endif
621
622 /* Report a fatal error. */
623 #ifndef YY_FATAL_ERROR
624 #define YY_FATAL_ERROR(msg) yy_fatal_error( msg )
625 #endif
626
627 /* Default declaration of generated scanner - a define so the user can
628 * easily add parameters.
629 */
630 #ifndef YY_DECL
631 #define YY_DECL int yylex YY_PROTO(( void ))
632 #endif
633
634 /* Code executed at the beginning of each rule, after yytext and yyleng
635 * have been set up.
636 */
637 #ifndef YY_USER_ACTION
638 #define YY_USER_ACTION
639 #endif
640
641 /* Code executed at the end of each rule. */
642 #ifndef YY_BREAK
643 #define YY_BREAK break;
644 #endif
645
646 #define YY_RULE_SETUP \
647 YY_USER_ACTION
648
649 YY_DECL
650 {
651 register yy_state_type yy_current_state;
652 register char *yy_cp, *yy_bp;
653 register int yy_act;
654
655
656
657
658 if ( yy_init )
659 {
660 yy_init = 0;
661
662 #ifdef YY_USER_INIT
663 YY_USER_INIT;
664 #endif
665
666 if ( ! yy_start )
667 yy_start = 1; /* first start state */
668
669 if ( ! yyin )
670 yyin = stdin;
671
672 if ( ! yyout )
673 yyout = stdout;
674
675 if ( ! yy_current_buffer )
676 yy_current_buffer =
677 yy_create_buffer( yyin, YY_BUF_SIZE );
678
679 yy_load_buffer_state();
680 }
681
682 while ( 1 ) /* loops until end-of-file is reached */
683 {
684 yy_cp = yy_c_buf_p;
685
686 /* Support of yytext. */
687 *yy_cp = yy_hold_char;
688
689 /* yy_bp points to the position in yy_ch_buf of the start of
690 * the current run.
691 */
692 yy_bp = yy_cp;
693
694 yy_current_state = yy_start;
695 yy_state_ptr = yy_state_buf;
696 *yy_state_ptr++ = yy_current_state;
697 yy_match:
698 do
699 {
700 register YY_CHAR yy_c = yy_ec[YY_SC_TO_UI(*yy_cp)];
701 while ( yy_chk[yy_base[yy_current_state] + yy_c] != yy_current_state )
702 {
703 yy_current_state = (int) yy_def[yy_current_state];
704 if ( yy_current_state >= 59 )
705 yy_c = yy_meta[(unsigned int) yy_c];
706 }
707 yy_current_state = yy_nxt[yy_base[yy_current_state] + (unsigned int) yy_c];
708 *yy_state_ptr++ = yy_current_state;
709 ++yy_cp;
710 }
711 while ( yy_base[yy_current_state] != 159 );
712
713 yy_find_action:
714 yy_current_state = *--yy_state_ptr;
715 yy_lp = yy_accept[yy_current_state];
716 find_rule: /* we branch to this label when backing up */
717 for ( ; ; ) /* until we find what rule we matched */
718 {
719 if ( yy_lp && yy_lp < yy_accept[yy_current_state + 1] )
720 {
721 yy_act = yy_acclist[yy_lp];
722 {
723 yy_full_match = yy_cp;
724 break;
725 }
726 }
727 --yy_cp;
728 yy_current_state = *--yy_state_ptr;
729 yy_lp = yy_accept[yy_current_state];
730 }
731
732 YY_DO_BEFORE_ACTION;
733
734 if ( yy_act != YY_END_OF_BUFFER )
735 {
736 int yyl;
737 for ( yyl = 0; yyl < yyleng; ++yyl )
738 if ( yytext[yyl] == '\n' )
739 ++yylineno;
740 }
741
742 do_action: /* This label is used only to access EOF actions. */
743
744
745 switch ( yy_act )
746 { /* beginning of action switch */
747 case 1:
748 YY_RULE_SETUP
749 {
750 BEGIN(cpp_comment);
751 }
752 YY_BREAK
753 case 2:
754 YY_RULE_SETUP
755 {
756 BEGIN(c_comment);
757 }
758 YY_BREAK
759 case 3:
760 YY_RULE_SETUP
761 {/* eat a string */}
762 YY_BREAK
763 case 4:
764 YY_RULE_SETUP
765 {/* eat a string */}
766 YY_BREAK
767 case 5:
768 YY_RULE_SETUP
769 {BEGIN(incl);}
770 YY_BREAK
771 case 6:
772 YY_RULE_SETUP
773 {}
774 YY_BREAK
775 case 7:
776 YY_RULE_SETUP
777 {BEGIN(INITIAL);}
778 YY_BREAK
779 case 8:
780 YY_RULE_SETUP
781 {} /* eat the whitespace */
782 YY_BREAK
783 case 9:
784 YY_RULE_SETUP
785 { /* got the include file name */
786
787 std::string mod_path ( inclf_text );
788 static std::string trimString("\"<> \t");
789
790 mod_path.erase(0, mod_path.find_first_not_of(trimString));
791 mod_path.erase(mod_path.find_last_not_of (trimString)+1);
792
793 IncludeStatement includeStatement;
794 includeStatement.line = inclf_lineno;
795 includeStatement.file = mod_path;
796 includeStatement.includedFrom = currentFile;
797 includeStatement.pattern = inclf_text;
798 pIncludes->push_back( includeStatement );
799 }
800 YY_BREAK
801 case 10:
802 YY_RULE_SETUP
803 {
804 BEGIN(INITIAL);
805 }
806 YY_BREAK
807 case 11:
808 YY_RULE_SETUP
809 {} /* do nothing */
810 YY_BREAK
811 case 12:
812 YY_RULE_SETUP
813 {
814 BEGIN(INITIAL);
815 }
816 YY_BREAK
817 case 13:
818 YY_RULE_SETUP
819 {}
820 YY_BREAK
821 case YY_STATE_EOF(INITIAL):
822 case YY_STATE_EOF(incl):
823 case YY_STATE_EOF(c_comment):
824 case YY_STATE_EOF(cpp_comment):
825 {
826 if ( YY_CURRENT_BUFFER->yy_input_file ) {
827 fclose( YY_CURRENT_BUFFER->yy_input_file );
828 YY_CURRENT_BUFFER->yy_input_file = NULL;
829 }
830
831 yy_delete_buffer ( YY_CURRENT_BUFFER );
832 yyterminate();
833 }
834 YY_BREAK
835 case 14:
836 YY_RULE_SETUP
837 ECHO;
838 YY_BREAK
839
840 case YY_END_OF_BUFFER:
841 {
842 /* Amount of text matched not including the EOB char. */
843 int yy_amount_of_matched_text = (int) (yy_cp - yytext_ptr) - 1;
844
845 /* Undo the effects of YY_DO_BEFORE_ACTION. */
846 *yy_cp = yy_hold_char;
847 YY_RESTORE_YY_MORE_OFFSET
848
849 if ( yy_current_buffer->yy_buffer_status == YY_BUFFER_NEW )
850 {
851 /* We're scanning a new file or input source. It's
852 * possible that this happened because the user
853 * just pointed yyin at a new source and called
854 * yylex(). If so, then we have to assure
855 * consistency between yy_current_buffer and our
856 * globals. Here is the right place to do so, because
857 * this is the first action (other than possibly a
858 * back-up) that will match for the new input source.
859 */
860 yy_n_chars = yy_current_buffer->yy_n_chars;
861 yy_current_buffer->yy_input_file = yyin;
862 yy_current_buffer->yy_buffer_status = YY_BUFFER_NORMAL;
863 }
864
865 /* Note that here we test for yy_c_buf_p "<=" to the position
866 * of the first EOB in the buffer, since yy_c_buf_p will
867 * already have been incremented past the NUL character
868 * (since all states make transitions on EOB to the
869 * end-of-buffer state). Contrast this with the test
870 * in input().
871 */
872 if ( yy_c_buf_p <= &yy_current_buffer->yy_ch_buf[yy_n_chars] )
873 { /* This was really a NUL. */
874 yy_state_type yy_next_state;
875
876 yy_c_buf_p = yytext_ptr + yy_amount_of_matched_text;
877
878 yy_current_state = yy_get_previous_state();
879
880 /* Okay, we're now positioned to make the NUL
881 * transition. We couldn't have
882 * yy_get_previous_state() go ahead and do it
883 * for us because it doesn't know how to deal
884 * with the possibility of jamming (and we don't
885 * want to build jamming into it because then it
886 * will run more slowly).
887 */
888
889 yy_next_state = yy_try_NUL_trans( yy_current_state );
890
891 yy_bp = yytext_ptr + YY_MORE_ADJ;
892
893 if ( yy_next_state )
894 {
895 /* Consume the NUL. */
896 yy_cp = ++yy_c_buf_p;
897 yy_current_state = yy_next_state;
898 goto yy_match;
899 }
900
901 else
902 {
903 yy_cp = yy_c_buf_p;
904 goto yy_find_action;
905 }
906 }
907
908 else switch ( yy_get_next_buffer() )
909 {
910 case EOB_ACT_END_OF_FILE:
911 {
912 yy_did_buffer_switch_on_eof = 0;
913
914 if ( yywrap() )
915 {
916 /* Note: because we've taken care in
917 * yy_get_next_buffer() to have set up
918 * yytext, we can now set up
919 * yy_c_buf_p so that if some total
920 * hoser (like flex itself) wants to
921 * call the scanner after we return the
922 * YY_NULL, it'll still work - another
923 * YY_NULL will get returned.
924 */
925 yy_c_buf_p = yytext_ptr + YY_MORE_ADJ;
926
927 yy_act = YY_STATE_EOF(YY_START);
928 goto do_action;
929 }
930
931 else
932 {
933 if ( ! yy_did_buffer_switch_on_eof )
934 YY_NEW_FILE;
935 }
936 break;
937 }
938
939 case EOB_ACT_CONTINUE_SCAN:
940 yy_c_buf_p =
941 yytext_ptr + yy_amount_of_matched_text;
942
943 yy_current_state = yy_get_previous_state();
944
945 yy_cp = yy_c_buf_p;
946 yy_bp = yytext_ptr + YY_MORE_ADJ;
947 goto yy_match;
948
949 case EOB_ACT_LAST_MATCH:
950 yy_c_buf_p =
951 &yy_current_buffer->yy_ch_buf[yy_n_chars];
952
953 yy_current_state = yy_get_previous_state();
954
955 yy_cp = yy_c_buf_p;
956 yy_bp = yytext_ptr + YY_MORE_ADJ;
957 goto yy_find_action;
958 }
959 break;
960 }
961
962 default:
963 YY_FATAL_ERROR(
964 "fatal flex scanner internal error--no action found" );
965 } /* end of action switch */
966 } /* end of scanning one token */
967 } /* end of yylex */
968
969
970 /* yy_get_next_buffer - try to read in a new buffer
971 *
972 * Returns a code representing an action:
973 * EOB_ACT_LAST_MATCH -
974 * EOB_ACT_CONTINUE_SCAN - continue scanning from current position
975 * EOB_ACT_END_OF_FILE - end of file
976 */
977
978 static int yy_get_next_buffer()
979 {
980 register char *dest = yy_current_buffer->yy_ch_buf;
981 register char *source = yytext_ptr;
982 register int number_to_move, i;
983 int ret_val;
984
985 if ( yy_c_buf_p > &yy_current_buffer->yy_ch_buf[yy_n_chars + 1] )
986 YY_FATAL_ERROR(
987 "fatal flex scanner internal error--end of buffer missed" );
988
989 if ( yy_current_buffer->yy_fill_buffer == 0 )
990 { /* Don't try to fill the buffer, so this is an EOF. */
991 if ( yy_c_buf_p - yytext_ptr - YY_MORE_ADJ == 1 )
992 {
993 /* We matched a single character, the EOB, so
994 * treat this as a final EOF.
995 */
996 return EOB_ACT_END_OF_FILE;
997 }
998
999 else
1000 {
1001 /* We matched some text prior to the EOB, first
1002 * process it.
1003 */
1004 return EOB_ACT_LAST_MATCH;
1005 }
1006 }
1007
1008 /* Try to read more data. */
1009
1010 /* First move last chars to start of buffer. */
1011 number_to_move = (int) (yy_c_buf_p - yytext_ptr) - 1;
1012
1013 for ( i = 0; i < number_to_move; ++i )
1014 *(dest++) = *(source++);
1015
1016 if ( yy_current_buffer->yy_buffer_status == YY_BUFFER_EOF_PENDING )
1017 /* don't do the read, it's not guaranteed to return an EOF,
1018 * just force an EOF
1019 */
1020 yy_current_buffer->yy_n_chars = yy_n_chars = 0;
1021
1022 else
1023 {
1024 int num_to_read =
1025 yy_current_buffer->yy_buf_size - number_to_move - 1;
1026
1027 while ( num_to_read <= 0 )
1028 { /* Not enough room in the buffer - grow it. */
1029 #ifdef YY_USES_REJECT
1030 YY_FATAL_ERROR(
1031 "input buffer overflow, can't enlarge buffer because scanner uses REJECT" );
1032 #else
1033
1034 /* just a shorter name for the current buffer */
1035 YY_BUFFER_STATE b = yy_current_buffer;
1036
1037 int yy_c_buf_p_offset =
1038 (int) (yy_c_buf_p - b->yy_ch_buf);
1039
1040 if ( b->yy_is_our_buffer )
1041 {
1042 int new_size = b->yy_buf_size * 2;
1043
1044 if ( new_size <= 0 )
1045 b->yy_buf_size += b->yy_buf_size / 8;
1046 else
1047 b->yy_buf_size *= 2;
1048
1049 b->yy_ch_buf = (char *)
1050 /* Include room in for 2 EOB chars. */
1051 yy_flex_realloc( (void *) b->yy_ch_buf,
1052 b->yy_buf_size + 2 );
1053 }
1054 else
1055 /* Can't grow it, we don't own it. */
1056 b->yy_ch_buf = 0;
1057
1058 if ( ! b->yy_ch_buf )
1059 YY_FATAL_ERROR(
1060 "fatal error - scanner input buffer overflow" );
1061
1062 yy_c_buf_p = &b->yy_ch_buf[yy_c_buf_p_offset];
1063
1064 num_to_read = yy_current_buffer->yy_buf_size -
1065 number_to_move - 1;
1066 #endif
1067 }
1068
1069 if ( num_to_read > YY_READ_BUF_SIZE )
1070 num_to_read = YY_READ_BUF_SIZE;
1071
1072 /* Read in more data. */
1073 YY_INPUT( (&yy_current_buffer->yy_ch_buf[number_to_move]),
1074 yy_n_chars, num_to_read );
1075
1076 yy_current_buffer->yy_n_chars = yy_n_chars;
1077 }
1078
1079 if ( yy_n_chars == 0 )
1080 {
1081 if ( number_to_move == YY_MORE_ADJ )
1082 {
1083 ret_val = EOB_ACT_END_OF_FILE;
1084 yyrestart( yyin );
1085 }
1086
1087 else
1088 {
1089 ret_val = EOB_ACT_LAST_MATCH;
1090 yy_current_buffer->yy_buffer_status =
1091 YY_BUFFER_EOF_PENDING;
1092 }
1093 }
1094
1095 else
1096 ret_val = EOB_ACT_CONTINUE_SCAN;
1097
1098 yy_n_chars += number_to_move;
1099 yy_current_buffer->yy_ch_buf[yy_n_chars] = YY_END_OF_BUFFER_CHAR;
1100 yy_current_buffer->yy_ch_buf[yy_n_chars + 1] = YY_END_OF_BUFFER_CHAR;
1101
1102 yytext_ptr = &yy_current_buffer->yy_ch_buf[0];
1103
1104 return ret_val;
1105 }
1106
1107
1108 /* yy_get_previous_state - get the state just before the EOB char was reached */
1109
1110 static yy_state_type yy_get_previous_state()
1111 {
1112 register yy_state_type yy_current_state;
1113 register char *yy_cp;
1114
1115 yy_current_state = yy_start;
1116 yy_state_ptr = yy_state_buf;
1117 *yy_state_ptr++ = yy_current_state;
1118
1119 for ( yy_cp = yytext_ptr + YY_MORE_ADJ; yy_cp < yy_c_buf_p; ++yy_cp )
1120 {
1121 register YY_CHAR yy_c = (*yy_cp ? yy_ec[YY_SC_TO_UI(*yy_cp)] : 1);
1122 while ( yy_chk[yy_base[yy_current_state] + yy_c] != yy_current_state )
1123 {
1124 yy_current_state = (int) yy_def[yy_current_state];
1125 if ( yy_current_state >= 59 )
1126 yy_c = yy_meta[(unsigned int) yy_c];
1127 }
1128 yy_current_state = yy_nxt[yy_base[yy_current_state] + (unsigned int) yy_c];
1129 *yy_state_ptr++ = yy_current_state;
1130 }
1131
1132 return yy_current_state;
1133 }
1134
1135
1136 /* yy_try_NUL_trans - try to make a transition on the NUL character
1137 *
1138 * synopsis
1139 * next_state = yy_try_NUL_trans( current_state );
1140 */
1141
1142 #ifdef YY_USE_PROTOS
1143 static yy_state_type yy_try_NUL_trans( yy_state_type yy_current_state )
1144 #else
1145 static yy_state_type yy_try_NUL_trans( yy_current_state )
1146 yy_state_type yy_current_state;
1147 #endif
1148 {
1149 register int yy_is_jam;
1150
1151 register YY_CHAR yy_c = 1;
1152 while ( yy_chk[yy_base[yy_current_state] + yy_c] != yy_current_state )
1153 {
1154 yy_current_state = (int) yy_def[yy_current_state];
1155 if ( yy_current_state >= 59 )
1156 yy_c = yy_meta[(unsigned int) yy_c];
1157 }
1158 yy_current_state = yy_nxt[yy_base[yy_current_state] + (unsigned int) yy_c];
1159 yy_is_jam = (yy_current_state == 58);
1160 if ( ! yy_is_jam )
1161 *yy_state_ptr++ = yy_current_state;
1162
1163 return yy_is_jam ? 0 : yy_current_state;
1164 }
1165
1166
1167 #ifndef YY_NO_UNPUT
1168 #ifdef YY_USE_PROTOS
1169 static void yyunput( int c, register char *yy_bp )
1170 #else
1171 static void yyunput( c, yy_bp )
1172 int c;
1173 register char *yy_bp;
1174 #endif
1175 {
1176 register char *yy_cp = yy_c_buf_p;
1177
1178 /* undo effects of setting up yytext */
1179 *yy_cp = yy_hold_char;
1180
1181 if ( yy_cp < yy_current_buffer->yy_ch_buf + 2 )
1182 { /* need to shift things up to make room */
1183 /* +2 for EOB chars. */
1184 register int number_to_move = yy_n_chars + 2;
1185 register char *dest = &yy_current_buffer->yy_ch_buf[
1186 yy_current_buffer->yy_buf_size + 2];
1187 register char *source =
1188 &yy_current_buffer->yy_ch_buf[number_to_move];
1189
1190 while ( source > yy_current_buffer->yy_ch_buf )
1191 *--dest = *--source;
1192
1193 yy_cp += (int) (dest - source);
1194 yy_bp += (int) (dest - source);
1195 yy_current_buffer->yy_n_chars =
1196 yy_n_chars = yy_current_buffer->yy_buf_size;
1197
1198 if ( yy_cp < yy_current_buffer->yy_ch_buf + 2 )
1199 YY_FATAL_ERROR( "flex scanner push-back overflow" );
1200 }
1201
1202 *--yy_cp = (char) c;
1203
1204 if ( c == '\n' )
1205 --yylineno;
1206
1207 yytext_ptr = yy_bp;
1208 yy_hold_char = *yy_cp;
1209 yy_c_buf_p = yy_cp;
1210 }
1211 #endif /* ifndef YY_NO_UNPUT */
1212
1213
1214 #ifdef __cplusplus
1215 static int yyinput()
1216 #else
1217 static int input()
1218 #endif
1219 {
1220 int c;
1221
1222 *yy_c_buf_p = yy_hold_char;
1223
1224 if ( *yy_c_buf_p == YY_END_OF_BUFFER_CHAR )
1225 {
1226 /* yy_c_buf_p now points to the character we want to return.
1227 * If this occurs *before* the EOB characters, then it's a
1228 * valid NUL; if not, then we've hit the end of the buffer.
1229 */
1230 if ( yy_c_buf_p < &yy_current_buffer->yy_ch_buf[yy_n_chars] )
1231 /* This was really a NUL. */
1232 *yy_c_buf_p = '\0';
1233
1234 else
1235 { /* need more input */
1236 int offset = yy_c_buf_p - yytext_ptr;
1237 ++yy_c_buf_p;
1238
1239 switch ( yy_get_next_buffer() )
1240 {
1241 case EOB_ACT_LAST_MATCH:
1242 /* This happens because yy_g_n_b()
1243 * sees that we've accumulated a
1244 * token and flags that we need to
1245 * try matching the token before
1246 * proceeding. But for input(),
1247 * there's no matching to consider.
1248 * So convert the EOB_ACT_LAST_MATCH
1249 * to EOB_ACT_END_OF_FILE.
1250 */
1251
1252 /* Reset buffer status. */
1253 yyrestart( yyin );
1254
1255 /* fall through */
1256
1257 case EOB_ACT_END_OF_FILE:
1258 {
1259 if ( yywrap() )
1260 return EOF;
1261
1262 if ( ! yy_did_buffer_switch_on_eof )
1263 YY_NEW_FILE;
1264 #ifdef __cplusplus
1265 return yyinput();
1266 #else
1267 return input();
1268 #endif
1269 }
1270
1271 case EOB_ACT_CONTINUE_SCAN:
1272 yy_c_buf_p = yytext_ptr + offset;
1273 break;
1274 }
1275 }
1276 }
1277
1278 c = *(unsigned char *) yy_c_buf_p; /* cast for 8-bit char's */
1279 *yy_c_buf_p = '\0'; /* preserve yytext */
1280 yy_hold_char = *++yy_c_buf_p;
1281
1282 if ( c == '\n' )
1283 ++yylineno;
1284
1285 return c;
1286 }
1287
1288
1289 #ifdef YY_USE_PROTOS
1290 void yyrestart( FILE *input_file )
1291 #else
1292 void yyrestart( input_file )
1293 FILE *input_file;
1294 #endif
1295 {
1296 if ( ! yy_current_buffer )
1297 yy_current_buffer = yy_create_buffer( yyin, YY_BUF_SIZE );
1298
1299 yy_init_buffer( yy_current_buffer, input_file );
1300 yy_load_buffer_state();
1301 }
1302
1303
1304 #ifdef YY_USE_PROTOS
1305 void yy_switch_to_buffer( YY_BUFFER_STATE new_buffer )
1306 #else
1307 void yy_switch_to_buffer( new_buffer )
1308 YY_BUFFER_STATE new_buffer;
1309 #endif
1310 {
1311 if ( yy_current_buffer == new_buffer )
1312 return;
1313
1314 if ( yy_current_buffer )
1315 {
1316 /* Flush out information for old buffer. */
1317 *yy_c_buf_p = yy_hold_char;
1318 yy_current_buffer->yy_buf_pos = yy_c_buf_p;
1319 yy_current_buffer->yy_n_chars = yy_n_chars;
1320 }
1321
1322 yy_current_buffer = new_buffer;
1323 yy_load_buffer_state();
1324
1325 /* We don't actually know whether we did this switch during
1326 * EOF (yywrap()) processing, but the only time this flag
1327 * is looked at is after yywrap() is called, so it's safe
1328 * to go ahead and always set it.
1329 */
1330 yy_did_buffer_switch_on_eof = 1;
1331 }
1332
1333
1334 #ifdef YY_USE_PROTOS
1335 void yy_load_buffer_state( void )
1336 #else
1337 void yy_load_buffer_state()
1338 #endif
1339 {
1340 yy_n_chars = yy_current_buffer->yy_n_chars;
1341 yytext_ptr = yy_c_buf_p = yy_current_buffer->yy_buf_pos;
1342 yyin = yy_current_buffer->yy_input_file;
1343 yy_hold_char = *yy_c_buf_p;
1344 }
1345
1346
1347 #ifdef YY_USE_PROTOS
1348 YY_BUFFER_STATE yy_create_buffer( FILE *file, int size )
1349 #else
1350 YY_BUFFER_STATE yy_create_buffer( file, size )
1351 FILE *file;
1352 int size;
1353 #endif
1354 {
1355 YY_BUFFER_STATE b;
1356
1357 b = (YY_BUFFER_STATE) yy_flex_alloc( sizeof( struct yy_buffer_state ) );
1358 if ( ! b )
1359 YY_FATAL_ERROR( "out of dynamic memory in yy_create_buffer()" );
1360
1361 b->yy_buf_size = size;
1362
1363 /* yy_ch_buf has to be 2 characters longer than the size given because
1364 * we need to put in 2 end-of-buffer characters.
1365 */
1366 b->yy_ch_buf = (char *) yy_flex_alloc( b->yy_buf_size + 2 );
1367 if ( ! b->yy_ch_buf )
1368 YY_FATAL_ERROR( "out of dynamic memory in yy_create_buffer()" );
1369
1370 b->yy_is_our_buffer = 1;
1371
1372 yy_init_buffer( b, file );
1373
1374 return b;
1375 }
1376
1377
1378 #ifdef YY_USE_PROTOS
1379 void yy_delete_buffer( YY_BUFFER_STATE b )
1380 #else
1381 void yy_delete_buffer( b )
1382 YY_BUFFER_STATE b;
1383 #endif
1384 {
1385 if ( ! b )
1386 return;
1387
1388 if ( b == yy_current_buffer )
1389 yy_current_buffer = (YY_BUFFER_STATE) 0;
1390
1391 if ( b->yy_is_our_buffer )
1392 yy_flex_free( (void *) b->yy_ch_buf );
1393
1394 yy_flex_free( (void *) b );
1395 }
1396
1397
1398 #ifndef YY_ALWAYS_INTERACTIVE
1399 #ifndef YY_NEVER_INTERACTIVE
1400 extern int isatty YY_PROTO(( int ));
1401 #endif
1402 #endif
1403
1404 #ifdef YY_USE_PROTOS
1405 void yy_init_buffer( YY_BUFFER_STATE b, FILE *file )
1406 #else
1407 void yy_init_buffer( b, file )
1408 YY_BUFFER_STATE b;
1409 FILE *file;
1410 #endif
1411
1412
1413 {
1414 yy_flush_buffer( b );
1415
1416 b->yy_input_file = file;
1417 b->yy_fill_buffer = 1;
1418
1419 #if YY_ALWAYS_INTERACTIVE
1420 b->yy_is_interactive = 1;
1421 #else
1422 #if YY_NEVER_INTERACTIVE
1423 b->yy_is_interactive = 0;
1424 #else
1425 b->yy_is_interactive = file ? (isatty( fileno(file) ) > 0) : 0;
1426 #endif
1427 #endif
1428 }
1429
1430
1431 #ifdef YY_USE_PROTOS
1432 void yy_flush_buffer( YY_BUFFER_STATE b )
1433 #else
1434 void yy_flush_buffer( b )
1435 YY_BUFFER_STATE b;
1436 #endif
1437
1438 {
1439 if ( ! b )
1440 return;
1441
1442 b->yy_n_chars = 0;
1443
1444 /* We always need two end-of-buffer characters. The first causes
1445 * a transition to the end-of-buffer state. The second causes
1446 * a jam in that state.
1447 */
1448 b->yy_ch_buf[0] = YY_END_OF_BUFFER_CHAR;
1449 b->yy_ch_buf[1] = YY_END_OF_BUFFER_CHAR;
1450
1451 b->yy_buf_pos = &b->yy_ch_buf[0];
1452
1453 b->yy_at_bol = 1;
1454 b->yy_buffer_status = YY_BUFFER_NEW;
1455
1456 if ( b == yy_current_buffer )
1457 yy_load_buffer_state();
1458 }
1459
1460
1461 #ifndef YY_NO_SCAN_BUFFER
1462 #ifdef YY_USE_PROTOS
1463 YY_BUFFER_STATE yy_scan_buffer( char *base, yy_size_t size )
1464 #else
1465 YY_BUFFER_STATE yy_scan_buffer( base, size )
1466 char *base;
1467 yy_size_t size;
1468 #endif
1469 {
1470 YY_BUFFER_STATE b;
1471
1472 if ( size < 2 ||
1473 base[size-2] != YY_END_OF_BUFFER_CHAR ||
1474 base[size-1] != YY_END_OF_BUFFER_CHAR )
1475 /* They forgot to leave room for the EOB's. */
1476 return 0;
1477
1478 b = (YY_BUFFER_STATE) yy_flex_alloc( sizeof( struct yy_buffer_state ) );
1479 if ( ! b )
1480 YY_FATAL_ERROR( "out of dynamic memory in yy_scan_buffer()" );
1481
1482 b->yy_buf_size = size - 2; /* "- 2" to take care of EOB's */
1483 b->yy_buf_pos = b->yy_ch_buf = base;
1484 b->yy_is_our_buffer = 0;
1485 b->yy_input_file = 0;
1486 b->yy_n_chars = b->yy_buf_size;
1487 b->yy_is_interactive = 0;
1488 b->yy_at_bol = 1;
1489 b->yy_fill_buffer = 0;
1490 b->yy_buffer_status = YY_BUFFER_NEW;
1491
1492 yy_switch_to_buffer( b );
1493
1494 return b;
1495 }
1496 #endif
1497
1498
1499 #ifndef YY_NO_SCAN_STRING
1500 #ifdef YY_USE_PROTOS
1501 YY_BUFFER_STATE yy_scan_string( yyconst char *yy_str )
1502 #else
1503 YY_BUFFER_STATE yy_scan_string( yy_str )
1504 yyconst char *yy_str;
1505 #endif
1506 {
1507 int len;
1508 for ( len = 0; yy_str[len]; ++len )
1509 ;
1510
1511 return yy_scan_bytes( yy_str, len );
1512 }
1513 #endif
1514
1515
1516 #ifndef YY_NO_SCAN_BYTES
1517 #ifdef YY_USE_PROTOS
1518 YY_BUFFER_STATE yy_scan_bytes( yyconst char *bytes, int len )
1519 #else
1520 YY_BUFFER_STATE yy_scan_bytes( bytes, len )
1521 yyconst char *bytes;
1522 int len;
1523 #endif
1524 {
1525 YY_BUFFER_STATE b;
1526 char *buf;
1527 yy_size_t n;
1528 int i;
1529
1530 /* Get memory for full buffer, including space for trailing EOB's. */
1531 n = len + 2;
1532 buf = (char *) yy_flex_alloc( n );
1533 if ( ! buf )
1534 YY_FATAL_ERROR( "out of dynamic memory in yy_scan_bytes()" );
1535
1536 for ( i = 0; i < len; ++i )
1537 buf[i] = bytes[i];
1538
1539 buf[len] = buf[len+1] = YY_END_OF_BUFFER_CHAR;
1540
1541 b = yy_scan_buffer( buf, n );
1542 if ( ! b )
1543 YY_FATAL_ERROR( "bad buffer in yy_scan_bytes()" );
1544
1545 /* It's okay to grow etc. this buffer, and we should throw it
1546 * away when we're done.
1547 */
1548 b->yy_is_our_buffer = 1;
1549
1550 return b;
1551 }
1552 #endif
1553
1554
1555 #ifndef YY_NO_PUSH_STATE
1556 #ifdef YY_USE_PROTOS
1557 static void yy_push_state( int new_state )
1558 #else
1559 static void yy_push_state( new_state )
1560 int new_state;
1561 #endif
1562 {
1563 if ( yy_start_stack_ptr >= yy_start_stack_depth )
1564 {
1565 yy_size_t new_size;
1566
1567 yy_start_stack_depth += YY_START_STACK_INCR;
1568 new_size = yy_start_stack_depth * sizeof( int );
1569
1570 if ( ! yy_start_stack )
1571 yy_start_stack = (int *) yy_flex_alloc( new_size );
1572
1573 else
1574 yy_start_stack = (int *) yy_flex_realloc(
1575 (void *) yy_start_stack, new_size );
1576
1577 if ( ! yy_start_stack )
1578 YY_FATAL_ERROR(
1579 "out of memory expanding start-condition stack" );
1580 }
1581
1582 yy_start_stack[yy_start_stack_ptr++] = YY_START;
1583
1584 BEGIN(new_state);
1585 }
1586 #endif
1587
1588
1589 #ifndef YY_NO_POP_STATE
1590 static void yy_pop_state()
1591 {
1592 if ( --yy_start_stack_ptr < 0 )
1593 YY_FATAL_ERROR( "start-condition stack underflow" );
1594
1595 BEGIN(yy_start_stack[yy_start_stack_ptr]);
1596 }
1597 #endif
1598
1599
1600 #ifndef YY_NO_TOP_STATE
1601 static int yy_top_state()
1602 {
1603 return yy_start_stack[yy_start_stack_ptr - 1];
1604 }
1605 #endif
1606
1607 #ifndef YY_EXIT_FAILURE
1608 #define YY_EXIT_FAILURE 2
1609 #endif
1610
1611 #ifdef YY_USE_PROTOS
1612 static void yy_fatal_error( yyconst char msg[] )
1613 #else
1614 static void yy_fatal_error( msg )
1615 char msg[];
1616 #endif
1617 {
1618 (void) fprintf( stderr, "%s\n", msg );
1619
1620 }
1621
1622
1623
1624 /* Redefine yyless() so it works in section 3 code. */
1625
1626 #undef yyless
1627 #define yyless(n) \
1628 do \
1629 { \
1630 /* Undo effects of setting up yytext. */ \
1631 yytext[yyleng] = yy_hold_char; \
1632 yy_c_buf_p = yytext + n; \
1633 yy_hold_char = *yy_c_buf_p; \
1634 *yy_c_buf_p = '\0'; \
1635 yyleng = n; \
1636 } \
1637 while ( 0 )
1638
1639
1640 /* Internal utility routines. */
1641
1642 #ifndef yytext_ptr
1643 #ifdef YY_USE_PROTOS
1644 static void yy_flex_strncpy( char *s1, yyconst char *s2, int n )
1645 #else
1646 static void yy_flex_strncpy( s1, s2, n )
1647 char *s1;
1648 yyconst char *s2;
1649 int n;
1650 #endif
1651 {
1652 register int i;
1653 for ( i = 0; i < n; ++i )
1654 s1[i] = s2[i];
1655 }
1656 #endif
1657
1658 #ifdef YY_NEED_STRLEN
1659 #ifdef YY_USE_PROTOS
1660 static int yy_flex_strlen( yyconst char *s )
1661 #else
1662 static int yy_flex_strlen( s )
1663 yyconst char *s;
1664 #endif
1665 {
1666 register int n;
1667 for ( n = 0; s[n]; ++n )
1668 ;
1669
1670 return n;
1671 }
1672 #endif
1673
1674
1675 #ifdef YY_USE_PROTOS
1676 static void *yy_flex_alloc( yy_size_t size )
1677 #else
1678 static void *yy_flex_alloc( size )
1679 yy_size_t size;
1680 #endif
1681 {
1682 return (void *) malloc( size );
1683 }
1684
1685 #ifdef YY_USE_PROTOS
1686 static void *yy_flex_realloc( void *ptr, yy_size_t size )
1687 #else
1688 static void *yy_flex_realloc( ptr, size )
1689 void *ptr;
1690 yy_size_t size;
1691 #endif
1692 {
1693 /* The cast to (char *) in the following accommodates both
1694 * implementations that use char* generic pointers, and those
1695 * that use void* generic pointers. It works with the latter
1696 * because both ANSI C and C++ allow castless assignment from
1697 * any pointer type to void*, and deal with argument conversions
1698 * as though doing an assignment.
1699 */
1700 return (void *) realloc( (char *) ptr, size );
1701 }
1702
1703 #ifdef YY_USE_PROTOS
1704 static void yy_flex_free( void *ptr )
1705 #else
1706 static void yy_flex_free( ptr )
1707 void *ptr;
1708 #endif
1709 {
1710 free( ptr );
1711 }
1712
1713 #if YY_MAIN
1714 int main()
1715 {
1716 yylex();
1717 return 0;
1718 }
1719 #endif
1720
1721
1722 int yywrap() {
1723 return 1;
1724 }
1725
1726 int IncludeFinder( const char* filePath, std::vector<IncludeStatement> &includes )
1727 {
1728 BEGIN INITIAL;
1729 inclf_lineno = 1;
1730
1731 FILE* fp = fopen(filePath, "r");
1732 if ( fp == NULL ) {
1733 return -1;
1734 }
1735
1736 currentFile = filePath;
1737 pIncludes = &includes;
1738 yy_switch_to_buffer( yy_create_buffer(fp, YY_BUF_SIZE) );
1739 inclf_in = fp;
1740 int rc = inclf_lex();
1741 yy_delete_buffer ( YY_CURRENT_BUFFER );
1742
1743 // Cleanup
1744 pIncludes = NULL;
1745 currentFile.clear();
1746 return rc;
1747 }
1748