Debian Codegraph @

CodeLite/comment_parser.cpp

raw
1 //////////////////////////////////////////////////////////////////////////////
2 //////////////////////////////////////////////////////////////////////////////
3 //
4 // copyright : (C) 2014 Eran Ifrah
5 // file name : comment_parser.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 cp__create_buffer
27 #define yy_delete_buffer cp__delete_buffer
28 #define yy_scan_buffer cp__scan_buffer
29 #define yy_scan_string cp__scan_string
30 #define yy_scan_bytes cp__scan_bytes
31 #define yy_flex_debug cp__flex_debug
32 #define yy_init_buffer cp__init_buffer
33 #define yy_flush_buffer cp__flush_buffer
34 #define yy_load_buffer_state cp__load_buffer_state
35 #define yy_switch_to_buffer cp__switch_to_buffer
36 #define yyin cp_in
37 #define yyleng cp_leng
38 #define yylex cp_lex
39 #define yyout cp_out
40 #define yyrestart cp_restart
41 #define yytext cp_text
42 #define yylineno cp_lineno
43 #define yywrap cp_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 16
334 #define YY_END_OF_BUFFER 17
335 static yyconst short int yy_acclist[37] =
336 { 0,
337 17, 6, 16, 4, 6, 16, 5, 16, 6, 16,
338 16, 15, 16, 12, 15, 16, 14, 16, 11, 15,
339 16, 10, 15, 16, 13, 15, 16, 8, 16, 7,
340 16, 2, 1, 9, 3, 1
341 } ;
342
343 static yyconst short int yy_accept[30] =
344 { 0,
345 1, 1, 1, 1, 1, 1, 1, 1, 1, 2,
346 4, 7, 9, 11, 12, 14, 17, 19, 22, 25,
347 28, 30, 32, 33, 34, 35, 36, 37, 37
348 } ;
349
350 static yyconst int yy_ec[256] =
351 { 0,
352 1, 1, 1, 1, 1, 1, 1, 1, 2, 3,
353 4, 1, 5, 1, 1, 1, 1, 1, 1, 1,
354 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
355 1, 2, 6, 1, 1, 1, 1, 1, 1, 1,
356 1, 7, 1, 1, 1, 1, 8, 1, 1, 1,
357 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
358 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
359 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
360 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
361 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
362
363 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
364 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
365 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
366 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
367 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
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
374 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
375 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
376 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
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
380 } ;
381
382 static yyconst int yy_meta[9] =
383 { 0,
384 1, 1, 1, 1, 1, 1, 1, 1
385 } ;
386
387 static yyconst short int yy_base[31] =
388 { 0,
389 0, 0, 0, 0, 8, 0, 24, 23, 25, 28,
390 28, 28, 10, 28, 28, 28, 28, 28, 28, 16,
391 28, 28, 17, 14, 28, 28, 13, 28, 19, 18
392 } ;
393
394 static yyconst short int yy_def[31] =
395 { 0,
396 28, 1, 29, 29, 28, 5, 30, 30, 28, 28,
397 28, 28, 28, 28, 28, 28, 28, 28, 28, 28,
398 28, 28, 28, 28, 28, 28, 28, 0, 28, 28
399 } ;
400
401 static yyconst short int yy_nxt[37] =
402 { 0,
403 10, 11, 12, 11, 10, 10, 10, 13, 15, 16,
404 17, 18, 19, 15, 20, 15, 23, 24, 21, 14,
405 27, 27, 26, 25, 28, 22, 22, 9, 28, 28,
406 28, 28, 28, 28, 28, 28
407 } ;
408
409 static yyconst short int yy_chk[37] =
410 { 0,
411 1, 1, 1, 1, 1, 1, 1, 1, 5, 5,
412 5, 5, 5, 5, 5, 5, 13, 13, 30, 29,
413 27, 24, 23, 20, 9, 8, 7, 28, 28, 28,
414 28, 28, 28, 28, 28, 28
415 } ;
416
417 static yy_state_type yy_state_buf[YY_BUF_SIZE + 2], *yy_state_ptr;
418 static char *yy_full_match;
419 static int yy_lp;
420 #define REJECT \
421 { \
422 *yy_cp = yy_hold_char; /* undo effects of setting up yytext */ \
423 yy_cp = yy_full_match; /* restore poss. backed-over text */ \
424 ++yy_lp; \
425 goto find_rule; \
426 }
427 #define yymore() yymore_used_but_not_detected
428 #define YY_MORE_ADJ 0
429 #define YY_RESTORE_YY_MORE_OFFSET
430 char *yytext;
431 #define INITIAL 0
432 /**
433 * the "incl" state is used for picking up the name
434 * of an include file
435 */
436 #define incl 1
437
438 #define c_comment 2
439
440 #define cpp_comment 3
441
442 // Avoid spam output
443 #ifdef ECHO
444 #undef ECHO
445 #endif
446 #define ECHO
447
448 // Never exit
449 #ifdef YY_FATAL_ERROR
450 #undef YY_FATAL_ERROR
451 #endif
452 #define YY_FATAL_ERROR(msg)
453
454 #include <list>
455 #include "comment_parser.h"
456
457 static CommentParseResult *pResults = NULL;
458 static std::string strComment;
459 static std::string strCppComment;
460 static int iCppCommentLine = -1;
461
462 /* Macros after this point can all be overridden by user definitions in
463 * section 1.
464 */
465
466 #ifndef YY_SKIP_YYWRAP
467 #ifdef __cplusplus
468 extern "C" int yywrap YY_PROTO(( void ));
469 #else
470 extern int yywrap YY_PROTO(( void ));
471 #endif
472 #endif
473
474 #ifndef YY_NO_UNPUT
475 static void yyunput YY_PROTO(( int c, char *buf_ptr ));
476 #endif
477
478 #ifndef yytext_ptr
479 static void yy_flex_strncpy YY_PROTO(( char *, yyconst char *, int ));
480 #endif
481
482 #ifdef YY_NEED_STRLEN
483 static int yy_flex_strlen YY_PROTO(( yyconst char * ));
484 #endif
485
486 #ifndef YY_NO_INPUT
487 #ifdef __cplusplus
488 static int yyinput YY_PROTO(( void ));
489 #else
490 static int input YY_PROTO(( void ));
491 #endif
492 #endif
493
494 #if YY_STACK_USED
495 static int yy_start_stack_ptr = 0;
496 static int yy_start_stack_depth = 0;
497 static int *yy_start_stack = 0;
498 #ifndef YY_NO_PUSH_STATE
499 static void yy_push_state YY_PROTO(( int new_state ));
500 #endif
501 #ifndef YY_NO_POP_STATE
502 static void yy_pop_state YY_PROTO(( void ));
503 #endif
504 #ifndef YY_NO_TOP_STATE
505 static int yy_top_state YY_PROTO(( void ));
506 #endif
507
508 #else
509 #define YY_NO_PUSH_STATE 1
510 #define YY_NO_POP_STATE 1
511 #define YY_NO_TOP_STATE 1
512 #endif
513
514 #ifdef YY_MALLOC_DECL
515 YY_MALLOC_DECL
516 #else
517 #if __STDC__
518 #ifndef __cplusplus
519 #include <stdlib.h>
520 #endif
521 #else
522 /* Just try to get by without declaring the routines. This will fail
523 * miserably on non-ANSI systems for which sizeof(size_t) != sizeof(int)
524 * or sizeof(void*) != sizeof(int).
525 */
526 #endif
527 #endif
528
529 /* Amount of stuff to slurp up with each read. */
530 #ifndef YY_READ_BUF_SIZE
531 #define YY_READ_BUF_SIZE 8192
532 #endif
533
534 /* Copy whatever the last rule matched to the standard output. */
535
536 #ifndef ECHO
537 /* This used to be an fputs(), but since the string might contain NUL's,
538 * we now use fwrite().
539 */
540 #define ECHO (void) fwrite( yytext, yyleng, 1, yyout )
541 #endif
542
543 /* Gets input and stuffs it into "buf". number of characters read, or YY_NULL,
544 * is returned in "result".
545 */
546 #ifndef YY_INPUT
547 #define YY_INPUT(buf,result,max_size) \
548 if ( yy_current_buffer->yy_is_interactive ) \
549 { \
550 int c = '*', n; \
551 for ( n = 0; n < max_size && \
552 (c = getc( yyin )) != EOF && c != '\n'; ++n ) \
553 buf[n] = (char) c; \
554 if ( c == '\n' ) \
555 buf[n++] = (char) c; \
556 if ( c == EOF && ferror( yyin ) ) \
557 YY_FATAL_ERROR( "input in flex scanner failed" ); \
558 result = n; \
559 } \
560 else if ( ((result = fread( buf, 1, max_size, yyin )) == 0) \
561 && ferror( yyin ) ) \
562 YY_FATAL_ERROR( "input in flex scanner failed" );
563 #endif
564
565 /* No semi-colon after return; correct usage is to write "yyterminate();" -
566 * we don't want an extra ';' after the "return" because that will cause
567 * some compilers to complain about unreachable statements.
568 */
569 #ifndef yyterminate
570 #define yyterminate() return YY_NULL
571 #endif
572
573 /* Number of entries by which start-condition stack grows. */
574 #ifndef YY_START_STACK_INCR
575 #define YY_START_STACK_INCR 25
576 #endif
577
578 /* Report a fatal error. */
579 #ifndef YY_FATAL_ERROR
580 #define YY_FATAL_ERROR(msg) yy_fatal_error( msg )
581 #endif
582
583 /* Default declaration of generated scanner - a define so the user can
584 * easily add parameters.
585 */
586 #ifndef YY_DECL
587 #define YY_DECL int yylex YY_PROTO(( void ))
588 #endif
589
590 /* Code executed at the beginning of each rule, after yytext and yyleng
591 * have been set up.
592 */
593 #ifndef YY_USER_ACTION
594 #define YY_USER_ACTION
595 #endif
596
597 /* Code executed at the end of each rule. */
598 #ifndef YY_BREAK
599 #define YY_BREAK break;
600 #endif
601
602 #define YY_RULE_SETUP \
603 YY_USER_ACTION
604
605 YY_DECL
606 {
607 register yy_state_type yy_current_state;
608 register char *yy_cp, *yy_bp;
609 register int yy_act;
610
611
612
613
614 if ( yy_init )
615 {
616 yy_init = 0;
617
618 #ifdef YY_USER_INIT
619 YY_USER_INIT;
620 #endif
621
622 if ( ! yy_start )
623 yy_start = 1; /* first start state */
624
625 if ( ! yyin )
626 yyin = stdin;
627
628 if ( ! yyout )
629 yyout = stdout;
630
631 if ( ! yy_current_buffer )
632 yy_current_buffer =
633 yy_create_buffer( yyin, YY_BUF_SIZE );
634
635 yy_load_buffer_state();
636 }
637
638 while ( 1 ) /* loops until end-of-file is reached */
639 {
640 yy_cp = yy_c_buf_p;
641
642 /* Support of yytext. */
643 *yy_cp = yy_hold_char;
644
645 /* yy_bp points to the position in yy_ch_buf of the start of
646 * the current run.
647 */
648 yy_bp = yy_cp;
649
650 yy_current_state = yy_start;
651 yy_state_ptr = yy_state_buf;
652 *yy_state_ptr++ = yy_current_state;
653 yy_match:
654 do
655 {
656 register YY_CHAR yy_c = yy_ec[YY_SC_TO_UI(*yy_cp)];
657 while ( yy_chk[yy_base[yy_current_state] + yy_c] != yy_current_state )
658 {
659 yy_current_state = (int) yy_def[yy_current_state];
660 if ( yy_current_state >= 29 )
661 yy_c = yy_meta[(unsigned int) yy_c];
662 }
663 yy_current_state = yy_nxt[yy_base[yy_current_state] + (unsigned int) yy_c];
664 *yy_state_ptr++ = yy_current_state;
665 ++yy_cp;
666 }
667 while ( yy_base[yy_current_state] != 28 );
668
669 yy_find_action:
670 yy_current_state = *--yy_state_ptr;
671 yy_lp = yy_accept[yy_current_state];
672 find_rule: /* we branch to this label when backing up */
673 for ( ; ; ) /* until we find what rule we matched */
674 {
675 if ( yy_lp && yy_lp < yy_accept[yy_current_state + 1] )
676 {
677 yy_act = yy_acclist[yy_lp];
678 {
679 yy_full_match = yy_cp;
680 break;
681 }
682 }
683 --yy_cp;
684 yy_current_state = *--yy_state_ptr;
685 yy_lp = yy_accept[yy_current_state];
686 }
687
688 YY_DO_BEFORE_ACTION;
689
690 if ( yy_act != YY_END_OF_BUFFER )
691 {
692 int yyl;
693 for ( yyl = 0; yyl < yyleng; ++yyl )
694 if ( yytext[yyl] == '\n' )
695 ++yylineno;
696 }
697
698 do_action: /* This label is used only to access EOF actions. */
699
700
701 switch ( yy_act )
702 { /* beginning of action switch */
703 case 1:
704 YY_RULE_SETUP
705 {
706 if(strCppComment.empty() == false) {
707 strCppComment += "\n";
708 }
709 iCppCommentLine = cp_lineno;
710 BEGIN(cpp_comment);
711 }
712 YY_BREAK
713 case 2:
714 YY_RULE_SETUP
715 {
716 /* if we kept some C++ comment, it is time to flush it to the
717 * result output */
718 if(strCppComment.empty() == false && pResults) {
719 pResults->addComment(strCppComment, iCppCommentLine, false);
720 strCppComment.clear();
721 iCppCommentLine = -1;
722 }
723 strComment.clear();
724 BEGIN(c_comment);
725 }
726 YY_BREAK
727 case 3:
728 YY_RULE_SETUP
729 {
730 /* if we kept some C++ comment, it is time to flush it to the
731 * result output */
732 if(strCppComment.empty() == false && pResults) {
733 pResults->addComment(strCppComment, iCppCommentLine, false);
734 strCppComment.clear();
735 iCppCommentLine = -1;
736 }
737 strComment.clear();
738 BEGIN(c_comment);
739 }
740 YY_BREAK
741 case 4:
742 YY_RULE_SETUP
743 { /* skip whitespaces */}
744 YY_BREAK
745 case 5:
746 YY_RULE_SETUP
747 {
748 /* if we kept some C++ comment, it is time to flush it to the
749 * result output */
750 if(strCppComment.empty() == false && pResults) {
751 pResults->addComment(strCppComment, iCppCommentLine, false);
752 strCppComment.clear();
753 iCppCommentLine = -1;
754 }
755 }
756 YY_BREAK
757 case 6:
758 YY_RULE_SETUP
759 {
760 /* if we kept some C++ comment, it is time to flush it to the
761 * result output */
762 if(strCppComment.empty() == false && pResults) {
763 pResults->addComment(strCppComment, iCppCommentLine, false);
764 strCppComment.clear();
765 iCppCommentLine = -1;
766 }
767 }
768 YY_BREAK
769 case 7:
770 YY_RULE_SETUP
771 {
772 BEGIN(INITIAL);
773 }
774 YY_BREAK
775 case 8:
776 YY_RULE_SETUP
777 {strCppComment += yytext;} /* do nothing */
778 YY_BREAK
779 case 9:
780 YY_RULE_SETUP
781 {
782 pResults->addComment(strComment, cp_lineno, false);
783 BEGIN(INITIAL);
784 }
785 YY_BREAK
786 case 10:
787 YY_RULE_SETUP
788 {}
789 YY_BREAK
790 case 11:
791 YY_RULE_SETUP
792 {}
793 YY_BREAK
794 case 12:
795 YY_RULE_SETUP
796 {
797 if(strComment.empty() == false) {
798 if(strComment.at(strComment.length() -1) == '\n'){
799 // dont add indentation tabs
800 } else {
801 strComment += " ";
802 }
803 } else {
804 // empty comment: dont prepend whitespaces at start
805 }
806 }
807 YY_BREAK
808 case 13:
809 YY_RULE_SETUP
810 {
811 if(strComment.empty() == false) {
812 if(strComment.at(strComment.length() -1) == '\n'){
813 // dont add indentation tabs
814 } else {
815 strComment += "*";
816 }
817 } else {
818 // empty comment: dont prepend '*'
819 }
820 }
821 YY_BREAK
822 case 14:
823 YY_RULE_SETUP
824 { strComment += "\n";}
825 YY_BREAK
826 case 15:
827 YY_RULE_SETUP
828 { strComment += yytext;}
829 YY_BREAK
830 case YY_STATE_EOF(INITIAL):
831 case YY_STATE_EOF(incl):
832 case YY_STATE_EOF(c_comment):
833 case YY_STATE_EOF(cpp_comment):
834 {
835 if(strCppComment.empty() == false && pResults) {
836 pResults->addComment(strCppComment, iCppCommentLine, false);
837 strCppComment.clear();
838 iCppCommentLine = -1;
839 }
840
841 if ( YY_CURRENT_BUFFER->yy_input_file ) {
842 fclose( YY_CURRENT_BUFFER->yy_input_file );
843 YY_CURRENT_BUFFER->yy_input_file = NULL;
844 }
845
846 yy_delete_buffer ( YY_CURRENT_BUFFER );
847 yyterminate();
848 }
849 YY_BREAK
850 case 16:
851 YY_RULE_SETUP
852 ECHO;
853 YY_BREAK
854
855 case YY_END_OF_BUFFER:
856 {
857 /* Amount of text matched not including the EOB char. */
858 int yy_amount_of_matched_text = (int) (yy_cp - yytext_ptr) - 1;
859
860 /* Undo the effects of YY_DO_BEFORE_ACTION. */
861 *yy_cp = yy_hold_char;
862 YY_RESTORE_YY_MORE_OFFSET
863
864 if ( yy_current_buffer->yy_buffer_status == YY_BUFFER_NEW )
865 {
866 /* We're scanning a new file or input source. It's
867 * possible that this happened because the user
868 * just pointed yyin at a new source and called
869 * yylex(). If so, then we have to assure
870 * consistency between yy_current_buffer and our
871 * globals. Here is the right place to do so, because
872 * this is the first action (other than possibly a
873 * back-up) that will match for the new input source.
874 */
875 yy_n_chars = yy_current_buffer->yy_n_chars;
876 yy_current_buffer->yy_input_file = yyin;
877 yy_current_buffer->yy_buffer_status = YY_BUFFER_NORMAL;
878 }
879
880 /* Note that here we test for yy_c_buf_p "<=" to the position
881 * of the first EOB in the buffer, since yy_c_buf_p will
882 * already have been incremented past the NUL character
883 * (since all states make transitions on EOB to the
884 * end-of-buffer state). Contrast this with the test
885 * in input().
886 */
887 if ( yy_c_buf_p <= &yy_current_buffer->yy_ch_buf[yy_n_chars] )
888 { /* This was really a NUL. */
889 yy_state_type yy_next_state;
890
891 yy_c_buf_p = yytext_ptr + yy_amount_of_matched_text;
892
893 yy_current_state = yy_get_previous_state();
894
895 /* Okay, we're now positioned to make the NUL
896 * transition. We couldn't have
897 * yy_get_previous_state() go ahead and do it
898 * for us because it doesn't know how to deal
899 * with the possibility of jamming (and we don't
900 * want to build jamming into it because then it
901 * will run more slowly).
902 */
903
904 yy_next_state = yy_try_NUL_trans( yy_current_state );
905
906 yy_bp = yytext_ptr + YY_MORE_ADJ;
907
908 if ( yy_next_state )
909 {
910 /* Consume the NUL. */
911 yy_cp = ++yy_c_buf_p;
912 yy_current_state = yy_next_state;
913 goto yy_match;
914 }
915
916 else
917 {
918 yy_cp = yy_c_buf_p;
919 goto yy_find_action;
920 }
921 }
922
923 else switch ( yy_get_next_buffer() )
924 {
925 case EOB_ACT_END_OF_FILE:
926 {
927 yy_did_buffer_switch_on_eof = 0;
928
929 if ( yywrap() )
930 {
931 /* Note: because we've taken care in
932 * yy_get_next_buffer() to have set up
933 * yytext, we can now set up
934 * yy_c_buf_p so that if some total
935 * hoser (like flex itself) wants to
936 * call the scanner after we return the
937 * YY_NULL, it'll still work - another
938 * YY_NULL will get returned.
939 */
940 yy_c_buf_p = yytext_ptr + YY_MORE_ADJ;
941
942 yy_act = YY_STATE_EOF(YY_START);
943 goto do_action;
944 }
945
946 else
947 {
948 if ( ! yy_did_buffer_switch_on_eof )
949 YY_NEW_FILE;
950 }
951 break;
952 }
953
954 case EOB_ACT_CONTINUE_SCAN:
955 yy_c_buf_p =
956 yytext_ptr + yy_amount_of_matched_text;
957
958 yy_current_state = yy_get_previous_state();
959
960 yy_cp = yy_c_buf_p;
961 yy_bp = yytext_ptr + YY_MORE_ADJ;
962 goto yy_match;
963
964 case EOB_ACT_LAST_MATCH:
965 yy_c_buf_p =
966 &yy_current_buffer->yy_ch_buf[yy_n_chars];
967
968 yy_current_state = yy_get_previous_state();
969
970 yy_cp = yy_c_buf_p;
971 yy_bp = yytext_ptr + YY_MORE_ADJ;
972 goto yy_find_action;
973 }
974 break;
975 }
976
977 default:
978 YY_FATAL_ERROR(
979 "fatal flex scanner internal error--no action found" );
980 } /* end of action switch */
981 } /* end of scanning one token */
982 } /* end of yylex */
983
984
985 /* yy_get_next_buffer - try to read in a new buffer
986 *
987 * Returns a code representing an action:
988 * EOB_ACT_LAST_MATCH -
989 * EOB_ACT_CONTINUE_SCAN - continue scanning from current position
990 * EOB_ACT_END_OF_FILE - end of file
991 */
992
993 static int yy_get_next_buffer()
994 {
995 register char *dest = yy_current_buffer->yy_ch_buf;
996 register char *source = yytext_ptr;
997 register int number_to_move, i;
998 int ret_val;
999
1000 if ( yy_c_buf_p > &yy_current_buffer->yy_ch_buf[yy_n_chars + 1] )
1001 YY_FATAL_ERROR(
1002 "fatal flex scanner internal error--end of buffer missed" );
1003
1004 if ( yy_current_buffer->yy_fill_buffer == 0 )
1005 { /* Don't try to fill the buffer, so this is an EOF. */
1006 if ( yy_c_buf_p - yytext_ptr - YY_MORE_ADJ == 1 )
1007 {
1008 /* We matched a single character, the EOB, so
1009 * treat this as a final EOF.
1010 */
1011 return EOB_ACT_END_OF_FILE;
1012 }
1013
1014 else
1015 {
1016 /* We matched some text prior to the EOB, first
1017 * process it.
1018 */
1019 return EOB_ACT_LAST_MATCH;
1020 }
1021 }
1022
1023 /* Try to read more data. */
1024
1025 /* First move last chars to start of buffer. */
1026 number_to_move = (int) (yy_c_buf_p - yytext_ptr) - 1;
1027
1028 for ( i = 0; i < number_to_move; ++i )
1029 *(dest++) = *(source++);
1030
1031 if ( yy_current_buffer->yy_buffer_status == YY_BUFFER_EOF_PENDING )
1032 /* don't do the read, it's not guaranteed to return an EOF,
1033 * just force an EOF
1034 */
1035 yy_current_buffer->yy_n_chars = yy_n_chars = 0;
1036
1037 else
1038 {
1039 int num_to_read =
1040 yy_current_buffer->yy_buf_size - number_to_move - 1;
1041
1042 while ( num_to_read <= 0 )
1043 { /* Not enough room in the buffer - grow it. */
1044 #ifdef YY_USES_REJECT
1045 YY_FATAL_ERROR(
1046 "input buffer overflow, can't enlarge buffer because scanner uses REJECT" );
1047 #else
1048
1049 /* just a shorter name for the current buffer */
1050 YY_BUFFER_STATE b = yy_current_buffer;
1051
1052 int yy_c_buf_p_offset =
1053 (int) (yy_c_buf_p - b->yy_ch_buf);
1054
1055 if ( b->yy_is_our_buffer )
1056 {
1057 int new_size = b->yy_buf_size * 2;
1058
1059 if ( new_size <= 0 )
1060 b->yy_buf_size += b->yy_buf_size / 8;
1061 else
1062 b->yy_buf_size *= 2;
1063
1064 b->yy_ch_buf = (char *)
1065 /* Include room in for 2 EOB chars. */
1066 yy_flex_realloc( (void *) b->yy_ch_buf,
1067 b->yy_buf_size + 2 );
1068 }
1069 else
1070 /* Can't grow it, we don't own it. */
1071 b->yy_ch_buf = 0;
1072
1073 if ( ! b->yy_ch_buf )
1074 YY_FATAL_ERROR(
1075 "fatal error - scanner input buffer overflow" );
1076
1077 yy_c_buf_p = &b->yy_ch_buf[yy_c_buf_p_offset];
1078
1079 num_to_read = yy_current_buffer->yy_buf_size -
1080 number_to_move - 1;
1081 #endif
1082 }
1083
1084 if ( num_to_read > YY_READ_BUF_SIZE )
1085 num_to_read = YY_READ_BUF_SIZE;
1086
1087 /* Read in more data. */
1088 YY_INPUT( (&yy_current_buffer->yy_ch_buf[number_to_move]),
1089 yy_n_chars, num_to_read );
1090
1091 yy_current_buffer->yy_n_chars = yy_n_chars;
1092 }
1093
1094 if ( yy_n_chars == 0 )
1095 {
1096 if ( number_to_move == YY_MORE_ADJ )
1097 {
1098 ret_val = EOB_ACT_END_OF_FILE;
1099 yyrestart( yyin );
1100 }
1101
1102 else
1103 {
1104 ret_val = EOB_ACT_LAST_MATCH;
1105 yy_current_buffer->yy_buffer_status =
1106 YY_BUFFER_EOF_PENDING;
1107 }
1108 }
1109
1110 else
1111 ret_val = EOB_ACT_CONTINUE_SCAN;
1112
1113 yy_n_chars += number_to_move;
1114 yy_current_buffer->yy_ch_buf[yy_n_chars] = YY_END_OF_BUFFER_CHAR;
1115 yy_current_buffer->yy_ch_buf[yy_n_chars + 1] = YY_END_OF_BUFFER_CHAR;
1116
1117 yytext_ptr = &yy_current_buffer->yy_ch_buf[0];
1118
1119 return ret_val;
1120 }
1121
1122
1123 /* yy_get_previous_state - get the state just before the EOB char was reached */
1124
1125 static yy_state_type yy_get_previous_state()
1126 {
1127 register yy_state_type yy_current_state;
1128 register char *yy_cp;
1129
1130 yy_current_state = yy_start;
1131 yy_state_ptr = yy_state_buf;
1132 *yy_state_ptr++ = yy_current_state;
1133
1134 for ( yy_cp = yytext_ptr + YY_MORE_ADJ; yy_cp < yy_c_buf_p; ++yy_cp )
1135 {
1136 register YY_CHAR yy_c = (*yy_cp ? yy_ec[YY_SC_TO_UI(*yy_cp)] : 1);
1137 while ( yy_chk[yy_base[yy_current_state] + yy_c] != yy_current_state )
1138 {
1139 yy_current_state = (int) yy_def[yy_current_state];
1140 if ( yy_current_state >= 29 )
1141 yy_c = yy_meta[(unsigned int) yy_c];
1142 }
1143 yy_current_state = yy_nxt[yy_base[yy_current_state] + (unsigned int) yy_c];
1144 *yy_state_ptr++ = yy_current_state;
1145 }
1146
1147 return yy_current_state;
1148 }
1149
1150
1151 /* yy_try_NUL_trans - try to make a transition on the NUL character
1152 *
1153 * synopsis
1154 * next_state = yy_try_NUL_trans( current_state );
1155 */
1156
1157 #ifdef YY_USE_PROTOS
1158 static yy_state_type yy_try_NUL_trans( yy_state_type yy_current_state )
1159 #else
1160 static yy_state_type yy_try_NUL_trans( yy_current_state )
1161 yy_state_type yy_current_state;
1162 #endif
1163 {
1164 register int yy_is_jam;
1165
1166 register YY_CHAR yy_c = 1;
1167 while ( yy_chk[yy_base[yy_current_state] + yy_c] != yy_current_state )
1168 {
1169 yy_current_state = (int) yy_def[yy_current_state];
1170 if ( yy_current_state >= 29 )
1171 yy_c = yy_meta[(unsigned int) yy_c];
1172 }
1173 yy_current_state = yy_nxt[yy_base[yy_current_state] + (unsigned int) yy_c];
1174 yy_is_jam = (yy_current_state == 28);
1175 if ( ! yy_is_jam )
1176 *yy_state_ptr++ = yy_current_state;
1177
1178 return yy_is_jam ? 0 : yy_current_state;
1179 }
1180
1181
1182 #ifndef YY_NO_UNPUT
1183 #ifdef YY_USE_PROTOS
1184 static void yyunput( int c, register char *yy_bp )
1185 #else
1186 static void yyunput( c, yy_bp )
1187 int c;
1188 register char *yy_bp;
1189 #endif
1190 {
1191 register char *yy_cp = yy_c_buf_p;
1192
1193 /* undo effects of setting up yytext */
1194 *yy_cp = yy_hold_char;
1195
1196 if ( yy_cp < yy_current_buffer->yy_ch_buf + 2 )
1197 { /* need to shift things up to make room */
1198 /* +2 for EOB chars. */
1199 register int number_to_move = yy_n_chars + 2;
1200 register char *dest = &yy_current_buffer->yy_ch_buf[
1201 yy_current_buffer->yy_buf_size + 2];
1202 register char *source =
1203 &yy_current_buffer->yy_ch_buf[number_to_move];
1204
1205 while ( source > yy_current_buffer->yy_ch_buf )
1206 *--dest = *--source;
1207
1208 yy_cp += (int) (dest - source);
1209 yy_bp += (int) (dest - source);
1210 yy_current_buffer->yy_n_chars =
1211 yy_n_chars = yy_current_buffer->yy_buf_size;
1212
1213 if ( yy_cp < yy_current_buffer->yy_ch_buf + 2 )
1214 YY_FATAL_ERROR( "flex scanner push-back overflow" );
1215 }
1216
1217 *--yy_cp = (char) c;
1218
1219 if ( c == '\n' )
1220 --yylineno;
1221
1222 yytext_ptr = yy_bp;
1223 yy_hold_char = *yy_cp;
1224 yy_c_buf_p = yy_cp;
1225 }
1226 #endif /* ifndef YY_NO_UNPUT */
1227
1228
1229 #ifdef __cplusplus
1230 static int yyinput()
1231 #else
1232 static int input()
1233 #endif
1234 {
1235 int c;
1236
1237 *yy_c_buf_p = yy_hold_char;
1238
1239 if ( *yy_c_buf_p == YY_END_OF_BUFFER_CHAR )
1240 {
1241 /* yy_c_buf_p now points to the character we want to return.
1242 * If this occurs *before* the EOB characters, then it's a
1243 * valid NUL; if not, then we've hit the end of the buffer.
1244 */
1245 if ( yy_c_buf_p < &yy_current_buffer->yy_ch_buf[yy_n_chars] )
1246 /* This was really a NUL. */
1247 *yy_c_buf_p = '\0';
1248
1249 else
1250 { /* need more input */
1251 int offset = yy_c_buf_p - yytext_ptr;
1252 ++yy_c_buf_p;
1253
1254 switch ( yy_get_next_buffer() )
1255 {
1256 case EOB_ACT_LAST_MATCH:
1257 /* This happens because yy_g_n_b()
1258 * sees that we've accumulated a
1259 * token and flags that we need to
1260 * try matching the token before
1261 * proceeding. But for input(),
1262 * there's no matching to consider.
1263 * So convert the EOB_ACT_LAST_MATCH
1264 * to EOB_ACT_END_OF_FILE.
1265 */
1266
1267 /* Reset buffer status. */
1268 yyrestart( yyin );
1269
1270 /* fall through */
1271
1272 case EOB_ACT_END_OF_FILE:
1273 {
1274 if ( yywrap() )
1275 return EOF;
1276
1277 if ( ! yy_did_buffer_switch_on_eof )
1278 YY_NEW_FILE;
1279 #ifdef __cplusplus
1280 return yyinput();
1281 #else
1282 return input();
1283 #endif
1284 }
1285
1286 case EOB_ACT_CONTINUE_SCAN:
1287 yy_c_buf_p = yytext_ptr + offset;
1288 break;
1289 }
1290 }
1291 }
1292
1293 c = *(unsigned char *) yy_c_buf_p; /* cast for 8-bit char's */
1294 *yy_c_buf_p = '\0'; /* preserve yytext */
1295 yy_hold_char = *++yy_c_buf_p;
1296
1297 if ( c == '\n' )
1298 ++yylineno;
1299
1300 return c;
1301 }
1302
1303
1304 #ifdef YY_USE_PROTOS
1305 void yyrestart( FILE *input_file )
1306 #else
1307 void yyrestart( input_file )
1308 FILE *input_file;
1309 #endif
1310 {
1311 if ( ! yy_current_buffer )
1312 yy_current_buffer = yy_create_buffer( yyin, YY_BUF_SIZE );
1313
1314 yy_init_buffer( yy_current_buffer, input_file );
1315 yy_load_buffer_state();
1316 }
1317
1318
1319 #ifdef YY_USE_PROTOS
1320 void yy_switch_to_buffer( YY_BUFFER_STATE new_buffer )
1321 #else
1322 void yy_switch_to_buffer( new_buffer )
1323 YY_BUFFER_STATE new_buffer;
1324 #endif
1325 {
1326 if ( yy_current_buffer == new_buffer )
1327 return;
1328
1329 if ( yy_current_buffer )
1330 {
1331 /* Flush out information for old buffer. */
1332 *yy_c_buf_p = yy_hold_char;
1333 yy_current_buffer->yy_buf_pos = yy_c_buf_p;
1334 yy_current_buffer->yy_n_chars = yy_n_chars;
1335 }
1336
1337 yy_current_buffer = new_buffer;
1338 yy_load_buffer_state();
1339
1340 /* We don't actually know whether we did this switch during
1341 * EOF (yywrap()) processing, but the only time this flag
1342 * is looked at is after yywrap() is called, so it's safe
1343 * to go ahead and always set it.
1344 */
1345 yy_did_buffer_switch_on_eof = 1;
1346 }
1347
1348
1349 #ifdef YY_USE_PROTOS
1350 void yy_load_buffer_state( void )
1351 #else
1352 void yy_load_buffer_state()
1353 #endif
1354 {
1355 yy_n_chars = yy_current_buffer->yy_n_chars;
1356 yytext_ptr = yy_c_buf_p = yy_current_buffer->yy_buf_pos;
1357 yyin = yy_current_buffer->yy_input_file;
1358 yy_hold_char = *yy_c_buf_p;
1359 }
1360
1361
1362 #ifdef YY_USE_PROTOS
1363 YY_BUFFER_STATE yy_create_buffer( FILE *file, int size )
1364 #else
1365 YY_BUFFER_STATE yy_create_buffer( file, size )
1366 FILE *file;
1367 int size;
1368 #endif
1369 {
1370 YY_BUFFER_STATE b;
1371
1372 b = (YY_BUFFER_STATE) yy_flex_alloc( sizeof( struct yy_buffer_state ) );
1373 if ( ! b )
1374 YY_FATAL_ERROR( "out of dynamic memory in yy_create_buffer()" );
1375
1376 b->yy_buf_size = size;
1377
1378 /* yy_ch_buf has to be 2 characters longer than the size given because
1379 * we need to put in 2 end-of-buffer characters.
1380 */
1381 b->yy_ch_buf = (char *) yy_flex_alloc( b->yy_buf_size + 2 );
1382 if ( ! b->yy_ch_buf )
1383 YY_FATAL_ERROR( "out of dynamic memory in yy_create_buffer()" );
1384
1385 b->yy_is_our_buffer = 1;
1386
1387 yy_init_buffer( b, file );
1388
1389 return b;
1390 }
1391
1392
1393 #ifdef YY_USE_PROTOS
1394 void yy_delete_buffer( YY_BUFFER_STATE b )
1395 #else
1396 void yy_delete_buffer( b )
1397 YY_BUFFER_STATE b;
1398 #endif
1399 {
1400 if ( ! b )
1401 return;
1402
1403 if ( b == yy_current_buffer )
1404 yy_current_buffer = (YY_BUFFER_STATE) 0;
1405
1406 if ( b->yy_is_our_buffer )
1407 yy_flex_free( (void *) b->yy_ch_buf );
1408
1409 yy_flex_free( (void *) b );
1410 }
1411
1412
1413 #ifndef YY_ALWAYS_INTERACTIVE
1414 #ifndef YY_NEVER_INTERACTIVE
1415 extern int isatty YY_PROTO(( int ));
1416 #endif
1417 #endif
1418
1419 #ifdef YY_USE_PROTOS
1420 void yy_init_buffer( YY_BUFFER_STATE b, FILE *file )
1421 #else
1422 void yy_init_buffer( b, file )
1423 YY_BUFFER_STATE b;
1424 FILE *file;
1425 #endif
1426
1427
1428 {
1429 yy_flush_buffer( b );
1430
1431 b->yy_input_file = file;
1432 b->yy_fill_buffer = 1;
1433
1434 #if YY_ALWAYS_INTERACTIVE
1435 b->yy_is_interactive = 1;
1436 #else
1437 #if YY_NEVER_INTERACTIVE
1438 b->yy_is_interactive = 0;
1439 #else
1440 b->yy_is_interactive = file ? (isatty( fileno(file) ) > 0) : 0;
1441 #endif
1442 #endif
1443 }
1444
1445
1446 #ifdef YY_USE_PROTOS
1447 void yy_flush_buffer( YY_BUFFER_STATE b )
1448 #else
1449 void yy_flush_buffer( b )
1450 YY_BUFFER_STATE b;
1451 #endif
1452
1453 {
1454 if ( ! b )
1455 return;
1456
1457 b->yy_n_chars = 0;
1458
1459 /* We always need two end-of-buffer characters. The first causes
1460 * a transition to the end-of-buffer state. The second causes
1461 * a jam in that state.
1462 */
1463 b->yy_ch_buf[0] = YY_END_OF_BUFFER_CHAR;
1464 b->yy_ch_buf[1] = YY_END_OF_BUFFER_CHAR;
1465
1466 b->yy_buf_pos = &b->yy_ch_buf[0];
1467
1468 b->yy_at_bol = 1;
1469 b->yy_buffer_status = YY_BUFFER_NEW;
1470
1471 if ( b == yy_current_buffer )
1472 yy_load_buffer_state();
1473 }
1474
1475
1476 #ifndef YY_NO_SCAN_BUFFER
1477 #ifdef YY_USE_PROTOS
1478 YY_BUFFER_STATE yy_scan_buffer( char *base, yy_size_t size )
1479 #else
1480 YY_BUFFER_STATE yy_scan_buffer( base, size )
1481 char *base;
1482 yy_size_t size;
1483 #endif
1484 {
1485 YY_BUFFER_STATE b;
1486
1487 if ( size < 2 ||
1488 base[size-2] != YY_END_OF_BUFFER_CHAR ||
1489 base[size-1] != YY_END_OF_BUFFER_CHAR )
1490 /* They forgot to leave room for the EOB's. */
1491 return 0;
1492
1493 b = (YY_BUFFER_STATE) yy_flex_alloc( sizeof( struct yy_buffer_state ) );
1494 if ( ! b )
1495 YY_FATAL_ERROR( "out of dynamic memory in yy_scan_buffer()" );
1496
1497 b->yy_buf_size = size - 2; /* "- 2" to take care of EOB's */
1498 b->yy_buf_pos = b->yy_ch_buf = base;
1499 b->yy_is_our_buffer = 0;
1500 b->yy_input_file = 0;
1501 b->yy_n_chars = b->yy_buf_size;
1502 b->yy_is_interactive = 0;
1503 b->yy_at_bol = 1;
1504 b->yy_fill_buffer = 0;
1505 b->yy_buffer_status = YY_BUFFER_NEW;
1506
1507 yy_switch_to_buffer( b );
1508
1509 return b;
1510 }
1511 #endif
1512
1513
1514 #ifndef YY_NO_SCAN_STRING
1515 #ifdef YY_USE_PROTOS
1516 YY_BUFFER_STATE yy_scan_string( yyconst char *yy_str )
1517 #else
1518 YY_BUFFER_STATE yy_scan_string( yy_str )
1519 yyconst char *yy_str;
1520 #endif
1521 {
1522 int len;
1523 for ( len = 0; yy_str[len]; ++len )
1524 ;
1525
1526 return yy_scan_bytes( yy_str, len );
1527 }
1528 #endif
1529
1530
1531 #ifndef YY_NO_SCAN_BYTES
1532 #ifdef YY_USE_PROTOS
1533 YY_BUFFER_STATE yy_scan_bytes( yyconst char *bytes, int len )
1534 #else
1535 YY_BUFFER_STATE yy_scan_bytes( bytes, len )
1536 yyconst char *bytes;
1537 int len;
1538 #endif
1539 {
1540 YY_BUFFER_STATE b;
1541 char *buf;
1542 yy_size_t n;
1543 int i;
1544
1545 /* Get memory for full buffer, including space for trailing EOB's. */
1546 n = len + 2;
1547 buf = (char *) yy_flex_alloc( n );
1548 if ( ! buf )
1549 YY_FATAL_ERROR( "out of dynamic memory in yy_scan_bytes()" );
1550
1551 for ( i = 0; i < len; ++i )
1552 buf[i] = bytes[i];
1553
1554 buf[len] = buf[len+1] = YY_END_OF_BUFFER_CHAR;
1555
1556 b = yy_scan_buffer( buf, n );
1557 if ( ! b )
1558 YY_FATAL_ERROR( "bad buffer in yy_scan_bytes()" );
1559
1560 /* It's okay to grow etc. this buffer, and we should throw it
1561 * away when we're done.
1562 */
1563 b->yy_is_our_buffer = 1;
1564
1565 return b;
1566 }
1567 #endif
1568
1569
1570 #ifndef YY_NO_PUSH_STATE
1571 #ifdef YY_USE_PROTOS
1572 static void yy_push_state( int new_state )
1573 #else
1574 static void yy_push_state( new_state )
1575 int new_state;
1576 #endif
1577 {
1578 if ( yy_start_stack_ptr >= yy_start_stack_depth )
1579 {
1580 yy_size_t new_size;
1581
1582 yy_start_stack_depth += YY_START_STACK_INCR;
1583 new_size = yy_start_stack_depth * sizeof( int );
1584
1585 if ( ! yy_start_stack )
1586 yy_start_stack = (int *) yy_flex_alloc( new_size );
1587
1588 else
1589 yy_start_stack = (int *) yy_flex_realloc(
1590 (void *) yy_start_stack, new_size );
1591
1592 if ( ! yy_start_stack )
1593 YY_FATAL_ERROR(
1594 "out of memory expanding start-condition stack" );
1595 }
1596
1597 yy_start_stack[yy_start_stack_ptr++] = YY_START;
1598
1599 BEGIN(new_state);
1600 }
1601 #endif
1602
1603
1604 #ifndef YY_NO_POP_STATE
1605 static void yy_pop_state()
1606 {
1607 if ( --yy_start_stack_ptr < 0 )
1608 YY_FATAL_ERROR( "start-condition stack underflow" );
1609
1610 BEGIN(yy_start_stack[yy_start_stack_ptr]);
1611 }
1612 #endif
1613
1614
1615 #ifndef YY_NO_TOP_STATE
1616 static int yy_top_state()
1617 {
1618 return yy_start_stack[yy_start_stack_ptr - 1];
1619 }
1620 #endif
1621
1622 #ifndef YY_EXIT_FAILURE
1623 #define YY_EXIT_FAILURE 2
1624 #endif
1625
1626 #ifdef YY_USE_PROTOS
1627 static void yy_fatal_error( yyconst char msg[] )
1628 #else
1629 static void yy_fatal_error( msg )
1630 char msg[];
1631 #endif
1632 {
1633 (void) fprintf( stderr, "%s\n", msg );
1634
1635 }
1636
1637
1638
1639 /* Redefine yyless() so it works in section 3 code. */
1640
1641 #undef yyless
1642 #define yyless(n) \
1643 do \
1644 { \
1645 /* Undo effects of setting up yytext. */ \
1646 yytext[yyleng] = yy_hold_char; \
1647 yy_c_buf_p = yytext + n; \
1648 yy_hold_char = *yy_c_buf_p; \
1649 *yy_c_buf_p = '\0'; \
1650 yyleng = n; \
1651 } \
1652 while ( 0 )
1653
1654
1655 /* Internal utility routines. */
1656
1657 #ifndef yytext_ptr
1658 #ifdef YY_USE_PROTOS
1659 static void yy_flex_strncpy( char *s1, yyconst char *s2, int n )
1660 #else
1661 static void yy_flex_strncpy( s1, s2, n )
1662 char *s1;
1663 yyconst char *s2;
1664 int n;
1665 #endif
1666 {
1667 register int i;
1668 for ( i = 0; i < n; ++i )
1669 s1[i] = s2[i];
1670 }
1671 #endif
1672
1673 #ifdef YY_NEED_STRLEN
1674 #ifdef YY_USE_PROTOS
1675 static int yy_flex_strlen( yyconst char *s )
1676 #else
1677 static int yy_flex_strlen( s )
1678 yyconst char *s;
1679 #endif
1680 {
1681 register int n;
1682 for ( n = 0; s[n]; ++n )
1683 ;
1684
1685 return n;
1686 }
1687 #endif
1688
1689
1690 #ifdef YY_USE_PROTOS
1691 static void *yy_flex_alloc( yy_size_t size )
1692 #else
1693 static void *yy_flex_alloc( size )
1694 yy_size_t size;
1695 #endif
1696 {
1697 return (void *) malloc( size );
1698 }
1699
1700 #ifdef YY_USE_PROTOS
1701 static void *yy_flex_realloc( void *ptr, yy_size_t size )
1702 #else
1703 static void *yy_flex_realloc( ptr, size )
1704 void *ptr;
1705 yy_size_t size;
1706 #endif
1707 {
1708 /* The cast to (char *) in the following accommodates both
1709 * implementations that use char* generic pointers, and those
1710 * that use void* generic pointers. It works with the latter
1711 * because both ANSI C and C++ allow castless assignment from
1712 * any pointer type to void*, and deal with argument conversions
1713 * as though doing an assignment.
1714 */
1715 return (void *) realloc( (char *) ptr, size );
1716 }
1717
1718 #ifdef YY_USE_PROTOS
1719 static void yy_flex_free( void *ptr )
1720 #else
1721 static void yy_flex_free( ptr )
1722 void *ptr;
1723 #endif
1724 {
1725 free( ptr );
1726 }
1727
1728 #if YY_MAIN
1729 int main()
1730 {
1731 yylex();
1732 return 0;
1733 }
1734 #endif
1735
1736
1737 int yywrap() {
1738 return 1;
1739 }
1740
1741 int ParseComments(const char* filePath, CommentParseResult &comments)
1742 {
1743 BEGIN INITIAL;
1744 cp_lineno = 1;
1745
1746 FILE* fp = fopen(filePath, "r");
1747 if ( fp == NULL ) {
1748 return -1;
1749 }
1750
1751 pResults = &comments;
1752 strComment.clear();
1753 strCppComment.clear();
1754 iCppCommentLine = -1;
1755
1756 yy_switch_to_buffer( yy_create_buffer(fp, YY_BUF_SIZE) );
1757 cp_in = fp;
1758 int rc = cp_lex();
1759 yy_delete_buffer ( YY_CURRENT_BUFFER );
1760
1761 // Cleanup
1762 pResults = NULL;
1763 strComment.clear();
1764 strCppComment.clear();
1765 iCppCommentLine = -1;
1766 return rc;
1767 }
1768