Line data Source code
1 : #line 2 "preproc-c.cc"
2 :
3 : #line 4 "preproc-c.cc"
4 :
5 : #define YY_INT_ALIGNED short int
6 :
7 : /* A lexical scanner generated by flex */
8 :
9 : #define yy_create_buffer Rose_C_Cxx__create_buffer
10 : #define yy_delete_buffer Rose_C_Cxx__delete_buffer
11 : #define yy_scan_buffer Rose_C_Cxx__scan_buffer
12 : #define yy_scan_string Rose_C_Cxx__scan_string
13 : #define yy_scan_bytes Rose_C_Cxx__scan_bytes
14 : #define yy_init_buffer Rose_C_Cxx__init_buffer
15 : #define yy_flush_buffer Rose_C_Cxx__flush_buffer
16 : #define yy_load_buffer_state Rose_C_Cxx__load_buffer_state
17 : #define yy_switch_to_buffer Rose_C_Cxx__switch_to_buffer
18 : #define yypush_buffer_state Rose_C_Cxx_push_buffer_state
19 : #define yypop_buffer_state Rose_C_Cxx_pop_buffer_state
20 : #define yyensure_buffer_stack Rose_C_Cxx_ensure_buffer_stack
21 : #define yy_flex_debug Rose_C_Cxx__flex_debug
22 : #define yyin Rose_C_Cxx_in
23 : #define yyleng Rose_C_Cxx_leng
24 : #define yylex Rose_C_Cxx_lex
25 : #define yylineno Rose_C_Cxx_lineno
26 : #define yyout Rose_C_Cxx_out
27 : #define yyrestart Rose_C_Cxx_restart
28 : #define yytext Rose_C_Cxx_text
29 : #define yywrap Rose_C_Cxx_wrap
30 : #define yyalloc Rose_C_Cxx_alloc
31 : #define yyrealloc Rose_C_Cxx_realloc
32 : #define yyfree Rose_C_Cxx_free
33 :
34 : #define FLEX_SCANNER
35 : #define YY_FLEX_MAJOR_VERSION 2
36 : #define YY_FLEX_MINOR_VERSION 6
37 : #define YY_FLEX_SUBMINOR_VERSION 4
38 : #if YY_FLEX_SUBMINOR_VERSION > 0
39 : #define FLEX_BETA
40 : #endif
41 :
42 : #ifdef yy_create_buffer
43 : #define Rose_C_Cxx__create_buffer_ALREADY_DEFINED
44 : #else
45 : #define yy_create_buffer Rose_C_Cxx__create_buffer
46 : #endif
47 :
48 : #ifdef yy_delete_buffer
49 : #define Rose_C_Cxx__delete_buffer_ALREADY_DEFINED
50 : #else
51 : #define yy_delete_buffer Rose_C_Cxx__delete_buffer
52 : #endif
53 :
54 : #ifdef yy_scan_buffer
55 : #define Rose_C_Cxx__scan_buffer_ALREADY_DEFINED
56 : #else
57 : #define yy_scan_buffer Rose_C_Cxx__scan_buffer
58 : #endif
59 :
60 : #ifdef yy_scan_string
61 : #define Rose_C_Cxx__scan_string_ALREADY_DEFINED
62 : #else
63 : #define yy_scan_string Rose_C_Cxx__scan_string
64 : #endif
65 :
66 : #ifdef yy_scan_bytes
67 : #define Rose_C_Cxx__scan_bytes_ALREADY_DEFINED
68 : #else
69 : #define yy_scan_bytes Rose_C_Cxx__scan_bytes
70 : #endif
71 :
72 : #ifdef yy_init_buffer
73 : #define Rose_C_Cxx__init_buffer_ALREADY_DEFINED
74 : #else
75 : #define yy_init_buffer Rose_C_Cxx__init_buffer
76 : #endif
77 :
78 : #ifdef yy_flush_buffer
79 : #define Rose_C_Cxx__flush_buffer_ALREADY_DEFINED
80 : #else
81 : #define yy_flush_buffer Rose_C_Cxx__flush_buffer
82 : #endif
83 :
84 : #ifdef yy_load_buffer_state
85 : #define Rose_C_Cxx__load_buffer_state_ALREADY_DEFINED
86 : #else
87 : #define yy_load_buffer_state Rose_C_Cxx__load_buffer_state
88 : #endif
89 :
90 : #ifdef yy_switch_to_buffer
91 : #define Rose_C_Cxx__switch_to_buffer_ALREADY_DEFINED
92 : #else
93 : #define yy_switch_to_buffer Rose_C_Cxx__switch_to_buffer
94 : #endif
95 :
96 : #ifdef yypush_buffer_state
97 : #define Rose_C_Cxx_push_buffer_state_ALREADY_DEFINED
98 : #else
99 : #define yypush_buffer_state Rose_C_Cxx_push_buffer_state
100 : #endif
101 :
102 : #ifdef yypop_buffer_state
103 : #define Rose_C_Cxx_pop_buffer_state_ALREADY_DEFINED
104 : #else
105 : #define yypop_buffer_state Rose_C_Cxx_pop_buffer_state
106 : #endif
107 :
108 : #ifdef yyensure_buffer_stack
109 : #define Rose_C_Cxx_ensure_buffer_stack_ALREADY_DEFINED
110 : #else
111 : #define yyensure_buffer_stack Rose_C_Cxx_ensure_buffer_stack
112 : #endif
113 :
114 : #ifdef yylex
115 : #define Rose_C_Cxx_lex_ALREADY_DEFINED
116 : #else
117 : #define yylex Rose_C_Cxx_lex
118 : #endif
119 :
120 : #ifdef yyrestart
121 : #define Rose_C_Cxx_restart_ALREADY_DEFINED
122 : #else
123 : #define yyrestart Rose_C_Cxx_restart
124 : #endif
125 :
126 : #ifdef yylex_init
127 : #define Rose_C_Cxx_lex_init_ALREADY_DEFINED
128 : #else
129 : #define yylex_init Rose_C_Cxx_lex_init
130 : #endif
131 :
132 : #ifdef yylex_init_extra
133 : #define Rose_C_Cxx_lex_init_extra_ALREADY_DEFINED
134 : #else
135 : #define yylex_init_extra Rose_C_Cxx_lex_init_extra
136 : #endif
137 :
138 : #ifdef yylex_destroy
139 : #define Rose_C_Cxx_lex_destroy_ALREADY_DEFINED
140 : #else
141 : #define yylex_destroy Rose_C_Cxx_lex_destroy
142 : #endif
143 :
144 : #ifdef yyget_debug
145 : #define Rose_C_Cxx_get_debug_ALREADY_DEFINED
146 : #else
147 : #define yyget_debug Rose_C_Cxx_get_debug
148 : #endif
149 :
150 : #ifdef yyset_debug
151 : #define Rose_C_Cxx_set_debug_ALREADY_DEFINED
152 : #else
153 : #define yyset_debug Rose_C_Cxx_set_debug
154 : #endif
155 :
156 : #ifdef yyget_extra
157 : #define Rose_C_Cxx_get_extra_ALREADY_DEFINED
158 : #else
159 : #define yyget_extra Rose_C_Cxx_get_extra
160 : #endif
161 :
162 : #ifdef yyset_extra
163 : #define Rose_C_Cxx_set_extra_ALREADY_DEFINED
164 : #else
165 : #define yyset_extra Rose_C_Cxx_set_extra
166 : #endif
167 :
168 : #ifdef yyget_in
169 : #define Rose_C_Cxx_get_in_ALREADY_DEFINED
170 : #else
171 : #define yyget_in Rose_C_Cxx_get_in
172 : #endif
173 :
174 : #ifdef yyset_in
175 : #define Rose_C_Cxx_set_in_ALREADY_DEFINED
176 : #else
177 : #define yyset_in Rose_C_Cxx_set_in
178 : #endif
179 :
180 : #ifdef yyget_out
181 : #define Rose_C_Cxx_get_out_ALREADY_DEFINED
182 : #else
183 : #define yyget_out Rose_C_Cxx_get_out
184 : #endif
185 :
186 : #ifdef yyset_out
187 : #define Rose_C_Cxx_set_out_ALREADY_DEFINED
188 : #else
189 : #define yyset_out Rose_C_Cxx_set_out
190 : #endif
191 :
192 : #ifdef yyget_leng
193 : #define Rose_C_Cxx_get_leng_ALREADY_DEFINED
194 : #else
195 : #define yyget_leng Rose_C_Cxx_get_leng
196 : #endif
197 :
198 : #ifdef yyget_text
199 : #define Rose_C_Cxx_get_text_ALREADY_DEFINED
200 : #else
201 : #define yyget_text Rose_C_Cxx_get_text
202 : #endif
203 :
204 : #ifdef yyget_lineno
205 : #define Rose_C_Cxx_get_lineno_ALREADY_DEFINED
206 : #else
207 : #define yyget_lineno Rose_C_Cxx_get_lineno
208 : #endif
209 :
210 : #ifdef yyset_lineno
211 : #define Rose_C_Cxx_set_lineno_ALREADY_DEFINED
212 : #else
213 : #define yyset_lineno Rose_C_Cxx_set_lineno
214 : #endif
215 :
216 : #ifdef yywrap
217 : #define Rose_C_Cxx_wrap_ALREADY_DEFINED
218 : #else
219 : #define yywrap Rose_C_Cxx_wrap
220 : #endif
221 :
222 : #ifdef yyalloc
223 : #define Rose_C_Cxx_alloc_ALREADY_DEFINED
224 : #else
225 : #define yyalloc Rose_C_Cxx_alloc
226 : #endif
227 :
228 : #ifdef yyrealloc
229 : #define Rose_C_Cxx_realloc_ALREADY_DEFINED
230 : #else
231 : #define yyrealloc Rose_C_Cxx_realloc
232 : #endif
233 :
234 : #ifdef yyfree
235 : #define Rose_C_Cxx_free_ALREADY_DEFINED
236 : #else
237 : #define yyfree Rose_C_Cxx_free
238 : #endif
239 :
240 : #ifdef yytext
241 : #define Rose_C_Cxx_text_ALREADY_DEFINED
242 : #else
243 : #define yytext Rose_C_Cxx_text
244 : #endif
245 :
246 : #ifdef yyleng
247 : #define Rose_C_Cxx_leng_ALREADY_DEFINED
248 : #else
249 : #define yyleng Rose_C_Cxx_leng
250 : #endif
251 :
252 : #ifdef yyin
253 : #define Rose_C_Cxx_in_ALREADY_DEFINED
254 : #else
255 : #define yyin Rose_C_Cxx_in
256 : #endif
257 :
258 : #ifdef yyout
259 : #define Rose_C_Cxx_out_ALREADY_DEFINED
260 : #else
261 : #define yyout Rose_C_Cxx_out
262 : #endif
263 :
264 : #ifdef yy_flex_debug
265 : #define Rose_C_Cxx__flex_debug_ALREADY_DEFINED
266 : #else
267 : #define yy_flex_debug Rose_C_Cxx__flex_debug
268 : #endif
269 :
270 : #ifdef yylineno
271 : #define Rose_C_Cxx_lineno_ALREADY_DEFINED
272 : #else
273 : #define yylineno Rose_C_Cxx_lineno
274 : #endif
275 :
276 : /* First, we deal with platform-specific or compiler-specific issues. */
277 :
278 : /* begin standard C headers. */
279 : #include <stdio.h>
280 : #include <string.h>
281 : #include <errno.h>
282 : #include <stdlib.h>
283 :
284 : /* end standard C headers. */
285 :
286 : /* flex integer type definitions */
287 :
288 : #ifndef FLEXINT_H
289 : #define FLEXINT_H
290 :
291 : /* C99 systems have <inttypes.h>. Non-C99 systems may or may not. */
292 :
293 : #if defined (__STDC_VERSION__) && __STDC_VERSION__ >= 199901L
294 :
295 : /* C99 says to define __STDC_LIMIT_MACROS before including stdint.h,
296 : * if you want the limit (max/min) macros for int types.
297 : */
298 : #ifndef __STDC_LIMIT_MACROS
299 : #define __STDC_LIMIT_MACROS 1
300 : #endif
301 :
302 : #include <inttypes.h>
303 : typedef int8_t flex_int8_t;
304 : typedef uint8_t flex_uint8_t;
305 : typedef int16_t flex_int16_t;
306 : typedef uint16_t flex_uint16_t;
307 : typedef int32_t flex_int32_t;
308 : typedef uint32_t flex_uint32_t;
309 : #else
310 : typedef signed char flex_int8_t;
311 : typedef short int flex_int16_t;
312 : typedef int flex_int32_t;
313 : typedef unsigned char flex_uint8_t;
314 : typedef unsigned short int flex_uint16_t;
315 : typedef unsigned int flex_uint32_t;
316 :
317 : /* Limits of integral types. */
318 : #ifndef INT8_MIN
319 : #define INT8_MIN (-128)
320 : #endif
321 : #ifndef INT16_MIN
322 : #define INT16_MIN (-32767-1)
323 : #endif
324 : #ifndef INT32_MIN
325 : #define INT32_MIN (-2147483647-1)
326 : #endif
327 : #ifndef INT8_MAX
328 : #define INT8_MAX (127)
329 : #endif
330 : #ifndef INT16_MAX
331 : #define INT16_MAX (32767)
332 : #endif
333 : #ifndef INT32_MAX
334 : #define INT32_MAX (2147483647)
335 : #endif
336 : #ifndef UINT8_MAX
337 : #define UINT8_MAX (255U)
338 : #endif
339 : #ifndef UINT16_MAX
340 : #define UINT16_MAX (65535U)
341 : #endif
342 : #ifndef UINT32_MAX
343 : #define UINT32_MAX (4294967295U)
344 : #endif
345 :
346 : #ifndef SIZE_MAX
347 : #define SIZE_MAX (~(size_t)0)
348 : #endif
349 :
350 : #endif /* ! C99 */
351 :
352 : #endif /* ! FLEXINT_H */
353 :
354 : /* begin standard C++ headers. */
355 :
356 : /* TODO: this is always defined, so inline it */
357 : #define yyconst const
358 :
359 : #if defined(__GNUC__) && __GNUC__ >= 3
360 : #define yynoreturn __attribute__((__noreturn__))
361 : #else
362 : #define yynoreturn
363 : #endif
364 :
365 : /* Returned upon end-of-file. */
366 : #define YY_NULL 0
367 :
368 : /* Promotes a possibly negative, possibly signed char to an
369 : * integer in range [0..255] for use as an array index.
370 : */
371 : #define YY_SC_TO_UI(c) ((YY_CHAR) (c))
372 :
373 : /* Enter a start condition. This macro really ought to take a parameter,
374 : * but we do it the disgusting crufty way forced on us by the ()-less
375 : * definition of BEGIN.
376 : */
377 : #define BEGIN (yy_start) = 1 + 2 *
378 : /* Translate the current start state into a value that can be later handed
379 : * to BEGIN to return to the state. The YYSTATE alias is for lex
380 : * compatibility.
381 : */
382 : #define YY_START (((yy_start) - 1) / 2)
383 : #define YYSTATE YY_START
384 : /* Action number for EOF rule of a given start state. */
385 : #define YY_STATE_EOF(state) (YY_END_OF_BUFFER + state + 1)
386 : /* Special action meaning "start processing a new file". */
387 : #define YY_NEW_FILE yyrestart( yyin )
388 : #define YY_END_OF_BUFFER_CHAR 0
389 :
390 : /* Size of default input buffer. */
391 : #ifndef YY_BUF_SIZE
392 : #ifdef __ia64__
393 : /* On IA-64, the buffer size is 16k, not 8k.
394 : * Moreover, YY_BUF_SIZE is 2*YY_READ_BUF_SIZE in the general case.
395 : * Ditto for the __ia64__ case accordingly.
396 : */
397 : #define YY_BUF_SIZE 32768
398 : #else
399 : #define YY_BUF_SIZE 16384
400 : #endif /* __ia64__ */
401 : #endif
402 :
403 : /* The state buf must be large enough to hold one state per character in the main buffer.
404 : */
405 : #define YY_STATE_BUF_SIZE ((YY_BUF_SIZE + 2) * sizeof(yy_state_type))
406 :
407 : #ifndef YY_TYPEDEF_YY_BUFFER_STATE
408 : #define YY_TYPEDEF_YY_BUFFER_STATE
409 : typedef struct yy_buffer_state *YY_BUFFER_STATE;
410 : #endif
411 :
412 : #ifndef YY_TYPEDEF_YY_SIZE_T
413 : #define YY_TYPEDEF_YY_SIZE_T
414 : typedef size_t yy_size_t;
415 : #endif
416 :
417 : extern int yyleng;
418 :
419 : extern FILE *yyin, *yyout;
420 :
421 : #define EOB_ACT_CONTINUE_SCAN 0
422 : #define EOB_ACT_END_OF_FILE 1
423 : #define EOB_ACT_LAST_MATCH 2
424 :
425 : #define YY_LESS_LINENO(n)
426 : #define YY_LINENO_REWIND_TO(ptr)
427 :
428 : /* Return all but the first "n" matched characters back to the input stream. */
429 : #define yyless(n) \
430 : do \
431 : { \
432 : /* Undo effects of setting up yytext. */ \
433 : int yyless_macro_arg = (n); \
434 : YY_LESS_LINENO(yyless_macro_arg);\
435 : *yy_cp = (yy_hold_char); \
436 : YY_RESTORE_YY_MORE_OFFSET \
437 : (yy_c_buf_p) = yy_cp = yy_bp + yyless_macro_arg - YY_MORE_ADJ; \
438 : YY_DO_BEFORE_ACTION; /* set up yytext again */ \
439 : } \
440 : while ( 0 )
441 : #define unput(c) yyunput( c, (yytext_ptr) )
442 :
443 : #ifndef YY_STRUCT_YY_BUFFER_STATE
444 : #define YY_STRUCT_YY_BUFFER_STATE
445 : struct yy_buffer_state
446 : {
447 : FILE *yy_input_file;
448 :
449 : char *yy_ch_buf; /* input buffer */
450 : char *yy_buf_pos; /* current position in input buffer */
451 :
452 : /* Size of input buffer in bytes, not including room for EOB
453 : * characters.
454 : */
455 : int yy_buf_size;
456 :
457 : /* Number of characters read into yy_ch_buf, not including EOB
458 : * characters.
459 : */
460 : int yy_n_chars;
461 :
462 : /* Whether we "own" the buffer - i.e., we know we created it,
463 : * and can realloc() it to grow it, and should free() it to
464 : * delete it.
465 : */
466 : int yy_is_our_buffer;
467 :
468 : /* Whether this is an "interactive" input source; if so, and
469 : * if we're using stdio for input, then we want to use getc()
470 : * instead of fread(), to make sure we stop fetching input after
471 : * each newline.
472 : */
473 : int yy_is_interactive;
474 :
475 : /* Whether we're considered to be at the beginning of a line.
476 : * If so, '^' rules will be active on the next match, otherwise
477 : * not.
478 : */
479 : int yy_at_bol;
480 :
481 : int yy_bs_lineno; /**< The line count. */
482 : int yy_bs_column; /**< The column count. */
483 :
484 : /* Whether to try to fill the input buffer when we reach the
485 : * end of it.
486 : */
487 : int yy_fill_buffer;
488 :
489 : int yy_buffer_status;
490 :
491 : #define YY_BUFFER_NEW 0
492 : #define YY_BUFFER_NORMAL 1
493 : /* When an EOF's been seen but there's still some text to process
494 : * then we mark the buffer as YY_EOF_PENDING, to indicate that we
495 : * shouldn't try reading from the input source any more. We might
496 : * still have a bunch of tokens to match, though, because of
497 : * possible backing-up.
498 : *
499 : * When we actually see the EOF, we change the status to "new"
500 : * (via yyrestart()), so that the user can continue scanning by
501 : * just pointing yyin at a new input file.
502 : */
503 : #define YY_BUFFER_EOF_PENDING 2
504 :
505 : };
506 : #endif /* !YY_STRUCT_YY_BUFFER_STATE */
507 :
508 : /* Stack of input buffers. */
509 : static size_t yy_buffer_stack_top = 0; /**< index of top of stack. */
510 : static size_t yy_buffer_stack_max = 0; /**< capacity of stack. */
511 : static YY_BUFFER_STATE * yy_buffer_stack = NULL; /**< Stack as an array. */
512 :
513 : /* We provide macros for accessing buffer states in case in the
514 : * future we want to put the buffer states in a more general
515 : * "scanner state".
516 : *
517 : * Returns the top of the stack, or NULL.
518 : */
519 : #define YY_CURRENT_BUFFER ( (yy_buffer_stack) \
520 : ? (yy_buffer_stack)[(yy_buffer_stack_top)] \
521 : : NULL)
522 : /* Same as previous macro, but useful when we know that the buffer stack is not
523 : * NULL or when we need an lvalue. For internal use only.
524 : */
525 : #define YY_CURRENT_BUFFER_LVALUE (yy_buffer_stack)[(yy_buffer_stack_top)]
526 :
527 : /* yy_hold_char holds the character lost when yytext is formed. */
528 : static char yy_hold_char;
529 : static int yy_n_chars; /* number of characters read into yy_ch_buf */
530 : int yyleng;
531 :
532 : /* Points to current character in buffer. */
533 : static char *yy_c_buf_p = NULL;
534 : static int yy_init = 0; /* whether we need to initialize */
535 : static int yy_start = 0; /* start state number */
536 :
537 : /* Flag which is used to allow yywrap()'s to do buffer switches
538 : * instead of setting up a fresh yyin. A bit of a hack ...
539 : */
540 : static int yy_did_buffer_switch_on_eof;
541 :
542 : void yyrestart ( FILE *input_file );
543 : void yy_switch_to_buffer ( YY_BUFFER_STATE new_buffer );
544 : YY_BUFFER_STATE yy_create_buffer ( FILE *file, int size );
545 : void yy_delete_buffer ( YY_BUFFER_STATE b );
546 : void yy_flush_buffer ( YY_BUFFER_STATE b );
547 : void yypush_buffer_state ( YY_BUFFER_STATE new_buffer );
548 : void yypop_buffer_state ( void );
549 :
550 : static void yyensure_buffer_stack ( void );
551 : static void yy_load_buffer_state ( void );
552 : static void yy_init_buffer ( YY_BUFFER_STATE b, FILE *file );
553 : #define YY_FLUSH_BUFFER yy_flush_buffer( YY_CURRENT_BUFFER )
554 :
555 : YY_BUFFER_STATE yy_scan_buffer ( char *base, yy_size_t size );
556 : YY_BUFFER_STATE yy_scan_string ( const char *yy_str );
557 : YY_BUFFER_STATE yy_scan_bytes ( const char *bytes, int len );
558 :
559 : void *yyalloc ( yy_size_t );
560 : void *yyrealloc ( void *, yy_size_t );
561 : void yyfree ( void * );
562 :
563 : #define yy_new_buffer yy_create_buffer
564 : #define yy_set_interactive(is_interactive) \
565 : { \
566 : if ( ! YY_CURRENT_BUFFER ){ \
567 : yyensure_buffer_stack (); \
568 : YY_CURRENT_BUFFER_LVALUE = \
569 : yy_create_buffer( yyin, YY_BUF_SIZE ); \
570 : } \
571 : YY_CURRENT_BUFFER_LVALUE->yy_is_interactive = is_interactive; \
572 : }
573 : #define yy_set_bol(at_bol) \
574 : { \
575 : if ( ! YY_CURRENT_BUFFER ){\
576 : yyensure_buffer_stack (); \
577 : YY_CURRENT_BUFFER_LVALUE = \
578 : yy_create_buffer( yyin, YY_BUF_SIZE ); \
579 : } \
580 : YY_CURRENT_BUFFER_LVALUE->yy_at_bol = at_bol; \
581 : }
582 : #define YY_AT_BOL() (YY_CURRENT_BUFFER_LVALUE->yy_at_bol)
583 :
584 : /* Begin user sect3 */
585 :
586 : #define Rose_C_Cxx_wrap() (/*CONSTCOND*/1)
587 : #define YY_SKIP_YYWRAP
588 : typedef flex_uint8_t YY_CHAR;
589 :
590 : FILE *yyin = NULL, *yyout = NULL;
591 :
592 : typedef int yy_state_type;
593 :
594 : extern int yylineno;
595 : int yylineno = 1;
596 :
597 : extern char *yytext;
598 : #ifdef yytext_ptr
599 : #undef yytext_ptr
600 : #endif
601 : #define yytext_ptr yytext
602 :
603 : static yy_state_type yy_get_previous_state ( void );
604 : static yy_state_type yy_try_NUL_trans ( yy_state_type current_state );
605 : static int yy_get_next_buffer ( void );
606 : static void yynoreturn yy_fatal_error ( const char* msg );
607 :
608 : /* Done after the current pattern has been matched and before the
609 : * corresponding action - sets up yytext.
610 : */
611 : #define YY_DO_BEFORE_ACTION \
612 : (yytext_ptr) = yy_bp; \
613 : yyleng = (int) (yy_cp - yy_bp); \
614 : (yy_hold_char) = *yy_cp; \
615 : *yy_cp = '\0'; \
616 : (yy_c_buf_p) = yy_cp;
617 : #define YY_NUM_RULES 95
618 : #define YY_END_OF_BUFFER 96
619 : /* This struct is not used in this scanner,
620 : but its presence is necessary. */
621 : struct yy_trans_info
622 : {
623 : flex_int32_t yy_verify;
624 : flex_int32_t yy_nxt;
625 : };
626 : static const flex_int16_t yy_accept[207] =
627 : { 0,
628 : 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
629 : 0, 0, 0, 0, 0, 0, 0, 0, 96, 95,
630 : 57, 37, 54, 1, 57, 19, 55, 33, 12, 15,
631 : 56, 6, 7, 17, 30, 9, 29, 11, 18, 34,
632 : 34, 10, 8, 35, 28, 36, 16, 38, 31, 32,
633 : 13, 4, 20, 5, 14, 37, 33, 38, 72, 75,
634 : 95, 78, 76, 78, 69, 70, 95, 71, 95, 61,
635 : 63, 95, 64, 95, 84, 81, 82, 84, 84, 94,
636 : 93, 94, 89, 90, 95, 91, 95, 37, 2, 24,
637 : 21, 22, 23, 40, 39, 0, 34, 0, 26, 27,
638 :
639 : 38, 25, 37, 0, 0, 0, 0, 0, 0, 0,
640 : 0, 0, 0, 38, 73, 74, 77, 68, 67, 66,
641 : 67, 62, 60, 59, 60, 83, 80, 0, 92, 88,
642 : 87, 86, 87, 34, 0, 0, 0, 0, 0, 46,
643 : 0, 0, 0, 0, 0, 38, 65, 58, 79, 85,
644 : 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
645 : 0, 0, 0, 38, 0, 0, 49, 50, 0, 0,
646 : 0, 0, 0, 44, 0, 0, 0, 38, 0, 0,
647 : 51, 45, 47, 0, 0, 0, 43, 0, 38, 0,
648 : 42, 48, 0, 53, 0, 0, 0, 41, 52, 0,
649 :
650 : 0, 0, 0, 3, 0, 0
651 : } ;
652 :
653 : static const YY_CHAR yy_ec[256] =
654 : { 0,
655 : 1, 1, 1, 1, 1, 1, 1, 1, 2, 3,
656 : 4, 5, 6, 1, 1, 1, 1, 1, 1, 1,
657 : 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
658 : 1, 2, 7, 8, 9, 1, 10, 11, 12, 13,
659 : 14, 15, 16, 17, 18, 19, 20, 21, 22, 22,
660 : 22, 22, 22, 22, 22, 22, 22, 23, 24, 25,
661 : 26, 27, 28, 1, 29, 29, 30, 29, 29, 29,
662 : 29, 29, 29, 29, 29, 29, 29, 29, 29, 29,
663 : 29, 29, 29, 29, 29, 29, 29, 29, 29, 29,
664 : 31, 32, 33, 34, 29, 1, 35, 36, 37, 38,
665 :
666 : 39, 40, 41, 29, 42, 29, 29, 43, 44, 45,
667 : 46, 47, 29, 48, 49, 50, 51, 29, 52, 53,
668 : 29, 29, 54, 55, 56, 57, 1, 1, 1, 1,
669 : 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
670 : 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
671 : 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
672 : 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
673 : 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
674 : 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
675 : 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
676 :
677 : 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
678 : 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
679 : 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
680 : 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
681 : 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
682 : 1, 1, 1, 1, 1
683 : } ;
684 :
685 : static const YY_CHAR yy_meta[58] =
686 : { 0,
687 : 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
688 : 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
689 : 2, 2, 1, 1, 1, 1, 1, 1, 2, 2,
690 : 1, 1, 1, 1, 2, 2, 2, 2, 2, 2,
691 : 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
692 : 2, 2, 2, 1, 1, 1, 1
693 : } ;
694 :
695 : static const flex_int16_t yy_base[220] =
696 : { 0,
697 : 0, 0, 0, 56, 56, 57, 58, 59, 60, 61,
698 : 69, 73, 74, 83, 68, 75, 94, 101, 292, 293,
699 : 293, 289, 293, 293, 287, 263, 293, 293, 293, 293,
700 : 293, 293, 293, 293, 272, 293, 69, 293, 93, 98,
701 : 100, 293, 293, 261, 293, 260, 293, 0, 293, 293,
702 : 293, 293, 259, 293, 293, 109, 114, 231, 293, 293,
703 : 280, 293, 293, 262, 293, 293, 278, 293, 111, 293,
704 : 293, 277, 293, 121, 293, 293, 293, 264, 122, 293,
705 : 293, 258, 293, 293, 274, 293, 126, 274, 293, 293,
706 : 293, 293, 293, 293, 293, 77, 118, 114, 293, 293,
707 :
708 : 0, 293, 129, 135, 197, 141, 210, 99, 101, 206,
709 : 199, 200, 209, 193, 293, 293, 293, 293, 293, 293,
710 : 239, 293, 293, 293, 238, 293, 293, 237, 293, 293,
711 : 293, 293, 236, 133, 188, 197, 118, 198, 187, 124,
712 : 197, 188, 197, 193, 182, 190, 293, 293, 293, 293,
713 : 189, 185, 186, 186, 182, 177, 183, 183, 177, 180,
714 : 177, 178, 171, 167, 166, 168, 293, 293, 172, 163,
715 : 170, 170, 157, 293, 163, 166, 163, 159, 146, 151,
716 : 293, 293, 293, 149, 147, 137, 293, 114, 156, 168,
717 : 293, 293, 111, 293, 108, 173, 93, 293, 293, 155,
718 :
719 : 192, 68, 197, 293, 72, 293, 251, 253, 255, 257,
720 : 259, 261, 263, 265, 68, 267, 269, 271, 273
721 : } ;
722 :
723 : static const flex_int16_t yy_def[220] =
724 : { 0,
725 : 207, 207, 206, 3, 208, 208, 209, 209, 210, 210,
726 : 211, 211, 212, 212, 213, 213, 214, 214, 206, 206,
727 : 206, 206, 206, 206, 206, 206, 206, 206, 206, 206,
728 : 206, 206, 206, 206, 206, 206, 206, 206, 206, 206,
729 : 206, 206, 206, 206, 206, 206, 206, 215, 206, 206,
730 : 206, 206, 206, 206, 206, 206, 206, 215, 206, 206,
731 : 216, 206, 206, 206, 206, 206, 206, 206, 217, 206,
732 : 206, 206, 206, 218, 206, 206, 206, 206, 206, 206,
733 : 206, 206, 206, 206, 206, 206, 219, 206, 206, 206,
734 : 206, 206, 206, 206, 206, 206, 206, 206, 206, 206,
735 :
736 : 215, 206, 206, 206, 206, 206, 206, 206, 206, 206,
737 : 206, 206, 206, 215, 206, 206, 206, 206, 206, 206,
738 : 206, 206, 206, 206, 206, 206, 206, 206, 206, 206,
739 : 206, 206, 206, 206, 206, 206, 206, 206, 206, 206,
740 : 206, 206, 206, 206, 206, 215, 206, 206, 206, 206,
741 : 206, 206, 206, 206, 206, 206, 206, 206, 206, 206,
742 : 206, 206, 206, 215, 206, 206, 206, 206, 206, 206,
743 : 206, 206, 206, 206, 206, 206, 206, 215, 206, 206,
744 : 206, 206, 206, 206, 206, 206, 206, 206, 215, 206,
745 : 206, 206, 206, 206, 206, 206, 206, 206, 206, 206,
746 :
747 : 206, 206, 206, 206, 206, 0, 206, 206, 206, 206,
748 : 206, 206, 206, 206, 206, 206, 206, 206, 206
749 : } ;
750 :
751 : static const flex_int16_t yy_nxt[351] =
752 : { 0,
753 : 21, 22, 23, 21, 24, 25, 26, 27, 28, 29,
754 : 30, 31, 32, 33, 34, 35, 36, 37, 38, 39,
755 : 40, 41, 42, 43, 44, 45, 46, 47, 48, 48,
756 : 49, 21, 50, 51, 48, 48, 48, 48, 48, 48,
757 : 48, 48, 48, 48, 48, 48, 48, 48, 48, 48,
758 : 48, 48, 48, 52, 53, 54, 55, 56, 60, 60,
759 : 63, 63, 66, 66, 57, 67, 67, 68, 68, 101,
760 : 81, 71, 64, 64, 72, 71, 76, 81, 72, 201,
761 : 73, 77, 82, 205, 73, 76, 92, 61, 61, 82,
762 : 77, 69, 69, 78, 58, 93, 84, 134, 134, 85,
763 :
764 : 74, 86, 78, 84, 74, 79, 85, 94, 86, 96,
765 : 103, 96, 95, 120, 79, 106, 121, 104, 97, 97,
766 : 97, 97, 200, 124, 127, 87, 125, 128, 132, 96,
767 : 103, 133, 87, 98, 97, 97, 106, 104, 97, 97,
768 : 140, 137, 106, 138, 96, 141, 139, 105, 199, 198,
769 : 98, 107, 108, 134, 134, 109, 110, 196, 195, 153,
770 : 111, 157, 201, 197, 112, 113, 154, 105, 158, 196,
771 : 202, 194, 107, 108, 196, 197, 109, 110, 107, 108,
772 : 197, 111, 109, 110, 193, 112, 113, 111, 192, 191,
773 : 190, 112, 113, 203, 203, 203, 203, 203, 203, 203,
774 :
775 : 203, 203, 203, 189, 188, 187, 186, 185, 184, 183,
776 : 182, 181, 180, 179, 178, 177, 176, 175, 174, 173,
777 : 172, 171, 170, 169, 168, 167, 166, 165, 164, 163,
778 : 162, 161, 160, 159, 156, 155, 152, 151, 150, 149,
779 : 148, 147, 146, 145, 144, 204, 143, 142, 136, 135,
780 : 204, 20, 20, 59, 59, 62, 62, 65, 65, 70,
781 : 70, 75, 75, 80, 80, 83, 83, 115, 115, 119,
782 : 119, 123, 123, 131, 131, 88, 130, 129, 126, 122,
783 : 118, 117, 116, 114, 102, 100, 99, 91, 90, 89,
784 : 88, 206, 19, 206, 206, 206, 206, 206, 206, 206,
785 :
786 : 206, 206, 206, 206, 206, 206, 206, 206, 206, 206,
787 : 206, 206, 206, 206, 206, 206, 206, 206, 206, 206,
788 : 206, 206, 206, 206, 206, 206, 206, 206, 206, 206,
789 : 206, 206, 206, 206, 206, 206, 206, 206, 206, 206,
790 : 206, 206, 206, 206, 206, 206, 206, 206, 206, 206
791 : } ;
792 :
793 : static const flex_int16_t yy_chk[351] =
794 : { 0,
795 : 3, 3, 3, 3, 3, 3, 3, 3, 3, 3,
796 : 3, 3, 3, 3, 3, 3, 3, 3, 3, 3,
797 : 3, 3, 3, 3, 3, 3, 3, 3, 3, 3,
798 : 3, 3, 3, 3, 3, 3, 3, 3, 3, 3,
799 : 3, 3, 3, 3, 3, 3, 3, 3, 3, 3,
800 : 3, 3, 3, 3, 3, 3, 3, 4, 5, 6,
801 : 7, 8, 9, 10, 4, 9, 10, 9, 10, 215,
802 : 15, 11, 7, 8, 11, 12, 13, 16, 12, 205,
803 : 11, 13, 15, 202, 12, 14, 37, 5, 6, 16,
804 : 14, 9, 10, 13, 4, 37, 17, 96, 96, 17,
805 :
806 : 11, 17, 14, 18, 12, 13, 18, 39, 18, 40,
807 : 56, 41, 39, 69, 14, 57, 69, 56, 40, 40,
808 : 41, 41, 197, 74, 79, 17, 74, 79, 87, 97,
809 : 103, 87, 18, 40, 98, 98, 104, 103, 97, 97,
810 : 109, 108, 106, 108, 134, 109, 108, 56, 195, 193,
811 : 40, 57, 57, 134, 134, 57, 57, 189, 188, 137,
812 : 57, 140, 200, 189, 57, 57, 137, 103, 140, 190,
813 : 200, 186, 104, 104, 196, 190, 104, 104, 106, 106,
814 : 196, 104, 106, 106, 185, 104, 104, 106, 184, 180,
815 : 179, 106, 106, 201, 201, 201, 201, 201, 203, 203,
816 :
817 : 203, 203, 203, 178, 177, 176, 175, 173, 172, 171,
818 : 170, 169, 166, 165, 164, 163, 162, 161, 160, 159,
819 : 158, 157, 156, 155, 154, 153, 152, 151, 146, 145,
820 : 144, 143, 142, 141, 139, 138, 136, 135, 133, 128,
821 : 125, 121, 114, 113, 112, 201, 111, 110, 107, 105,
822 : 203, 207, 207, 208, 208, 209, 209, 210, 210, 211,
823 : 211, 212, 212, 213, 213, 214, 214, 216, 216, 217,
824 : 217, 218, 218, 219, 219, 88, 85, 82, 78, 72,
825 : 67, 64, 61, 58, 53, 46, 44, 35, 26, 25,
826 : 22, 19, 206, 206, 206, 206, 206, 206, 206, 206,
827 :
828 : 206, 206, 206, 206, 206, 206, 206, 206, 206, 206,
829 : 206, 206, 206, 206, 206, 206, 206, 206, 206, 206,
830 : 206, 206, 206, 206, 206, 206, 206, 206, 206, 206,
831 : 206, 206, 206, 206, 206, 206, 206, 206, 206, 206,
832 : 206, 206, 206, 206, 206, 206, 206, 206, 206, 206
833 : } ;
834 :
835 : static yy_state_type yy_last_accepting_state;
836 : static char *yy_last_accepting_cpos;
837 :
838 : extern int yy_flex_debug;
839 : int yy_flex_debug = 0;
840 :
841 : /* The intent behind this definition is that it'll catch
842 : * any uses of REJECT which flex missed.
843 : */
844 : #define REJECT reject_used_but_not_detected
845 : #define yymore() yymore_used_but_not_detected
846 : #define YY_MORE_ADJ 0
847 : #define YY_RESTORE_YY_MORE_OFFSET
848 : char *yytext;
849 : #line 1 "../../../../rexompiler/src/frontend/SageIII/preproc-c.ll"
850 : #line 6 "../../../../rexompiler/src/frontend/SageIII/preproc-c.ll"
851 : /*
852 : preproc.lex: This lexer currently recognizes C style comments, C++ style
853 : comments, preprocessor directives, and c/c++ linkage specifications.
854 : line/column/text information for each recognized directive is stored in
855 : ROSEAttributesList. This information is used by the unparser.
856 : */
857 :
858 : /*
859 : -------------------------------------------------------------------------------------
860 : Originally written and modified by Markus Schordan and Dan Quinlan.
861 : (see ChangeLog).
862 :
863 : 08-05-2006: Rewritten significantly by Ramakrishna Upadrasta.
864 : Reason: For supporting additional features and bug-fixing (see summary below).
865 : Note: The old preproc.lex is available in the same directory as preproc.original.lex
866 : ------------------------------------------------------------------------------------
867 : */
868 : //Ramakrishna Upadrasta
869 : //01-12-07: This is only version 0 of this file
870 :
871 :
872 : /*
873 : Summary of the changes:
874 : =========================================================================================
875 : The regular expressions (and the action code) for C++ comments and
876 : C style comments has been cleaned up and are (hopefully:) upto the standard.
877 : =========================================================================================
878 : Naming of variables:
879 : changed the lex variable names (states/start conditions) so that
880 : CXX_COMMENT to corresponds to C++ style comments (beginning with //) and
881 : C_COMMENT to correspond to C-style comments (enclosed by / * and * / ).
882 : Earlier they were
883 : C_COMMENT corresponded to C++ style comments
884 : CPP_COMMENT corresponded to C-style comments.
885 : It was felt that the names were confusing.
886 : The other choice was to name the C-style comments as C_COMMENT and C++ style
887 : comments as CPP_COMMENT as in Wave. That was also found to be confusing, as CPP usually
888 : means C Pre Processor). The new terminology is (partly) taken from makefiles which
889 : allows 3 types of flags (C_FLAGS/CPP_FLAGS/CXX_FLAGS).
890 :
891 : =========================================================================================
892 : Use STL types for instead of fixed size buffers for the following data structures
893 : commentString, macroString and bracestack. (earlier they were
894 : char commentString[10000000] for comments
895 : char macroString[10000000] for macro strings
896 : and char bracestack[500] for matching of braces)
897 : =========================================================================================
898 : Exact Position information for literals
899 : The previous method to get the position information from EDG is incorrect in
900 : most of the cases. A second scan (like this lexer does) of the input was thought
901 : to be necessary to attach additional info.
902 : =========================================================================================
903 : Support for char literals
904 : including the '\e' '\U' which would be part of 2008 standard
905 : refer to ???? for details
906 : =========================================================================================
907 : Semi colons
908 : We have to ensure that semi colons for that donot actually end
909 : statements are taken care of carefully.
910 : class A {
911 : f(); <-- this semi colon should be taken care of carefully.
912 : }
913 : =========================================================================================
914 : Double colons (::'s)
915 : They can only occur in .........
916 : we identify them with
917 : =========================================================================================
918 : trigraphs
919 :
920 : =========================================================================================
921 : backslashes followed by newlines
922 : Either inside or outside of comments
923 : =========================================================================================
924 : Whitespace info:
925 : The
926 :
927 : =========================================================================================
928 : Line number information:
929 : A better line count
930 :
931 : =========================================================================================
932 : Trigraphs/Digraphs
933 : =========================================================================================
934 : Proper identification and matching of different varieties of brackets
935 : Parenthesis ()
936 : Curly braces {}: The support for this existed earlier
937 : Square brackets []
938 : =========================================================================================
939 : Support for keywords
940 : C++
941 : C
942 : C99
943 : C++Ox
944 : Ones only in
945 : =========================================================================================
946 : To be done in CHAR literals
947 : wierd char literals
948 : testing for octal and hex char literals
949 : testing for backslashes in char literals.
950 : To be done in INT literals
951 : testing for
952 : =========================================================================================
953 : Limitations/open questions:
954 : This lexer does not handle lots of important cases, like
955 : character literals etc.
956 : Trigraph sequences, alternative tokens (lex.trigraph and lex.digraph of the standard).
957 : hexadecimal floating point literals and similar arcane stuff
958 : (HOW DOES EDG handle them? How does Wave handle them?)
959 : The user should probably use the wave workaround (does it support these?????), if she needs such things.
960 : =========================================================================================
961 : Use of standard variable names like ([:space:] and [:blank:]) that come with FLEX.
962 : Read the flex http://www.gnu.org/software/flex/manual/ for details. They work like C functions
963 : isspace and isblank respectively.
964 : =========================================================================================
965 : =========================================================================================
966 : A ROSE-sequence point in the original program is a position in the input program where
967 : synchronization of the AST happens with the input program. For now, the sequence points
968 : are specific lexical tokens in the input program. In specific, they are
969 : parenthesis: ()
970 : curly braces: {}
971 : semi colons: ;
972 : new lines: \n
973 : The possible are contenders for being sequence points
974 : keywords???
975 :
976 :
977 : Sequence points of the program so that exact code generation is done
978 : If the code is not transformed? we synchronize the code generation
979 : If the code is transformed, we synchronize the code generation immediately after the next sequence point.
980 :
981 : An extension to the above token/character based sequence-points is to use parsing-constructs in the
982 : the grammar of the source language, like
983 : end of statement-sequence
984 : end of function/class/namespace definition
985 : =========================================================================================
986 : ellipsis????
987 :
988 : =========================================================================================
989 : =========================================================================================
990 : =========================================================================================
991 : Notes about coding style:
992 : There is a unsaid tradition of separating the patterns and the actions in LEX files by tabs.
993 : I am using that, though Dan prefers that whitespace be used for indentation.
994 : */
995 :
996 : /*
997 : Test cases these (atleast fix) and effect:
998 : test2005_170.C about the buffer size of (C and C++ style) comments.
999 : test2001_18.C (and its related files: test2001_18A.h and test2001_18B.h): which is about the includes having code segments??????????????
1000 : test2006_15.C: which is about the handling of the character literals.
1001 : test2005_184.C: which is about handling of backslashes at the end of C++ style comments
1002 : -------------------
1003 : test2005_131.C
1004 : The ones that have singlequotes in a IF(0) and were earlier preprocessed silently, but are being flagged (incorrectly??) because we identify character literrals
1005 : Cxx tests
1006 : test2004_154.C
1007 : test2005_178.C
1008 : test2005_191.C
1009 : test2005_194.C
1010 : test2005_196.C
1011 : test2005_198.C
1012 : test2005_199.C
1013 : test2006_16.C
1014 : test2006_17.C
1015 : test2006_18.C
1016 : test2006_26.C
1017 : -------------------------------------------------
1018 : write test cases so that
1019 : comments and preprocssor stuff etc.
1020 :
1021 : */
1022 : /*
1023 : CHANGE LINES LIKE THIS TO ACCEPT std::string instead of char*, which makes us give it a c_str
1024 : preprocessorList.addElement(macrotype,macroString_str.c_str(),globalFileName,preproc_start_line_num,preproc_start_column_num,preproc_line_num-preproc_start_line_num);
1025 : */
1026 :
1027 : /* DQ (12/10/2016): This is a technique to suppress warnings in generated code that we want to be an error elsewhere in ROSE.
1028 : See https://gcc.gnu.org/onlinedocs/gcc/Diagnostic-Pragmas.html for more detail.
1029 : */
1030 : #if __GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 8)
1031 : #pragma GCC diagnostic ignored "-Wsign-compare"
1032 : #endif
1033 :
1034 : #include "sage3basic.hhh"
1035 : #include <iostream>
1036 : #include <stdio.h>
1037 : #include <ctype.h>
1038 : #include <string>
1039 : #include <string.h>
1040 : #include <list>
1041 :
1042 : /* DQ (1/21/2008): This now has a single definition in the header file: ROSE/src/frontend/SageIII/general_defs.h */
1043 : #include "general_token_defs.h"
1044 :
1045 :
1046 : #if 0
1047 : // DQ (1/21/2008): This definition is now redundent with what is in general_token_defs.h
1048 : struct token_element
1049 : {
1050 : std::string token_lexeme;
1051 : int token_id;
1052 : };
1053 : #endif
1054 :
1055 : #if 0
1056 : // These are now defined in general_defs.h
1057 : //Ideally this should inherit from Sg_File_Info
1058 : //But for now, this will work
1059 : struct file_pos_info
1060 : {
1061 : int line_num;
1062 : int column_num;
1063 : };
1064 :
1065 : struct stream_element
1066 : {
1067 : struct token_element * p_tok_elem;
1068 : struct file_pos_info beginning_fpi;
1069 : struct file_pos_info ending_fpi;
1070 : };
1071 : #endif
1072 :
1073 :
1074 : using namespace std;
1075 :
1076 : #define DEBUG_LEX_PASS 0
1077 :
1078 : // list <stream_element*> ROSE_token_stream;
1079 : // typedef list <stream_element*>:: iterator SE_ITR;
1080 : LexTokenStreamTypePointer ROSE_token_stream_pointer = NULL;
1081 : typedef LexTokenStreamType::iterator SE_ITR;
1082 :
1083 : struct file_pos_info curr_beginning;
1084 :
1085 :
1086 : //Rama
1087 : //#ifdef ROSE_TOKEN_IDENTIFIERS_H
1088 : //#define ROSE_TOKEN_IDENTIFIERS_H
1089 :
1090 : using namespace ROSE_token_ids;
1091 :
1092 : token_element ROSE_C_CXX_keyword_map[] =
1093 : {
1094 : {"asm", C_CXX_ASM },
1095 : {"auto", C_CXX_AUTO },
1096 : {"bool", C_CXX_BOOL },
1097 : {"break", C_CXX_BREAK },
1098 : {"case", C_CXX_CASE },
1099 : {"catch", C_CXX_CATCH },
1100 : {"char", C_CXX_CHAR },
1101 : {"class", C_CXX_CLASS },
1102 : {"const", C_CXX_CONST },
1103 : {"const_cast", C_CXX_CONSTCAST },
1104 : {"continue", C_CXX_CONTINUE },
1105 : {"default", C_CXX_DEFAULT },
1106 : //{"defined", C_CXX_DEFINED },
1107 : {"delete", C_CXX_DELETE },
1108 : {"do", C_CXX_DO },
1109 : {"double", C_CXX_DOUBLE },
1110 : {"dynamic_cast", C_CXX_DYNAMICCAST },
1111 : {"else", C_CXX_ELSE },
1112 : {"enum", C_CXX_ENUM },
1113 : {"explicit", C_CXX_EXPLICIT },
1114 : {"export", C_CXX_EXPORT },
1115 : {"extern", C_CXX_EXTERN },
1116 : {"false", C_CXX_FALSE },
1117 : {"float", C_CXX_FLOAT },
1118 : {"for", C_CXX_FOR },
1119 : {"friend", C_CXX_FRIEND },
1120 : {"goto", C_CXX_GOTO },
1121 : {"if", C_CXX_IF },
1122 : {"inline", C_CXX_INLINE },
1123 : {"int", C_CXX_INT },
1124 : {"long", C_CXX_LONG },
1125 : {"mutable", C_CXX_MUTABLE },
1126 : {"namespace", C_CXX_NAMESPACE },
1127 : {"new", C_CXX_NEW },
1128 : {"operator", C_CXX_OPERATOR },
1129 : {"private", C_CXX_PRIVATE },
1130 : {"protected", C_CXX_PROTECTED },
1131 : {"public", C_CXX_PUBLIC },
1132 : {"register", C_CXX_REGISTER },
1133 : {"reinterpret_cast", C_CXX_REINTERPRETCAST },
1134 : {"return", C_CXX_RETURN },
1135 : {"short", C_CXX_SHORT },
1136 : {"signed", C_CXX_SIGNED },
1137 : {"sizeof", C_CXX_SIZEOF },
1138 : {"static", C_CXX_STATIC },
1139 : {"static_cast", C_CXX_STATICCAST },
1140 : {"struct", C_CXX_STRUCT },
1141 : {"switch", C_CXX_SWITCH },
1142 : {"template", C_CXX_TEMPLATE },
1143 : {"this", C_CXX_THIS },
1144 : {"throw", C_CXX_THROW },
1145 : {"true", C_CXX_TRUE },
1146 : {"try", C_CXX_TRY },
1147 : {"typedef", C_CXX_TYPEDEF },
1148 : {"typeid", C_CXX_TYPEID },
1149 : {"typename", C_CXX_TYPENAME },
1150 : {"union", C_CXX_UNION },
1151 : {"unsigned", C_CXX_UNSIGNED },
1152 : {"using", C_CXX_USING },
1153 : {"virtual", C_CXX_VIRTUAL },
1154 : {"void", C_CXX_VOID },
1155 : {"volatile", C_CXX_VOLATILE },
1156 : {"wchar_t", C_CXX_WCHART },
1157 : {"while", C_CXX_WHILE }
1158 : };
1159 :
1160 :
1161 :
1162 : //We know that this is a magic number.
1163 : //We also know how to fix it.
1164 : #define NUM_C_CXX_KEYWORDS 63
1165 :
1166 : //returns -1 if the string is not a keyword
1167 : //otherwise returns the token ID
1168 : int identify_if_C_CXX_keyword(std::string str)
1169 : {
1170 : // In FORTRAN, the identifiers are case insensitive.
1171 : // So, variable 'ArEa' is the same as 'aReA'
1172 :
1173 : string lowered_str;
1174 : for(unsigned int i = 0; i < str.size(); i++)
1175 : {
1176 : lowered_str += (unsigned char)tolower(str[i]);
1177 : }
1178 :
1179 : // DQ (9/29/2013): This loop over keywords is rather inifficent, there should be a better implementation.
1180 :
1181 : // printf("got called with %s. Converted to %s\n", str.c_str(), lowered_str.c_str());
1182 : for(int i = 0; i < NUM_C_CXX_KEYWORDS; i++)
1183 : {
1184 : if(lowered_str == ROSE_C_CXX_keyword_map[i].token_lexeme)
1185 : {
1186 : return (ROSE_C_CXX_keyword_map[i].token_id);
1187 : }
1188 : }
1189 :
1190 : return -1;
1191 : }
1192 :
1193 :
1194 : int getNumberOfLines( std::string internalString )
1195 : {
1196 : // This code is copied from the similar support in rose_attributes_list.C.
1197 :
1198 : int line = 0;
1199 : int i = 0;
1200 : while (internalString[i] != '\0')
1201 : {
1202 : if (internalString[i] == '\n')
1203 : {
1204 : line++;
1205 : }
1206 : i++;
1207 : }
1208 :
1209 : return line;
1210 : }
1211 :
1212 : int getColumnNumberOfEndOfString( std::string internalString )
1213 : {
1214 : // This code is copied from the similar support in rose_attributes_list.C.
1215 :
1216 : int col = 1;
1217 : int i = 0;
1218 :
1219 : // DQ (10/1/2013): I think we want to have the column number after a '\n' be zero.
1220 : // DQ (10/27/2006): the last line has a '\n' so we need the length
1221 : // of the last line before the '\n" triggers the counter to be reset!
1222 : // This fix is required because the strings we have include the final '\n"
1223 : int previousLineLength = col;
1224 : while (internalString[i] != '\0')
1225 : {
1226 : if (internalString[i] == '\n')
1227 : {
1228 : // previousLineLength = col;
1229 : col = 1;
1230 : previousLineLength = col;
1231 : }
1232 : else
1233 : {
1234 : col++;
1235 : previousLineLength = col;
1236 : }
1237 : i++;
1238 : }
1239 :
1240 : int endingColumnNumber = previousLineLength;
1241 :
1242 : // printf ("lexer: getColumnNumberOfEndOfString(): endingColumnNumber = %d \n",endingColumnNumber);
1243 :
1244 : #if 0
1245 : // If this is a one line comment then the ending position is the length of the comment PLUS the starting column position
1246 : if (getNumberOfLines(internalString) == 1)
1247 : {
1248 : // endingColumnNumber += get_file_info()->get_col() - 1;
1249 : endingColumnNumber += internalString.length() - 1;
1250 : }
1251 : #endif
1252 :
1253 : return endingColumnNumber;
1254 : }
1255 :
1256 :
1257 : void add_token (std::string str, int preproc_line_num, int & preproc_column_num, int tokenId )
1258 : {
1259 : // This function refactors the support to build a token and add it to the
1260 : // list of tokens. It also increments the preproc_column_num as well.
1261 :
1262 : token_element *p_tok_elem = new token_element;
1263 : p_tok_elem->token_lexeme = yytext;
1264 :
1265 : int is_keyword = identify_if_C_CXX_keyword(str);
1266 :
1267 : #if DEBUG_LEX_PASS
1268 : //printf("%s is either a %s token \n",str.c_str(),(is_keyword != -1) ? "keyword" : "identifier");
1269 : #endif
1270 :
1271 : #if 0
1272 : printf("%s is a %s token str.length() = %zu \n",str.c_str(),(is_keyword != -1) ? "keyword" : "identifier",str.length());
1273 : if (str.length() == 1)
1274 : {
1275 : printf ("str[0] = %d \n",str[0]);
1276 : }
1277 : if (str.length() == 2)
1278 : {
1279 : printf ("str[0] = %d \n",str[0]);
1280 : printf ("str[1] = %d \n",str[1]);
1281 : }
1282 : #endif
1283 :
1284 : // found a keyword?
1285 : if(is_keyword != -1)
1286 : {
1287 : // printf("%s is a keyword\n", str.c_str());
1288 : p_tok_elem->token_id = is_keyword;
1289 : }
1290 : else
1291 : {
1292 : // printf("%s is not a keyword\n", str.c_str());
1293 : if (tokenId == C_CXX_SYNTAX)
1294 : {
1295 : p_tok_elem->token_id = C_CXX_SYNTAX;
1296 : }
1297 : else
1298 : {
1299 : if (tokenId == C_CXX_WHITESPACE)
1300 : {
1301 : p_tok_elem->token_id = C_CXX_WHITESPACE;
1302 : }
1303 : else
1304 : {
1305 : p_tok_elem->token_id = C_CXX_IDENTIFIER;
1306 : }
1307 : }
1308 : }
1309 :
1310 : stream_element *p_se = new stream_element;
1311 : p_se->p_tok_elem = p_tok_elem;
1312 :
1313 : // Added a pointer to the processed PreprocessingInfo object.
1314 : p_se->p_preprocessingInfo = NULL;
1315 :
1316 : // DQ (9/29/2013): uncommented so that we can
1317 : // set the source position.
1318 : p_se->beginning_fpi.line_num = preproc_line_num;
1319 : p_se->beginning_fpi.column_num = preproc_column_num;
1320 :
1321 : int number_of_lines = getNumberOfLines(str);
1322 :
1323 : // p_se->ending_fpi.line_num = preproc_line_num;
1324 : p_se->ending_fpi.line_num = preproc_line_num + number_of_lines;
1325 :
1326 : int last_string_length = getColumnNumberOfEndOfString(str);
1327 :
1328 : // printf ("In add_token(): preproc_column_num = %d last_string_length = %d \n",preproc_column_num,last_string_length);
1329 :
1330 : // p_se->ending_fpi.column_num = preproc_column_num-1;
1331 : // p_se->ending_fpi.column_num = (preproc_column_num-1) + (last_string_length - 1);
1332 : if (number_of_lines == 0)
1333 : {
1334 : p_se->ending_fpi.column_num = (preproc_column_num-1) + (last_string_length - 1);
1335 : // printf ("In add_token(): ending_fpi.column_num set to (preproc_column_num-1) + (last_string_length - 1) \n");
1336 : }
1337 : else
1338 : {
1339 : p_se->ending_fpi.column_num = (last_string_length - 1);
1340 : // printf ("In add_token(): ending_fpi.column_num set to (last_string_length - 1) \n");
1341 : }
1342 :
1343 : // When using the std::string we need to subtract 1 for the null terminal.
1344 : // preproc_column_num += strlen(yytext);
1345 : // preproc_column_num += str.length();
1346 :
1347 : // DQ (12/26/2018): This is reset when we see a windows CR LF pair.
1348 : if (str.length() == 2)
1349 : {
1350 : if (str[0] == '\r' && str[1] == '\n')
1351 : {
1352 : #if 0
1353 : printf ("Found a CR LF Windows line ending pair, reset the column number \n");
1354 : #endif
1355 : preproc_column_num = 1;
1356 : }
1357 : else
1358 : {
1359 : preproc_column_num += str.length();
1360 : }
1361 : }
1362 : else
1363 : {
1364 : preproc_column_num += str.length();
1365 : }
1366 :
1367 : // push the element onto the token stream
1368 : ROSE_token_stream_pointer->push_back(p_se);
1369 :
1370 : #if 0
1371 : // DQ (11/29/2018): Investigating form-feeds and windows line endings (and how the token-based unparsing is removing them).
1372 : if (p_tok_elem->token_id == C_CXX_WHITESPACE)
1373 : {
1374 : printf ("p_se->beginning_fpi.line_num = (%d,%d) \n",p_se->beginning_fpi.line_num,p_se->beginning_fpi.column_num);
1375 : if (p_tok_elem->token_lexeme.length() == 1)
1376 : {
1377 : printf ("Found token of length one \n");
1378 : char character = p_tok_elem->token_lexeme[0];
1379 : printf ("character = %d \n",(int)character);
1380 : }
1381 : #if 0
1382 : printf ("Exiting as a test! \n");
1383 : ROSE_ASSERT(false);
1384 : #endif
1385 : }
1386 : #endif
1387 : }
1388 :
1389 :
1390 : void add_preprocessingInfo_to_token_stream (PreprocessingInfo* preprocessingInfo, int preproc_line_num, int preproc_column_num, int number_of_lines)
1391 : {
1392 : // This function is overloaded with the one above and refactors the
1393 : // support to build a token and add it to the list of tokens. It
1394 : // also increments the preproc_column_num as well.
1395 :
1396 : token_element *p_tok_elem = new token_element;
1397 :
1398 : // We don't have to set this since it will be an empty string.
1399 : // unless it is helpful to set the string to that of the
1400 : // PreprocessingInfo.
1401 : ROSE_ASSERT(preprocessingInfo != NULL);
1402 : p_tok_elem->token_lexeme = preprocessingInfo->getString();
1403 :
1404 : p_tok_elem->token_id = C_CXX_PREPROCESSING_INFO;
1405 :
1406 : #if DEBUG_LEX_PASS
1407 : printf("This is a PreprocessingInfo object processed as a token: preprocessingInfo = %p \n",preprocessingInfo);
1408 : #endif
1409 :
1410 : #if DEBUG_LEX_PASS
1411 : for (size_t i = 0; i < p_tok_elem->token_lexeme.length(); i++)
1412 : {
1413 : printf(" --- p_tok_elem->token_lexeme[i] = %c = (ascii value) %d \n",p_tok_elem->token_lexeme[i],p_tok_elem->token_lexeme[i]);
1414 : // if (p_tok_elem->token_lexeme[i+1] == '\r')
1415 : if (p_tok_elem->token_lexeme[i+1] != '\0')
1416 : {
1417 : printf(" --- --- p_tok_elem->token_lexeme[i+1] = %c = (ascii value) %d \n",p_tok_elem->token_lexeme[i+1],p_tok_elem->token_lexeme[i+1]);
1418 : }
1419 : }
1420 : #endif
1421 :
1422 : stream_element *p_se = new stream_element;
1423 : p_se->p_tok_elem = p_tok_elem;
1424 :
1425 : // Added a pointer to the processed PreprocessingInfo object.
1426 : p_se->p_preprocessingInfo = preprocessingInfo;
1427 :
1428 : // DQ (9/29/2013): uncommented so that we can
1429 : // set the source position.
1430 : p_se->beginning_fpi.line_num = preproc_line_num;
1431 : p_se->beginning_fpi.column_num = preproc_column_num;
1432 :
1433 : // preproc_column_num += p_tok_elem->token_lexeme.length();
1434 :
1435 : // Adjust the increment in the current line number based on the size of the macro.
1436 : // Note: we don't want to modify the value of preproc_line_num, since that will have
1437 : // been taken care of in the processing of the CPP directive or C/C++ comment.
1438 : // int numberOfLines = preprocessingInfo->getNumberOfLines();
1439 : // ROSE_ASSERT(numberOfLines >= 1);
1440 : #if 0
1441 : printf ("In add_token(PreprocessingInfo*,int,int&): line column number correctly?: numberOfLines = %d \n",numberOfLines);
1442 : #endif
1443 : // p_se->ending_fpi.line_num = preproc_line_num + (numberOfLines - 1);
1444 :
1445 : #if 0
1446 : printf ("In add_token(PreprocessingInfo*,int,int&): line column number correctly?: number_of_lines = %d \n",number_of_lines);
1447 : #endif
1448 : p_se->ending_fpi.line_num = preproc_line_num + number_of_lines;
1449 :
1450 : // preproc_column_num = preprocessingInfo->getColumnNumberOfEndOfString();
1451 :
1452 : int last_string_length = getColumnNumberOfEndOfString(p_tok_elem->token_lexeme);
1453 :
1454 : // printf ("In add_preprocessingInfo_to_token_stream(): preproc_column_num = %d last_string_length = %d \n",preproc_column_num,last_string_length);
1455 :
1456 : // p_se->ending_fpi.column_num = preproc_column_num-1;
1457 : // p_se->ending_fpi.column_num = last_string_length - 1;
1458 :
1459 : if (number_of_lines == 0)
1460 : {
1461 : p_se->ending_fpi.column_num = (preproc_column_num-1) + (last_string_length - 1);
1462 : // printf ("In add_preprocessingInfo_to_token_stream(): ending_fpi.column_num set to (preproc_column_num-1) + (last_string_length - 1) \n");
1463 : }
1464 : else
1465 : {
1466 : p_se->ending_fpi.column_num = (last_string_length - 1);
1467 : // printf ("In add_preprocessingInfo_to_token_stream(): ending_fpi.column_num set to (last_string_length - 1) \n");
1468 : }
1469 :
1470 : // push the element onto the token stream
1471 : ROSE_token_stream_pointer->push_back(p_se);
1472 : }
1473 :
1474 :
1475 : //#endif
1476 :
1477 :
1478 :
1479 : #include "sage3.h"
1480 :
1481 : // DQ (11/17/2004): Avoid compiler warning about unused function
1482 : #define YY_NO_UNPUT
1483 :
1484 : #ifdef BOOL_IS_BROKEN
1485 : // If BOOL_IS_BROKEN then we can assume that there is no definition for "true" and "false"
1486 : #ifndef false
1487 : #define false 0
1488 : #endif
1489 : #ifndef true
1490 : #define true 1
1491 : #endif
1492 : #ifndef bool
1493 : typedef int bool;
1494 : #endif
1495 : #endif
1496 :
1497 : #ifndef ROSE_ASSERT
1498 : #define ROSE_ASSERT assert
1499 : #endif
1500 :
1501 : #include "rose_attributes_list.h"
1502 : #define yytext Rose_C_Cxx_text
1503 : #define yylex Rose_C_Cxx_lex
1504 :
1505 : #define HANDLEMACROSTART preproc_start_line_num=preproc_line_num; preproc_start_column_num=1; preproc_column_num+=strlen(yytext); macroString = yytext; BEGIN MACRO;
1506 :
1507 : int i = 0;
1508 :
1509 : std::string commentString;
1510 : std::string macroString;
1511 : //remove these _st's later
1512 : std::stack<int> curly_brace_stack_st;
1513 : std::stack<int> parenthesis_stack;
1514 : std::stack<int> square_bracket;
1515 :
1516 : //All the above should be "matching constructs"
1517 : //create new for various casts and templates
1518 :
1519 :
1520 : // DQ (4/19/2006):
1521 : // Store the name of the current file so that we can generate Sg_File_Info objects
1522 : // for each comment. Later we might want starting and ending fileInfo for each
1523 : // comments and CPP directive.
1524 : std::string globalFileName;
1525 :
1526 : int curr_brace_depth=0;
1527 : int ls_startingline_no;
1528 : int ls_startingpreproc_column_num;
1529 : int brace_counting_on=0;
1530 : PreprocessingInfo::DirectiveType macrotype = PreprocessingInfo::CpreprocessorUnknownDeclaration;
1531 :
1532 : int topcurlybracestack();
1533 : void pushbracestack(int);
1534 : int popbracestack();
1535 : bool isemptystack();
1536 :
1537 : int num_of_newlines(char*);
1538 :
1539 : ROSEAttributesList preprocessorList;
1540 :
1541 :
1542 : //add stuff for char literals???????????
1543 :
1544 : /*
1545 : whitespacenl [\t\n ]+
1546 : whitespace [\t ]+
1547 : lineprefix ^{whitespace}*"#"{whitespace}*
1548 : macrokeyword "include"|"define"|"undef"|"line"|"error"|"warning"|"if"|"ifdef"|"ifndef"|"elif"|"else"|"endif"
1549 : mlinkagespecification ^{whitespace}*"extern"{whitespace}*(("\"C\"")|("\"C++\"")){whitespacenl}*"{"
1550 : */
1551 :
1552 : //refresher: blank and space function exactly as the STDLIB functions isblank and isspace respectively.
1553 : //blank matches only the various blank characters (\b,\t). It does NOT match new line. (and its variants).
1554 : //space matches blanks, newlines (various flavours like formfeed etc) as well as other stuff like vertical tab '\v' etc.
1555 : //refer to http://www.gatago.com/comp/std/c/18426853.html among others for difference between these two.
1556 : /*
1557 : The following was the original
1558 : whitespacenl [\t\n ]+
1559 : whitespace [\t ]+
1560 :
1561 : I changed it to
1562 : whitespacenl [:space:]+
1563 : whitespace [:blank:]+
1564 : This does not work.
1565 :
1566 : What worked was the following:
1567 : whitespacenl [[:space:]]+
1568 : whitespace [[:blank:]]+
1569 :
1570 : */
1571 :
1572 : /*
1573 : I am not sure if the whitespacenl would count the number of newlines in code that has backslashes properly.
1574 : */
1575 : #line 1576 "preproc-c.cc"
1576 :
1577 : #line 1578 "preproc-c.cc"
1578 :
1579 : #define INITIAL 0
1580 : #define NORMAL 1
1581 : #define CXX_COMMENT 2
1582 : #define C_COMMENT 3
1583 : #define STRING_LIT 4
1584 : #define CHAR_LIT 5
1585 : #define MACRO 6
1586 : #define C_COMMENT_INMACRO 7
1587 : #define STRING_LIT_IN_MACRO 8
1588 :
1589 : #ifndef YY_NO_UNISTD_H
1590 : /* Special case for "unistd.h", since it is non-ANSI. We include it way
1591 : * down here because we want the user's section 1 to have been scanned first.
1592 : * The user has a chance to override it with an option.
1593 : */
1594 : #include <unistd.h>
1595 : #endif
1596 :
1597 : #ifndef YY_EXTRA_TYPE
1598 : #define YY_EXTRA_TYPE void *
1599 : #endif
1600 :
1601 : static int yy_init_globals ( void );
1602 :
1603 : /* Accessor methods to globals.
1604 : These are made visible to non-reentrant scanners for convenience. */
1605 :
1606 : int yylex_destroy ( void );
1607 :
1608 : int yyget_debug ( void );
1609 :
1610 : void yyset_debug ( int debug_flag );
1611 :
1612 : YY_EXTRA_TYPE yyget_extra ( void );
1613 :
1614 : void yyset_extra ( YY_EXTRA_TYPE user_defined );
1615 :
1616 : FILE *yyget_in ( void );
1617 :
1618 : void yyset_in ( FILE * _in_str );
1619 :
1620 : FILE *yyget_out ( void );
1621 :
1622 : void yyset_out ( FILE * _out_str );
1623 :
1624 : int yyget_leng ( void );
1625 :
1626 : char *yyget_text ( void );
1627 :
1628 : int yyget_lineno ( void );
1629 :
1630 : void yyset_lineno ( int _line_number );
1631 :
1632 : /* Macros after this point can all be overridden by user definitions in
1633 : * section 1.
1634 : */
1635 :
1636 : #ifndef YY_SKIP_YYWRAP
1637 : #ifdef __cplusplus
1638 : extern "C" int yywrap ( void );
1639 : #else
1640 : extern int yywrap ( void );
1641 : #endif
1642 : #endif
1643 :
1644 : #ifndef YY_NO_UNPUT
1645 :
1646 : static void yyunput ( int c, char *buf_ptr );
1647 :
1648 : #endif
1649 :
1650 : #ifndef yytext_ptr
1651 : static void yy_flex_strncpy ( char *, const char *, int );
1652 : #endif
1653 :
1654 : #ifdef YY_NEED_STRLEN
1655 : static int yy_flex_strlen ( const char * );
1656 : #endif
1657 :
1658 : #ifndef YY_NO_INPUT
1659 : #ifdef __cplusplus
1660 : static int yyinput ( void );
1661 : #else
1662 : static int input ( void );
1663 : #endif
1664 :
1665 : #endif
1666 :
1667 : /* Amount of stuff to slurp up with each read. */
1668 : #ifndef YY_READ_BUF_SIZE
1669 : #ifdef __ia64__
1670 : /* On IA-64, the buffer size is 16k, not 8k */
1671 : #define YY_READ_BUF_SIZE 16384
1672 : #else
1673 : #define YY_READ_BUF_SIZE 8192
1674 : #endif /* __ia64__ */
1675 : #endif
1676 :
1677 : /* Copy whatever the last rule matched to the standard output. */
1678 : #ifndef ECHO
1679 : /* This used to be an fputs(), but since the string might contain NUL's,
1680 : * we now use fwrite().
1681 : */
1682 : #define ECHO do { if (fwrite( yytext, (size_t) yyleng, 1, yyout )) {} } while (0)
1683 : #endif
1684 :
1685 : /* Gets input and stuffs it into "buf". number of characters read, or YY_NULL,
1686 : * is returned in "result".
1687 : */
1688 : #ifndef YY_INPUT
1689 : #define YY_INPUT(buf,result,max_size) \
1690 : if ( YY_CURRENT_BUFFER_LVALUE->yy_is_interactive ) \
1691 : { \
1692 : int c = '*'; \
1693 : int n; \
1694 : for ( n = 0; n < max_size && \
1695 : (c = getc( yyin )) != EOF && c != '\n'; ++n ) \
1696 : buf[n] = (char) c; \
1697 : if ( c == '\n' ) \
1698 : buf[n++] = (char) c; \
1699 : if ( c == EOF && ferror( yyin ) ) \
1700 : YY_FATAL_ERROR( "input in flex scanner failed" ); \
1701 : result = n; \
1702 : } \
1703 : else \
1704 : { \
1705 : errno=0; \
1706 : while ( (result = (int) fread(buf, 1, (yy_size_t) max_size, yyin)) == 0 && ferror(yyin)) \
1707 : { \
1708 : if( errno != EINTR) \
1709 : { \
1710 : YY_FATAL_ERROR( "input in flex scanner failed" ); \
1711 : break; \
1712 : } \
1713 : errno=0; \
1714 : clearerr(yyin); \
1715 : } \
1716 : }\
1717 : \
1718 :
1719 : #endif
1720 :
1721 : /* No semi-colon after return; correct usage is to write "yyterminate();" -
1722 : * we don't want an extra ';' after the "return" because that will cause
1723 : * some compilers to complain about unreachable statements.
1724 : */
1725 : #ifndef yyterminate
1726 : #define yyterminate() return YY_NULL
1727 : #endif
1728 :
1729 : /* Number of entries by which start-condition stack grows. */
1730 : #ifndef YY_START_STACK_INCR
1731 : #define YY_START_STACK_INCR 25
1732 : #endif
1733 :
1734 : /* Report a fatal error. */
1735 : #ifndef YY_FATAL_ERROR
1736 : #define YY_FATAL_ERROR(msg) yy_fatal_error( msg )
1737 : #endif
1738 :
1739 : /* end tables serialization structures and prototypes */
1740 :
1741 : /* Default declaration of generated scanner - a define so the user can
1742 : * easily add parameters.
1743 : */
1744 : #ifndef YY_DECL
1745 : #define YY_DECL_IS_OURS 1
1746 :
1747 : extern int yylex (void);
1748 :
1749 : #define YY_DECL int yylex (void)
1750 : #endif /* !YY_DECL */
1751 :
1752 : /* Code executed at the beginning of each rule, after yytext and yyleng
1753 : * have been set up.
1754 : */
1755 : #ifndef YY_USER_ACTION
1756 : #define YY_USER_ACTION
1757 : #endif
1758 :
1759 : /* Code executed at the end of each rule. */
1760 : #ifndef YY_BREAK
1761 : #define YY_BREAK /*LINTED*/break;
1762 : #endif
1763 :
1764 : #define YY_RULE_SETUP \
1765 : if ( yyleng > 0 ) \
1766 : YY_CURRENT_BUFFER_LVALUE->yy_at_bol = \
1767 : (yytext[yyleng - 1] == '\n'); \
1768 : YY_USER_ACTION
1769 :
1770 : /** The main scanner function which does all the work.
1771 : */
1772 316 : YY_DECL
1773 : {
1774 316 : yy_state_type yy_current_state;
1775 316 : char *yy_cp, *yy_bp;
1776 316 : int yy_act;
1777 :
1778 316 : if ( !(yy_init) )
1779 : {
1780 315 : (yy_init) = 1;
1781 :
1782 : #ifdef YY_USER_INIT
1783 : YY_USER_INIT;
1784 : #endif
1785 :
1786 315 : if ( ! (yy_start) )
1787 315 : (yy_start) = 1; /* first start state */
1788 :
1789 315 : if ( ! yyin )
1790 0 : yyin = stdin;
1791 :
1792 315 : if ( ! yyout )
1793 315 : yyout = stdout;
1794 :
1795 315 : if ( ! YY_CURRENT_BUFFER ) {
1796 315 : yyensure_buffer_stack ();
1797 315 : YY_CURRENT_BUFFER_LVALUE =
1798 315 : yy_create_buffer( yyin, YY_BUF_SIZE );
1799 : }
1800 :
1801 315 : yy_load_buffer_state( );
1802 : }
1803 :
1804 316 : {
1805 : #line 739 "../../../../rexompiler/src/frontend/SageIII/preproc-c.ll"
1806 :
1807 :
1808 :
1809 : #line 743 "../../../../rexompiler/src/frontend/SageIII/preproc-c.ll"
1810 : int preproc_line_num = 1;
1811 : /*bad way to initialize*/
1812 : int preproc_start_line_num = preproc_line_num;
1813 : int preproc_column_num = 1;
1814 : int preproc_start_column_num = preproc_column_num;
1815 : /*Do we need this ???*/
1816 : BEGIN NORMAL;
1817 :
1818 :
1819 : #line 1820 "preproc-c.cc"
1820 :
1821 206572 : while ( /*CONSTCOND*/1 ) /* loops until end-of-file is reached */
1822 : {
1823 206572 : yy_cp = (yy_c_buf_p);
1824 :
1825 : /* Support of yytext. */
1826 206572 : *yy_cp = (yy_hold_char);
1827 :
1828 : /* yy_bp points to the position in yy_ch_buf of the start of
1829 : * the current run.
1830 : */
1831 206572 : yy_bp = yy_cp;
1832 :
1833 206572 : yy_current_state = (yy_start);
1834 206572 : yy_current_state += YY_AT_BOL();
1835 387416 : yy_match:
1836 387416 : do
1837 : {
1838 387416 : YY_CHAR yy_c = yy_ec[YY_SC_TO_UI(*yy_cp)] ;
1839 387416 : if ( yy_accept[yy_current_state] )
1840 : {
1841 169677 : (yy_last_accepting_state) = yy_current_state;
1842 169677 : (yy_last_accepting_cpos) = yy_cp;
1843 : }
1844 643251 : while ( yy_chk[yy_base[yy_current_state] + yy_c] != yy_current_state )
1845 : {
1846 255835 : yy_current_state = (int) yy_def[yy_current_state];
1847 255835 : if ( yy_current_state >= 207 )
1848 185787 : yy_c = yy_meta[yy_c];
1849 : }
1850 387416 : yy_current_state = yy_nxt[yy_base[yy_current_state] + yy_c];
1851 387416 : ++yy_cp;
1852 : }
1853 387416 : while ( yy_base[yy_current_state] != 293 );
1854 :
1855 206897 : yy_find_action:
1856 206897 : yy_act = yy_accept[yy_current_state];
1857 206897 : if ( yy_act == 0 )
1858 : { /* have to back up */
1859 65101 : yy_cp = (yy_last_accepting_cpos);
1860 65101 : yy_current_state = (yy_last_accepting_state);
1861 65101 : yy_act = yy_accept[yy_current_state];
1862 : }
1863 :
1864 206897 : YY_DO_BEFORE_ACTION;
1865 :
1866 207213 : do_action: /* This label is used only to access EOF actions. */
1867 :
1868 207213 : switch ( yy_act )
1869 : { /* beginning of action switch */
1870 0 : case 0: /* must back up */
1871 : /* undo the effects of YY_DO_BEFORE_ACTION */
1872 0 : *yy_cp = (yy_hold_char);
1873 0 : yy_cp = (yy_last_accepting_cpos);
1874 0 : yy_current_state = (yy_last_accepting_state);
1875 0 : goto yy_find_action;
1876 :
1877 0 : case 1:
1878 0 : YY_RULE_SETUP
1879 : #line 752 "../../../../rexompiler/src/frontend/SageIII/preproc-c.ll"
1880 : {
1881 : #if DEBUG_LEX_PASS
1882 : printf("%s is a form-feed token (length = %" PRIuPTR ") \n",yytext,strlen(yytext));
1883 : #endif
1884 : // DQ (11/29/2018): Adding form feed support to ROSE.
1885 : add_token(yytext,preproc_line_num,preproc_column_num,C_CXX_WHITESPACE);
1886 : }
1887 : YY_BREAK
1888 : case 2:
1889 : /* rule 2 can match eol */
1890 : YY_RULE_SETUP
1891 : #line 760 "../../../../rexompiler/src/frontend/SageIII/preproc-c.ll"
1892 : {
1893 : #if DEBUG_LEX_PASS
1894 : printf("%s is a windows line ending token (length = %" PRIuPTR ") \n",yytext,strlen(yytext));
1895 : #endif
1896 : // DQ (11/29/2018): Adding windows line ending support to ROSE.
1897 : add_token(yytext,preproc_line_num,preproc_column_num,C_CXX_WHITESPACE);
1898 :
1899 : // DQ (12/26/2018): Adding windows line ending support to ROSE (increment the line count).
1900 : preproc_line_num += 1;
1901 :
1902 : // DQ (12/26/2018): This is reset in the add_token() function.
1903 : // preproc_column_num = 1;
1904 : }
1905 : YY_BREAK
1906 : case 3:
1907 : /* rule 3 can match eol */
1908 : YY_RULE_SETUP
1909 : #line 774 "../../../../rexompiler/src/frontend/SageIII/preproc-c.ll"
1910 : {
1911 : #if DEBUG_LEX_PASS
1912 : printf("%s is a mlinkagespecification token \n",yytext);
1913 : #endif
1914 : preprocessorList.addElement(PreprocessingInfo::ClinkageSpecificationStart,yytext,globalFileName,preproc_line_num,preproc_column_num,0);
1915 : preproc_line_num+=num_of_newlines(yytext);
1916 :
1917 : add_token(yytext,preproc_line_num,preproc_column_num,0);
1918 : // preproc_column_num+=strlen(yytext);
1919 :
1920 : curr_brace_depth++;
1921 : pushbracestack(curr_brace_depth);
1922 : }
1923 : YY_BREAK
1924 : /*Handle the braces (left and right). Push and Pop the bracestack accordingly*/
1925 : case 4:
1926 : YY_RULE_SETUP
1927 : #line 789 "../../../../rexompiler/src/frontend/SageIII/preproc-c.ll"
1928 : {
1929 : #if DEBUG_LEX_PASS
1930 : printf("%s is a syntax token \n",yytext);
1931 : #endif
1932 : if (!isemptystack())
1933 : {
1934 : /* we only count braces within a linkage specification. */
1935 : curr_brace_depth++;
1936 : }
1937 : // printf("Ram: found left brace at preproc_line_num = %d, preproc_column_num = %d\n", preproc_line_num, preproc_column_num);
1938 :
1939 : add_token(yytext,preproc_line_num,preproc_column_num,C_CXX_SYNTAX);
1940 : // preproc_column_num++;
1941 : }
1942 : YY_BREAK
1943 : case 5:
1944 : YY_RULE_SETUP
1945 : #line 804 "../../../../rexompiler/src/frontend/SageIII/preproc-c.ll"
1946 : {
1947 : #if DEBUG_LEX_PASS
1948 : printf("%s is a syntax token \n",yytext);
1949 : #endif
1950 :
1951 : bool added_link_specification_as_token = false;
1952 : if (!isemptystack())
1953 : {
1954 : if (curr_brace_depth==topcurlybracestack())
1955 : {
1956 : popbracestack();
1957 :
1958 : // The semantics of ROSEAttributesList::addElement() is to use std::vector::push_back();
1959 : preprocessorList.addElement(PreprocessingInfo::ClinkageSpecificationEnd, yytext, globalFileName, preproc_line_num, preproc_column_num, 0);
1960 :
1961 : added_link_specification_as_token = true;
1962 :
1963 : // This token should maybe be special since it marks the end of a link specification (later).
1964 : add_preprocessingInfo_to_token_stream(preprocessorList.lastElement(),preproc_line_num,preproc_column_num,0);
1965 : }
1966 :
1967 : curr_brace_depth--;
1968 : }
1969 : // printf("Ram: found right brace at preproc_line_num = %d, preproc_column_num = %d\n", preproc_line_num, preproc_column_num);
1970 :
1971 : if (added_link_specification_as_token == false)
1972 : {
1973 : add_token(yytext,preproc_line_num,preproc_column_num,C_CXX_SYNTAX);
1974 : }
1975 : // preproc_column_num++;
1976 : }
1977 : YY_BREAK
1978 : case 6:
1979 : YY_RULE_SETUP
1980 : #line 836 "../../../../rexompiler/src/frontend/SageIII/preproc-c.ll"
1981 : {
1982 : /*if(!isemptystack())
1983 : {
1984 : //we only count braces within a linkage specification.
1985 : curr_brace_depth++;
1986 : }
1987 : */
1988 : #if DEBUG_LEX_PASS
1989 : printf("%s is a syntax token \n", yytext);
1990 : #endif
1991 : add_token(yytext,preproc_line_num,preproc_column_num,C_CXX_SYNTAX);
1992 : // preproc_column_num++;
1993 : }
1994 : YY_BREAK
1995 : case 7:
1996 : YY_RULE_SETUP
1997 : #line 850 "../../../../rexompiler/src/frontend/SageIII/preproc-c.ll"
1998 : {
1999 : /*
2000 : if(!isemptystack())
2001 : {
2002 : if(curr_brace_depth==topcurlybracestack())
2003 : {
2004 : popbracestack();
2005 : preprocessorList.addElement(PreprocessingInfo::ClinkageSpecificationEnd,
2006 : yytext, globalFileName, preproc_line_num, preproc_column_num, 0);
2007 : }
2008 : curr_brace_depth--;
2009 : }
2010 : */
2011 : #if DEBUG_LEX_PASS
2012 : printf("%s is a syntax token \n", yytext);
2013 : #endif
2014 : add_token(yytext,preproc_line_num,preproc_column_num,C_CXX_SYNTAX);
2015 : // preproc_column_num++;
2016 : }
2017 : YY_BREAK
2018 : /* DQ (9/29/2013): Added additional syntax to token handling */
2019 : case 8:
2020 : YY_RULE_SETUP
2021 : #line 871 "../../../../rexompiler/src/frontend/SageIII/preproc-c.ll"
2022 : {
2023 : #if DEBUG_LEX_PASS
2024 : printf("%s is a syntax token \n", yytext);
2025 : #endif
2026 : add_token(yytext,preproc_line_num,preproc_column_num,C_CXX_SYNTAX);
2027 : // preproc_column_num++;
2028 : }
2029 : YY_BREAK
2030 : case 9:
2031 : YY_RULE_SETUP
2032 : #line 879 "../../../../rexompiler/src/frontend/SageIII/preproc-c.ll"
2033 : {
2034 : #if DEBUG_LEX_PASS
2035 : printf("%s is a syntax token \n", yytext);
2036 : #endif
2037 : add_token(yytext,preproc_line_num,preproc_column_num,C_CXX_SYNTAX);
2038 : // preproc_column_num++;
2039 : }
2040 : YY_BREAK
2041 : case 10:
2042 : YY_RULE_SETUP
2043 : #line 887 "../../../../rexompiler/src/frontend/SageIII/preproc-c.ll"
2044 : {
2045 : #if DEBUG_LEX_PASS
2046 : printf("%s is a syntax token \n", yytext);
2047 : #endif
2048 : add_token(yytext,preproc_line_num,preproc_column_num,C_CXX_SYNTAX);
2049 : // preproc_column_num++;
2050 : }
2051 : YY_BREAK
2052 : case 11:
2053 : YY_RULE_SETUP
2054 : #line 895 "../../../../rexompiler/src/frontend/SageIII/preproc-c.ll"
2055 : {
2056 : #if DEBUG_LEX_PASS
2057 : printf("%s is a syntax token \n", yytext);
2058 : #endif
2059 : add_token(yytext,preproc_line_num,preproc_column_num,C_CXX_SYNTAX);
2060 : // preproc_column_num++;
2061 : }
2062 : YY_BREAK
2063 : case 12:
2064 : YY_RULE_SETUP
2065 : #line 903 "../../../../rexompiler/src/frontend/SageIII/preproc-c.ll"
2066 : {
2067 : #if DEBUG_LEX_PASS
2068 : printf("%s is a syntax token \n", yytext);
2069 : #endif
2070 : add_token(yytext,preproc_line_num,preproc_column_num,C_CXX_SYNTAX);
2071 : // preproc_column_num++;
2072 : }
2073 : YY_BREAK
2074 : case 13:
2075 : YY_RULE_SETUP
2076 : #line 911 "../../../../rexompiler/src/frontend/SageIII/preproc-c.ll"
2077 : {
2078 : #if DEBUG_LEX_PASS
2079 : printf("%s is a syntax token \n", yytext);
2080 : #endif
2081 : add_token(yytext,preproc_line_num,preproc_column_num,C_CXX_SYNTAX);
2082 : // preproc_column_num++;
2083 : }
2084 : YY_BREAK
2085 : case 14:
2086 : YY_RULE_SETUP
2087 : #line 919 "../../../../rexompiler/src/frontend/SageIII/preproc-c.ll"
2088 : {
2089 : #if DEBUG_LEX_PASS
2090 : printf("%s is a syntax token \n", yytext);
2091 : #endif
2092 : add_token(yytext,preproc_line_num,preproc_column_num,C_CXX_SYNTAX);
2093 : // preproc_column_num++;
2094 : }
2095 : YY_BREAK
2096 : case 15:
2097 : YY_RULE_SETUP
2098 : #line 927 "../../../../rexompiler/src/frontend/SageIII/preproc-c.ll"
2099 : {
2100 : #if DEBUG_LEX_PASS
2101 : printf("%s is a syntax token \n", yytext);
2102 : #endif
2103 : add_token(yytext,preproc_line_num,preproc_column_num,C_CXX_SYNTAX);
2104 : // preproc_column_num++;
2105 : }
2106 : YY_BREAK
2107 : case 16:
2108 : YY_RULE_SETUP
2109 : #line 935 "../../../../rexompiler/src/frontend/SageIII/preproc-c.ll"
2110 : {
2111 : #if DEBUG_LEX_PASS
2112 : printf("%s is a syntax token \n", yytext);
2113 : #endif
2114 : add_token(yytext,preproc_line_num,preproc_column_num,C_CXX_SYNTAX);
2115 : // preproc_column_num++;
2116 : }
2117 : YY_BREAK
2118 : case 17:
2119 : YY_RULE_SETUP
2120 : #line 943 "../../../../rexompiler/src/frontend/SageIII/preproc-c.ll"
2121 : {
2122 : #if DEBUG_LEX_PASS
2123 : printf("%s is a syntax token \n", yytext);
2124 : #endif
2125 : add_token(yytext,preproc_line_num,preproc_column_num,C_CXX_SYNTAX);
2126 : // preproc_column_num++;
2127 : }
2128 : YY_BREAK
2129 : case 18:
2130 : YY_RULE_SETUP
2131 : #line 951 "../../../../rexompiler/src/frontend/SageIII/preproc-c.ll"
2132 : {
2133 : #if DEBUG_LEX_PASS
2134 : printf("%s is a syntax token \n", yytext);
2135 : #endif
2136 : add_token(yytext,preproc_line_num,preproc_column_num,C_CXX_SYNTAX);
2137 : // preproc_column_num++;
2138 : }
2139 : YY_BREAK
2140 : case 19:
2141 : YY_RULE_SETUP
2142 : #line 959 "../../../../rexompiler/src/frontend/SageIII/preproc-c.ll"
2143 : {
2144 : #if DEBUG_LEX_PASS
2145 : printf("%s is a syntax token \n", yytext);
2146 : #endif
2147 : // preproc_column_num++;
2148 : add_token(yytext,preproc_line_num,preproc_column_num,C_CXX_SYNTAX);
2149 : }
2150 : YY_BREAK
2151 : case 20:
2152 : YY_RULE_SETUP
2153 : #line 967 "../../../../rexompiler/src/frontend/SageIII/preproc-c.ll"
2154 : {
2155 : #if DEBUG_LEX_PASS
2156 : printf("%s is a syntax token \n", yytext);
2157 : #endif
2158 : // preproc_column_num++;
2159 : add_token(yytext,preproc_line_num,preproc_column_num,C_CXX_SYNTAX);
2160 : }
2161 : YY_BREAK
2162 : case 21:
2163 : YY_RULE_SETUP
2164 : #line 975 "../../../../rexompiler/src/frontend/SageIII/preproc-c.ll"
2165 : {
2166 : #if DEBUG_LEX_PASS
2167 : printf("%s is a syntax token \n", yytext);
2168 : #endif
2169 : // preproc_column_num += 2;
2170 : add_token(yytext,preproc_line_num,preproc_column_num,C_CXX_SYNTAX);
2171 : }
2172 : YY_BREAK
2173 : case 22:
2174 : YY_RULE_SETUP
2175 : #line 983 "../../../../rexompiler/src/frontend/SageIII/preproc-c.ll"
2176 : {
2177 : #if DEBUG_LEX_PASS
2178 : printf("%s is a syntax token \n", yytext);
2179 : #endif
2180 : // preproc_column_num += 2;
2181 : add_token(yytext,preproc_line_num,preproc_column_num,C_CXX_SYNTAX);
2182 : }
2183 : YY_BREAK
2184 : case 23:
2185 : YY_RULE_SETUP
2186 : #line 991 "../../../../rexompiler/src/frontend/SageIII/preproc-c.ll"
2187 : {
2188 : #if DEBUG_LEX_PASS
2189 : printf("%s is a syntax token \n", yytext);
2190 : #endif
2191 : // preproc_column_num += 2;
2192 : add_token(yytext,preproc_line_num,preproc_column_num,C_CXX_SYNTAX);
2193 : }
2194 : YY_BREAK
2195 : case 24:
2196 : YY_RULE_SETUP
2197 : #line 999 "../../../../rexompiler/src/frontend/SageIII/preproc-c.ll"
2198 : {
2199 : #if DEBUG_LEX_PASS
2200 : printf("%s is a syntax token \n", yytext);
2201 : #endif
2202 : // preproc_column_num += 2;
2203 : add_token(yytext,preproc_line_num,preproc_column_num,C_CXX_SYNTAX);
2204 : }
2205 : YY_BREAK
2206 : case 25:
2207 : YY_RULE_SETUP
2208 : #line 1007 "../../../../rexompiler/src/frontend/SageIII/preproc-c.ll"
2209 : {
2210 : #if DEBUG_LEX_PASS
2211 : printf("%s is a syntax token \n", yytext);
2212 : #endif
2213 : // preproc_column_num += 2;
2214 : add_token(yytext,preproc_line_num,preproc_column_num,C_CXX_SYNTAX);
2215 : }
2216 : YY_BREAK
2217 : case 26:
2218 : YY_RULE_SETUP
2219 : #line 1015 "../../../../rexompiler/src/frontend/SageIII/preproc-c.ll"
2220 : {
2221 : #if DEBUG_LEX_PASS
2222 : printf("%s is a syntax token \n", yytext);
2223 : #endif
2224 : // preproc_column_num += 2;
2225 : add_token(yytext,preproc_line_num,preproc_column_num,C_CXX_SYNTAX);
2226 : }
2227 : YY_BREAK
2228 : case 27:
2229 : YY_RULE_SETUP
2230 : #line 1023 "../../../../rexompiler/src/frontend/SageIII/preproc-c.ll"
2231 : {
2232 : #if DEBUG_LEX_PASS
2233 : printf("%s is a syntax token \n", yytext);
2234 : #endif
2235 : // preproc_column_num += 2;
2236 : add_token(yytext,preproc_line_num,preproc_column_num,C_CXX_SYNTAX);
2237 : }
2238 : YY_BREAK
2239 : case 28:
2240 : YY_RULE_SETUP
2241 : #line 1031 "../../../../rexompiler/src/frontend/SageIII/preproc-c.ll"
2242 : {
2243 : #if DEBUG_LEX_PASS
2244 : printf("%s is a syntax token \n", yytext);
2245 : #endif
2246 : add_token(yytext,preproc_line_num,preproc_column_num,C_CXX_SYNTAX);
2247 : // preproc_column_num++;
2248 : }
2249 : YY_BREAK
2250 : case 29:
2251 : YY_RULE_SETUP
2252 : #line 1039 "../../../../rexompiler/src/frontend/SageIII/preproc-c.ll"
2253 : {
2254 : #if DEBUG_LEX_PASS
2255 : printf("%s is a syntax token \n", yytext);
2256 : #endif
2257 : add_token(yytext,preproc_line_num,preproc_column_num,C_CXX_SYNTAX);
2258 : // preproc_column_num++;
2259 : }
2260 : YY_BREAK
2261 : case 30:
2262 : YY_RULE_SETUP
2263 : #line 1047 "../../../../rexompiler/src/frontend/SageIII/preproc-c.ll"
2264 : {
2265 : #if DEBUG_LEX_PASS
2266 : printf("%s is a syntax token \n", yytext);
2267 : #endif
2268 : add_token(yytext,preproc_line_num,preproc_column_num,C_CXX_SYNTAX);
2269 : // preproc_column_num++;
2270 : }
2271 : YY_BREAK
2272 : case 31:
2273 : YY_RULE_SETUP
2274 : #line 1055 "../../../../rexompiler/src/frontend/SageIII/preproc-c.ll"
2275 : {
2276 : #if DEBUG_LEX_PASS
2277 : printf("%s is a syntax token \n", yytext);
2278 : #endif
2279 : add_token(yytext,preproc_line_num,preproc_column_num,C_CXX_SYNTAX);
2280 : // preproc_column_num++;
2281 : }
2282 : YY_BREAK
2283 : case 32:
2284 : YY_RULE_SETUP
2285 : #line 1063 "../../../../rexompiler/src/frontend/SageIII/preproc-c.ll"
2286 : {
2287 : #if DEBUG_LEX_PASS
2288 : printf("%s is a syntax token \n", yytext);
2289 : #endif
2290 : add_token(yytext,preproc_line_num,preproc_column_num,C_CXX_SYNTAX);
2291 : // preproc_column_num++;
2292 : }
2293 : YY_BREAK
2294 : case 33:
2295 : YY_RULE_SETUP
2296 : #line 1071 "../../../../rexompiler/src/frontend/SageIII/preproc-c.ll"
2297 : {
2298 : #if DEBUG_LEX_PASS
2299 : printf("%s is a syntax token \n", yytext);
2300 : #endif
2301 : add_token(yytext,preproc_line_num,preproc_column_num,C_CXX_SYNTAX);
2302 : // preproc_column_num++;
2303 : }
2304 : YY_BREAK
2305 : case 34:
2306 : YY_RULE_SETUP
2307 : #line 1079 "../../../../rexompiler/src/frontend/SageIII/preproc-c.ll"
2308 : {
2309 : // MS (7/14/2020): C++14 support for "'" in numbers, also added binary/hex prefix (octal is implicit)
2310 : // DQ (9/29/2013): This does not accound for 0L to be a single literal
2311 : #if DEBUG_LEX_PASS
2312 : printf("%s is a numeric literal token \n", yytext);
2313 : #endif
2314 : add_token(yytext,preproc_line_num,preproc_column_num,0);
2315 : // preproc_column_num += strlen(yytext);
2316 : }
2317 : YY_BREAK
2318 : case 35:
2319 : YY_RULE_SETUP
2320 : #line 1089 "../../../../rexompiler/src/frontend/SageIII/preproc-c.ll"
2321 : {
2322 : #if DEBUG_LEX_PASS
2323 : printf("%s is a whitespace token (length = %" PRIuPTR ") \n",yytext,strlen(yytext));
2324 : #endif
2325 : add_token(yytext,preproc_line_num,preproc_column_num,C_CXX_SYNTAX);
2326 : }
2327 : YY_BREAK
2328 : case 36:
2329 : YY_RULE_SETUP
2330 : #line 1096 "../../../../rexompiler/src/frontend/SageIII/preproc-c.ll"
2331 : {
2332 : #if DEBUG_LEX_PASS
2333 : printf("%s is a whitespace token (length = %" PRIuPTR ") \n",yytext,strlen(yytext));
2334 : #endif
2335 : add_token(yytext,preproc_line_num,preproc_column_num,C_CXX_SYNTAX);
2336 : }
2337 : YY_BREAK
2338 : case 37:
2339 : YY_RULE_SETUP
2340 : #line 1103 "../../../../rexompiler/src/frontend/SageIII/preproc-c.ll"
2341 : {
2342 : #if DEBUG_LEX_PASS
2343 : printf("%s is a whitespace token (length = %" PRIuPTR ") \n",yytext,strlen(yytext));
2344 : #endif
2345 : add_token(yytext,preproc_line_num,preproc_column_num,C_CXX_WHITESPACE);
2346 : }
2347 : YY_BREAK
2348 : case 38:
2349 : YY_RULE_SETUP
2350 : #line 1110 "../../../../rexompiler/src/frontend/SageIII/preproc-c.ll"
2351 : {
2352 : #if 1
2353 : #if DEBUG_LEX_PASS
2354 : printf("%s matched identifier regex \n",yytext);
2355 : #endif
2356 : add_token(yytext,preproc_line_num,preproc_column_num,0);
2357 : #else
2358 : token_element *p_tok_elem = new token_element;
2359 : p_tok_elem->token_lexeme = yytext;
2360 :
2361 : int is_keyword = identify_if_C_CXX_keyword(yytext);
2362 :
2363 : #if DEBUG_LEX_PASS
2364 : printf("%s is either a %s token \n",yytext,(is_keyword != -1) ? "keyword" : "identifier");
2365 : #endif
2366 :
2367 : // found a keyword?
2368 : if(is_keyword != -1)
2369 : {
2370 : // printf("%s is a keyword\n", yytext);
2371 : p_tok_elem->token_id = is_keyword;
2372 : }
2373 : else
2374 : {
2375 : // printf("%s is not a keyword\n", yytext);
2376 : p_tok_elem->token_id = C_CXX_IDENTIFIER;
2377 : }
2378 :
2379 : stream_element *p_se = new stream_element;
2380 : p_se->p_tok_elem = p_tok_elem;
2381 :
2382 : // DQ (9/29/2013): uncommented so that we can
2383 : // set the source position.
2384 : // p_se->beginning_fpi.line_num = preproc_column_num;
2385 : p_se->beginning_fpi.line_num = preproc_line_num;
2386 : p_se->beginning_fpi.column_num = preproc_column_num;
2387 : preproc_column_num += strlen(yytext);
2388 : p_se->ending_fpi.line_num = preproc_line_num;
2389 : p_se->ending_fpi.column_num = preproc_column_num-1;
2390 :
2391 : // push the element onto the token stream
2392 : ROSE_token_stream_pointer->push_back(p_se);
2393 : #endif
2394 : }
2395 : YY_BREAK
2396 : /*begin handling the C++ style comments. */
2397 : case 39:
2398 : YY_RULE_SETUP
2399 : #line 1156 "../../../../rexompiler/src/frontend/SageIII/preproc-c.ll"
2400 : {
2401 : /*Handle the C comments.*/
2402 : preproc_start_line_num=preproc_line_num;
2403 : preproc_start_column_num=preproc_column_num;
2404 : preproc_column_num+=2;
2405 : commentString = yytext;
2406 : BEGIN CXX_COMMENT;
2407 : }
2408 : YY_BREAK
2409 : /*The normal mode actions. Handle the preprocessor stuff and any other characters. */
2410 : /*Do we need the backslash character?????????????*/
2411 : case 40:
2412 : YY_RULE_SETUP
2413 : #line 1167 "../../../../rexompiler/src/frontend/SageIII/preproc-c.ll"
2414 : {
2415 : preproc_start_line_num=preproc_line_num;
2416 : preproc_start_column_num=preproc_column_num;
2417 : preproc_column_num+=strlen(yytext);
2418 :
2419 : //copy the comment to commentString
2420 : commentString = yytext;
2421 : BEGIN C_COMMENT;
2422 : }
2423 : YY_BREAK
2424 : /* These are the alternative tokens. Refer to page 12 of C++ std to understand their representation */
2425 : /*<NORMAL>"<%" {curr_token = ALT_LEFT_CURLY; do_yytext_bookeeping(); }
2426 : <NORMAL>"<%" { }
2427 : */
2428 : /* DQ (9/29/2013): I think this should not be here, it can't be matched given that we handle identifiers above. */
2429 : /*
2430 : <NORMAL>"static_cast" {
2431 : #if DEBUG_LEX_PASS
2432 : printf("%s is a static_cast token \n",yytext);
2433 : #endif
2434 : preproc_column_num++;
2435 : }
2436 : */
2437 : case 41:
2438 : YY_RULE_SETUP
2439 : #line 1194 "../../../../rexompiler/src/frontend/SageIII/preproc-c.ll"
2440 : { macrotype=PreprocessingInfo::CpreprocessorIncludeDeclaration; HANDLEMACROSTART }
2441 : YY_BREAK
2442 : case 42:
2443 : YY_RULE_SETUP
2444 : #line 1195 "../../../../rexompiler/src/frontend/SageIII/preproc-c.ll"
2445 : { macrotype=PreprocessingInfo::CpreprocessorDefineDeclaration; HANDLEMACROSTART }
2446 : YY_BREAK
2447 : case 43:
2448 : YY_RULE_SETUP
2449 : #line 1196 "../../../../rexompiler/src/frontend/SageIII/preproc-c.ll"
2450 : { macrotype=PreprocessingInfo::CpreprocessorUndefDeclaration; HANDLEMACROSTART }
2451 : YY_BREAK
2452 : case 44:
2453 : YY_RULE_SETUP
2454 : #line 1197 "../../../../rexompiler/src/frontend/SageIII/preproc-c.ll"
2455 : { macrotype=PreprocessingInfo::CpreprocessorLineDeclaration; HANDLEMACROSTART }
2456 : YY_BREAK
2457 : case 45:
2458 : YY_RULE_SETUP
2459 : #line 1198 "../../../../rexompiler/src/frontend/SageIII/preproc-c.ll"
2460 : { macrotype=PreprocessingInfo::CpreprocessorErrorDeclaration; HANDLEMACROSTART }
2461 : YY_BREAK
2462 : case 46:
2463 : YY_RULE_SETUP
2464 : #line 1199 "../../../../rexompiler/src/frontend/SageIII/preproc-c.ll"
2465 : { macrotype=PreprocessingInfo::CpreprocessorIfDeclaration; HANDLEMACROSTART }
2466 : YY_BREAK
2467 : case 47:
2468 : YY_RULE_SETUP
2469 : #line 1200 "../../../../rexompiler/src/frontend/SageIII/preproc-c.ll"
2470 : { macrotype=PreprocessingInfo::CpreprocessorIfdefDeclaration; HANDLEMACROSTART }
2471 : YY_BREAK
2472 : case 48:
2473 : YY_RULE_SETUP
2474 : #line 1201 "../../../../rexompiler/src/frontend/SageIII/preproc-c.ll"
2475 : { macrotype=PreprocessingInfo::CpreprocessorIfndefDeclaration; HANDLEMACROSTART }
2476 : YY_BREAK
2477 : case 49:
2478 : YY_RULE_SETUP
2479 : #line 1202 "../../../../rexompiler/src/frontend/SageIII/preproc-c.ll"
2480 : { macrotype=PreprocessingInfo::CpreprocessorElifDeclaration; HANDLEMACROSTART }
2481 : YY_BREAK
2482 : case 50:
2483 : YY_RULE_SETUP
2484 : #line 1203 "../../../../rexompiler/src/frontend/SageIII/preproc-c.ll"
2485 : { macrotype=PreprocessingInfo::CpreprocessorElseDeclaration; HANDLEMACROSTART }
2486 : YY_BREAK
2487 : case 51:
2488 : YY_RULE_SETUP
2489 : #line 1204 "../../../../rexompiler/src/frontend/SageIII/preproc-c.ll"
2490 : { macrotype=PreprocessingInfo::CpreprocessorEndifDeclaration; HANDLEMACROSTART }
2491 : YY_BREAK
2492 : case 52:
2493 : YY_RULE_SETUP
2494 : #line 1205 "../../../../rexompiler/src/frontend/SageIII/preproc-c.ll"
2495 : { macrotype=PreprocessingInfo::CpreprocessorWarningDeclaration; HANDLEMACROSTART }
2496 : YY_BREAK
2497 : /* DQ (9/30/2013): Added support to recognize #pragma as a token */
2498 : case 53:
2499 : YY_RULE_SETUP
2500 : #line 1208 "../../../../rexompiler/src/frontend/SageIII/preproc-c.ll"
2501 : {
2502 : add_token(yytext,preproc_line_num,preproc_column_num,C_CXX_PRAGMA);
2503 : }
2504 : YY_BREAK
2505 : /*Add code here to attach the whitespace before newlines (and general lineprefix code) */
2506 : case 54:
2507 : /* rule 54 can match eol */
2508 : YY_RULE_SETUP
2509 : #line 1213 "../../../../rexompiler/src/frontend/SageIII/preproc-c.ll"
2510 : {
2511 : add_token(yytext,preproc_line_num,preproc_column_num,C_CXX_WHITESPACE);
2512 : preproc_line_num++;
2513 : preproc_column_num = 1;
2514 : }
2515 : YY_BREAK
2516 : case 55:
2517 : YY_RULE_SETUP
2518 : #line 1219 "../../../../rexompiler/src/frontend/SageIII/preproc-c.ll"
2519 : {
2520 : /* preproc_line_num+=num_of_newlines(yytext); */
2521 : add_token(yytext,preproc_line_num,preproc_column_num,0);
2522 : // preproc_column_num+=strlen(yytext);
2523 : BEGIN STRING_LIT;
2524 : }
2525 : YY_BREAK
2526 : case 56:
2527 : YY_RULE_SETUP
2528 : #line 1226 "../../../../rexompiler/src/frontend/SageIII/preproc-c.ll"
2529 : {
2530 : /*preproc_line_num+=num_of_newlines(yytext);*/
2531 : #if DEBUG_LEX_PASS
2532 : printf("char literal BEGIN.");
2533 : #endif
2534 : add_token(yytext,preproc_line_num,preproc_column_num,0);
2535 : // preproc_column_num+=strlen(yytext);
2536 : BEGIN CHAR_LIT;
2537 : }
2538 : YY_BREAK
2539 : case 57:
2540 : YY_RULE_SETUP
2541 : #line 1236 "../../../../rexompiler/src/frontend/SageIII/preproc-c.ll"
2542 : { preproc_column_num++; }
2543 : YY_BREAK
2544 : /* Actions for character literals. Since the part between single quote can be more than one
2545 : * character of input (e.g., '\\', '\'', '\n', '\012', etc) we parse them sort of like strings. */
2546 : case 58:
2547 : /* rule 58 can match eol */
2548 : YY_RULE_SETUP
2549 : #line 1240 "../../../../rexompiler/src/frontend/SageIII/preproc-c.ll"
2550 : {/*eat escaped DOS line-term*/ preproc_line_num++; preproc_column_num=1; }
2551 : YY_BREAK
2552 : case 59:
2553 : /* rule 59 can match eol */
2554 : YY_RULE_SETUP
2555 : #line 1241 "../../../../rexompiler/src/frontend/SageIII/preproc-c.ll"
2556 : {/*eat escaped linefeed*/ preproc_line_num++; preproc_column_num=1; }
2557 : YY_BREAK
2558 : case 60:
2559 : YY_RULE_SETUP
2560 : #line 1242 "../../../../rexompiler/src/frontend/SageIII/preproc-c.ll"
2561 : {/*eat escaped something*/ add_token(yytext,preproc_line_num,preproc_column_num,0); /*preproc_column_num+=strlen(yytext);*/ }
2562 : YY_BREAK
2563 : case 61:
2564 : YY_RULE_SETUP
2565 : #line 1243 "../../../../rexompiler/src/frontend/SageIII/preproc-c.ll"
2566 : {/*eat non-special characters*/ add_token(yytext,preproc_line_num,preproc_column_num,0); /*preproc_column_num+=strlen(yytext);*/ }
2567 : YY_BREAK
2568 : case 62:
2569 : /* rule 62 can match eol */
2570 : YY_RULE_SETUP
2571 : #line 1244 "../../../../rexompiler/src/frontend/SageIII/preproc-c.ll"
2572 : {/*eat DOS line-term*/ preproc_line_num++; preproc_column_num=1; }
2573 : YY_BREAK
2574 : case 63:
2575 : /* rule 63 can match eol */
2576 : YY_RULE_SETUP
2577 : #line 1245 "../../../../rexompiler/src/frontend/SageIII/preproc-c.ll"
2578 : {/*eat linefeed*/ preproc_line_num++; preproc_column_num=1; }
2579 : YY_BREAK
2580 : case 64:
2581 : YY_RULE_SETUP
2582 : #line 1246 "../../../../rexompiler/src/frontend/SageIII/preproc-c.ll"
2583 : {
2584 : /*end of character literal*/
2585 : add_token(yytext,preproc_line_num,preproc_column_num,0);
2586 : // preproc_column_num+=strlen(yytext);
2587 : #if DEBUG_LEX_PASS
2588 : printf("char literal END.");
2589 : #endif
2590 : BEGIN NORMAL;
2591 : }
2592 : YY_BREAK
2593 : /* Actions for string literals. */
2594 : case 65:
2595 : /* rule 65 can match eol */
2596 : YY_RULE_SETUP
2597 : #line 1259 "../../../../rexompiler/src/frontend/SageIII/preproc-c.ll"
2598 : {/*eat escaped DOS line-term*/ add_token(yytext,preproc_line_num,preproc_column_num,0); preproc_line_num++; preproc_column_num=1; }
2599 : YY_BREAK
2600 : case 66:
2601 : /* rule 66 can match eol */
2602 : YY_RULE_SETUP
2603 : #line 1260 "../../../../rexompiler/src/frontend/SageIII/preproc-c.ll"
2604 : {/*eat escaped linefeed*/ add_token(yytext,preproc_line_num,preproc_column_num,0); preproc_line_num++; preproc_column_num=1; }
2605 : YY_BREAK
2606 : case 67:
2607 : YY_RULE_SETUP
2608 : #line 1261 "../../../../rexompiler/src/frontend/SageIII/preproc-c.ll"
2609 : {/*eat escaped something*/ add_token(yytext,preproc_line_num,preproc_column_num,0); /*preproc_column_num+=strlen(yytext);*/ }
2610 : YY_BREAK
2611 : case 68:
2612 : /* rule 68 can match eol */
2613 : YY_RULE_SETUP
2614 : #line 1262 "../../../../rexompiler/src/frontend/SageIII/preproc-c.ll"
2615 : {/*eat DOS line-term*/ add_token(yytext,preproc_line_num,preproc_column_num,0); preproc_line_num++; preproc_column_num=1; }
2616 : YY_BREAK
2617 : case 69:
2618 : YY_RULE_SETUP
2619 : #line 1263 "../../../../rexompiler/src/frontend/SageIII/preproc-c.ll"
2620 : {/*eat non-special characters*/ add_token(yytext,preproc_line_num,preproc_column_num,0); /*preproc_column_num+=strlen(yytext)*/; }
2621 : YY_BREAK
2622 : case 70:
2623 : /* rule 70 can match eol */
2624 : YY_RULE_SETUP
2625 : #line 1264 "../../../../rexompiler/src/frontend/SageIII/preproc-c.ll"
2626 : {/*eat linefeed*/ add_token(yytext,preproc_line_num,preproc_column_num,0); preproc_line_num++; preproc_column_num=1; }
2627 : YY_BREAK
2628 : case 71:
2629 : YY_RULE_SETUP
2630 : #line 1265 "../../../../rexompiler/src/frontend/SageIII/preproc-c.ll"
2631 : {
2632 : /* end of string literal */
2633 : add_token(yytext,preproc_line_num,preproc_column_num,0);
2634 : // preproc_column_num+=strlen(yytext);
2635 : BEGIN NORMAL;
2636 : }
2637 : YY_BREAK
2638 : /*Actions for a C++ style comment.*/
2639 : case 72:
2640 : YY_RULE_SETUP
2641 : #line 1273 "../../../../rexompiler/src/frontend/SageIII/preproc-c.ll"
2642 : { /* eat anything that is not a backslash or a newline*/ commentString += yytext;}
2643 : YY_BREAK
2644 : case 73:
2645 : YY_RULE_SETUP
2646 : #line 1274 "../../../../rexompiler/src/frontend/SageIII/preproc-c.ll"
2647 : {
2648 : /*eat up backslashes not immdediately followed by newlines*/
2649 : commentString += yytext;
2650 : /*fix the preproc_column_num at other places ???????????????????? ??????????????*/
2651 : preproc_column_num=1;
2652 : }
2653 : YY_BREAK
2654 : case 74:
2655 : /* rule 74 can match eol */
2656 : YY_RULE_SETUP
2657 : #line 1281 "../../../../rexompiler/src/frontend/SageIII/preproc-c.ll"
2658 : {
2659 : /*if backslash is followed by a newline, then eat them (backslash, newline) up, increment preproc_line_num and continue*/
2660 : commentString += yytext;
2661 : preproc_line_num++;
2662 : }
2663 : YY_BREAK
2664 : case 75:
2665 : /* rule 75 can match eol */
2666 : YY_RULE_SETUP
2667 : #line 1287 "../../../../rexompiler/src/frontend/SageIII/preproc-c.ll"
2668 : {
2669 : preproc_line_num++; preproc_column_num=1;
2670 : commentString += yytext;
2671 : preprocessorList.addElement(PreprocessingInfo::CplusplusStyleComment,
2672 : commentString,globalFileName, preproc_start_line_num, preproc_start_column_num,preproc_line_num-preproc_start_line_num);
2673 :
2674 : // This element of the token stream is special since it is from a PreprocessorInfo object.
2675 : add_preprocessingInfo_to_token_stream(preprocessorList.lastElement(),preproc_start_line_num,preproc_start_column_num,preproc_line_num-preproc_start_line_num);
2676 :
2677 : BEGIN NORMAL;
2678 : }
2679 : YY_BREAK
2680 : /* negara1 (07/25/2011): Added handling of CXX comments that appear at the last line of a file. */
2681 : case YY_STATE_EOF(CXX_COMMENT):
2682 : #line 1300 "../../../../rexompiler/src/frontend/SageIII/preproc-c.ll"
2683 : {
2684 : preprocessorList.addElement(PreprocessingInfo::CplusplusStyleComment,
2685 : commentString,globalFileName, preproc_start_line_num, preproc_start_column_num,preproc_line_num-preproc_start_line_num);
2686 :
2687 : // This element of the token stream is special since it is from a PreprocessorInfo object.
2688 : add_preprocessingInfo_to_token_stream(preprocessorList.lastElement(),preproc_start_line_num,preproc_start_column_num,preproc_line_num-preproc_start_line_num);
2689 :
2690 : yyterminate();
2691 : }
2692 : YY_BREAK
2693 : /*Actions while in a C style comment.*/
2694 : case 76:
2695 : /* rule 76 can match eol */
2696 : YY_RULE_SETUP
2697 : #line 1311 "../../../../rexompiler/src/frontend/SageIII/preproc-c.ll"
2698 : {
2699 : commentString += yytext;
2700 : preproc_line_num++;
2701 : preproc_column_num=1;
2702 : }
2703 : YY_BREAK
2704 : case 77:
2705 : YY_RULE_SETUP
2706 : #line 1316 "../../../../rexompiler/src/frontend/SageIII/preproc-c.ll"
2707 : {
2708 : commentString += yytext;
2709 : preproc_column_num+=strlen(yytext);
2710 : /* printf("hello Ram: The comment string is ####%s#############. It is of %d lines, the current line number is %d\n",commentString.c_str(), preproc_line_num-preproc_start_line_num+1, preproc_line_num);
2711 : */
2712 : // DQ (10/1/2013): This is a bug fix the number of lines should be computed using
2713 : // "preproc_line_num-preproc_start_line_num" not "preproc_line_num-preproc_start_line_num+1"
2714 : // preprocessorList.addElement(PreprocessingInfo::C_StyleComment,commentString,globalFileName,preproc_start_line_num,preproc_start_column_num,preproc_line_num-preproc_start_line_num+1);
2715 : preprocessorList.addElement(PreprocessingInfo::C_StyleComment,commentString,globalFileName,preproc_start_line_num,preproc_start_column_num,preproc_line_num-preproc_start_line_num);
2716 :
2717 : // This element of the token stream is special since it is from a PreprocessorInfo object.
2718 : add_preprocessingInfo_to_token_stream(preprocessorList.lastElement(),preproc_start_line_num,preproc_start_column_num,preproc_line_num-preproc_start_line_num);
2719 :
2720 : BEGIN(NORMAL);
2721 :
2722 : }
2723 : YY_BREAK
2724 : case 78:
2725 : YY_RULE_SETUP
2726 : #line 1332 "../../../../rexompiler/src/frontend/SageIII/preproc-c.ll"
2727 : {
2728 : commentString += yytext;
2729 : preproc_column_num++;
2730 : }
2731 : YY_BREAK
2732 : /*Actions while in a MACRO.*/
2733 : case 79:
2734 : /* rule 79 can match eol */
2735 : YY_RULE_SETUP
2736 : #line 1338 "../../../../rexompiler/src/frontend/SageIII/preproc-c.ll"
2737 : { // Escaped DOS line termination
2738 : #if DEBUG_LEX_PASS
2739 : printf("%s is an escaped windows line ending token in a CPP directive (length = %" PRIuPTR ") \n",yytext,strlen(yytext));
2740 : #endif
2741 : macroString += yytext;
2742 : ++preproc_line_num;
2743 : preproc_column_num = 1;
2744 : }
2745 : YY_BREAK
2746 : case 80:
2747 : /* rule 80 can match eol */
2748 : YY_RULE_SETUP
2749 : #line 1347 "../../../../rexompiler/src/frontend/SageIII/preproc-c.ll"
2750 : { // Escape line termination
2751 : macroString += yytext;
2752 : ++preproc_line_num;
2753 : preproc_column_num = 1;
2754 : }
2755 : YY_BREAK
2756 : case 81:
2757 : /* rule 81 can match eol */
2758 : YY_RULE_SETUP
2759 : #line 1353 "../../../../rexompiler/src/frontend/SageIII/preproc-c.ll"
2760 : { // End of macro
2761 :
2762 : // DQ (12/30/2018): This is where windows line endings are normalized, and we need to supress this.
2763 : // macroString = Rose::StringUtility::fixLineTermination(macroString + yytext);
2764 : macroString = macroString + yytext;
2765 :
2766 : preproc_line_num++;
2767 : preproc_column_num=1;
2768 : preprocessorList.addElement(macrotype, macroString, globalFileName,
2769 : preproc_start_line_num, preproc_start_column_num,
2770 : preproc_line_num-preproc_start_line_num);
2771 :
2772 : // This element of the token stream is special since it is from a PreprocessorInfo object.
2773 : add_preprocessingInfo_to_token_stream(preprocessorList.lastElement(),preproc_start_line_num,preproc_start_column_num,preproc_line_num-preproc_start_line_num);
2774 : BEGIN NORMAL;
2775 : }
2776 : YY_BREAK
2777 : case YY_STATE_EOF(MACRO):
2778 : #line 1370 "../../../../rexompiler/src/frontend/SageIII/preproc-c.ll"
2779 : { // End of macro
2780 :
2781 : // DQ (12/30/2018): This is where windows line endings are normalized, and we need to supress this.
2782 : // macroString = Rose::StringUtility::fixLineTermination(macroString + yytext);
2783 : macroString = macroString + yytext;
2784 :
2785 : preprocessorList.addElement(macrotype, macroString, globalFileName,
2786 : preproc_start_line_num, preproc_start_column_num,
2787 : preproc_line_num-preproc_start_line_num);
2788 :
2789 : // This element of the token stream is special since it is from a PreprocessorInfo object.
2790 : add_preprocessingInfo_to_token_stream(preprocessorList.lastElement(),preproc_start_line_num,preproc_start_column_num,preproc_line_num-preproc_start_line_num);
2791 :
2792 : yyterminate();
2793 : }
2794 : YY_BREAK
2795 : case 82:
2796 : YY_RULE_SETUP
2797 : #line 1386 "../../../../rexompiler/src/frontend/SageIII/preproc-c.ll"
2798 : {
2799 : preproc_column_num+=2;
2800 : macroString += yytext;
2801 : BEGIN STRING_LIT_IN_MACRO;
2802 : }
2803 : YY_BREAK
2804 : case 83:
2805 : YY_RULE_SETUP
2806 : #line 1392 "../../../../rexompiler/src/frontend/SageIII/preproc-c.ll"
2807 : {
2808 : preproc_column_num+=2;
2809 : macroString += yytext;
2810 : BEGIN C_COMMENT_INMACRO;
2811 : }
2812 : YY_BREAK
2813 : case 84:
2814 : YY_RULE_SETUP
2815 : #line 1398 "../../../../rexompiler/src/frontend/SageIII/preproc-c.ll"
2816 : { // Add character to macro string; we'll fix up line termination issues at the end of the <MACRO> state.
2817 : macroString += yytext;
2818 : preproc_column_num++;
2819 : }
2820 : YY_BREAK
2821 : /* MS 08/31/2020: added special case of string literal inside macro; note GNU allows single double quotes in macros, but EDG rejects it */
2822 : /* Actions for string literals. */
2823 : case 85:
2824 : /* rule 85 can match eol */
2825 : YY_RULE_SETUP
2826 : #line 1406 "../../../../rexompiler/src/frontend/SageIII/preproc-c.ll"
2827 : {/*eat escaped DOS line-term*/ preproc_line_num++; preproc_column_num=1; macroString += yytext;}
2828 : YY_BREAK
2829 : case 86:
2830 : /* rule 86 can match eol */
2831 : YY_RULE_SETUP
2832 : #line 1407 "../../../../rexompiler/src/frontend/SageIII/preproc-c.ll"
2833 : {/*eat escaped linefeed*/ preproc_line_num++; preproc_column_num=1; macroString += yytext;}
2834 : YY_BREAK
2835 : case 87:
2836 : YY_RULE_SETUP
2837 : #line 1408 "../../../../rexompiler/src/frontend/SageIII/preproc-c.ll"
2838 : {/*eat escaped something*/ /*preproc_column_num+=strlen(yytext);*/macroString += yytext; }
2839 : YY_BREAK
2840 : case 88:
2841 : /* rule 88 can match eol */
2842 : YY_RULE_SETUP
2843 : #line 1409 "../../../../rexompiler/src/frontend/SageIII/preproc-c.ll"
2844 : {/*eat DOS line-term*/ preproc_line_num++; preproc_column_num=1; macroString += yytext;}
2845 : YY_BREAK
2846 : case 89:
2847 : YY_RULE_SETUP
2848 : #line 1410 "../../../../rexompiler/src/frontend/SageIII/preproc-c.ll"
2849 : {/*eat non-special characters*/ preproc_column_num+=strlen(yytext);macroString += yytext; }
2850 : YY_BREAK
2851 : case 90:
2852 : /* rule 90 can match eol */
2853 : YY_RULE_SETUP
2854 : #line 1411 "../../../../rexompiler/src/frontend/SageIII/preproc-c.ll"
2855 : {/*eat linefeed*/ preproc_line_num++; preproc_column_num=1; macroString += yytext;}
2856 : YY_BREAK
2857 : case 91:
2858 : YY_RULE_SETUP
2859 : #line 1412 "../../../../rexompiler/src/frontend/SageIII/preproc-c.ll"
2860 : {
2861 : /* end of string literal */
2862 : macroString += yytext;
2863 : preproc_column_num+=strlen(yytext);
2864 : /* go back into macro state */
2865 : BEGIN MACRO;
2866 : }
2867 : YY_BREAK
2868 : case 92:
2869 : YY_RULE_SETUP
2870 : #line 1421 "../../../../rexompiler/src/frontend/SageIII/preproc-c.ll"
2871 : {
2872 : //This code copies the comment only into the macrobuffer, but not into comment buffer
2873 : macroString += yytext;
2874 :
2875 : /*
2876 : commentString += yytext;
2877 : //to add the comment as separate element use this:
2878 : preprocessorList.addElement(PreprocessingInfo::C_StyleComment,commentString.c_str(),globalFileName,preproc_start_line_num,preproc_start_column_num,preproc_line_num-preproc_start_line_num);
2879 : */
2880 : preproc_column_num+=strlen(yytext);
2881 : BEGIN MACRO;
2882 : }
2883 : YY_BREAK
2884 : case 93:
2885 : /* rule 93 can match eol */
2886 : YY_RULE_SETUP
2887 : #line 1433 "../../../../rexompiler/src/frontend/SageIII/preproc-c.ll"
2888 : {
2889 : macroString += yytext;
2890 : preproc_line_num++; preproc_column_num=1;
2891 : }
2892 : YY_BREAK
2893 : case 94:
2894 : YY_RULE_SETUP
2895 : #line 1437 "../../../../rexompiler/src/frontend/SageIII/preproc-c.ll"
2896 : {
2897 : macroString += yytext;
2898 : preproc_column_num++;
2899 : }
2900 : YY_BREAK
2901 : case 95:
2902 : YY_RULE_SETUP
2903 : #line 1441 "../../../../rexompiler/src/frontend/SageIII/preproc-c.ll"
2904 : ECHO;
2905 : YY_BREAK
2906 : #line 2907 "preproc-c.cc"
2907 : case YY_STATE_EOF(INITIAL):
2908 : case YY_STATE_EOF(NORMAL):
2909 : case YY_STATE_EOF(C_COMMENT):
2910 : case YY_STATE_EOF(STRING_LIT):
2911 : case YY_STATE_EOF(CHAR_LIT):
2912 : case YY_STATE_EOF(C_COMMENT_INMACRO):
2913 : case YY_STATE_EOF(STRING_LIT_IN_MACRO):
2914 : yyterminate();
2915 :
2916 641 : case YY_END_OF_BUFFER:
2917 641 : {
2918 : /* Amount of text matched not including the EOB char. */
2919 641 : int yy_amount_of_matched_text = (int) (yy_cp - (yytext_ptr)) - 1;
2920 :
2921 : /* Undo the effects of YY_DO_BEFORE_ACTION. */
2922 641 : *yy_cp = (yy_hold_char);
2923 : YY_RESTORE_YY_MORE_OFFSET
2924 :
2925 641 : if ( YY_CURRENT_BUFFER_LVALUE->yy_buffer_status == YY_BUFFER_NEW )
2926 : {
2927 : /* We're scanning a new file or input source. It's
2928 : * possible that this happened because the user
2929 : * just pointed yyin at a new source and called
2930 : * yylex(). If so, then we have to assure
2931 : * consistency between YY_CURRENT_BUFFER and our
2932 : * globals. Here is the right place to do so, because
2933 : * this is the first action (other than possibly a
2934 : * back-up) that will match for the new input source.
2935 : */
2936 316 : (yy_n_chars) = YY_CURRENT_BUFFER_LVALUE->yy_n_chars;
2937 316 : YY_CURRENT_BUFFER_LVALUE->yy_input_file = yyin;
2938 316 : YY_CURRENT_BUFFER_LVALUE->yy_buffer_status = YY_BUFFER_NORMAL;
2939 : }
2940 :
2941 : /* Note that here we test for yy_c_buf_p "<=" to the position
2942 : * of the first EOB in the buffer, since yy_c_buf_p will
2943 : * already have been incremented past the NUL character
2944 : * (since all states make transitions on EOB to the
2945 : * end-of-buffer state). Contrast this with the test
2946 : * in input().
2947 : */
2948 641 : if ( (yy_c_buf_p) <= &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[(yy_n_chars)] )
2949 : { /* This was really a NUL. */
2950 0 : yy_state_type yy_next_state;
2951 :
2952 0 : (yy_c_buf_p) = (yytext_ptr) + yy_amount_of_matched_text;
2953 :
2954 0 : yy_current_state = yy_get_previous_state( );
2955 :
2956 : /* Okay, we're now positioned to make the NUL
2957 : * transition. We couldn't have
2958 : * yy_get_previous_state() go ahead and do it
2959 : * for us because it doesn't know how to deal
2960 : * with the possibility of jamming (and we don't
2961 : * want to build jamming into it because then it
2962 : * will run more slowly).
2963 : */
2964 :
2965 0 : yy_next_state = yy_try_NUL_trans( yy_current_state );
2966 :
2967 0 : yy_bp = (yytext_ptr) + YY_MORE_ADJ;
2968 :
2969 0 : if ( yy_next_state )
2970 : {
2971 : /* Consume the NUL. */
2972 0 : yy_cp = ++(yy_c_buf_p);
2973 0 : yy_current_state = yy_next_state;
2974 0 : goto yy_match;
2975 : }
2976 :
2977 : else
2978 : {
2979 0 : yy_cp = (yy_c_buf_p);
2980 0 : goto yy_find_action;
2981 : }
2982 : }
2983 :
2984 641 : else switch ( yy_get_next_buffer( ) )
2985 : {
2986 316 : case EOB_ACT_END_OF_FILE:
2987 316 : {
2988 316 : (yy_did_buffer_switch_on_eof) = 0;
2989 :
2990 316 : if ( yywrap( ) )
2991 : {
2992 : /* Note: because we've taken care in
2993 : * yy_get_next_buffer() to have set up
2994 : * yytext, we can now set up
2995 : * yy_c_buf_p so that if some total
2996 : * hoser (like flex itself) wants to
2997 : * call the scanner after we return the
2998 : * YY_NULL, it'll still work - another
2999 : * YY_NULL will get returned.
3000 : */
3001 316 : (yy_c_buf_p) = (yytext_ptr) + YY_MORE_ADJ;
3002 :
3003 316 : yy_act = YY_STATE_EOF(YY_START);
3004 316 : goto do_action;
3005 : }
3006 :
3007 : else
3008 : {
3009 : if ( ! (yy_did_buffer_switch_on_eof) )
3010 : YY_NEW_FILE;
3011 : }
3012 : break;
3013 : }
3014 :
3015 325 : case EOB_ACT_CONTINUE_SCAN:
3016 325 : (yy_c_buf_p) =
3017 325 : (yytext_ptr) + yy_amount_of_matched_text;
3018 :
3019 325 : yy_current_state = yy_get_previous_state( );
3020 :
3021 325 : yy_cp = (yy_c_buf_p);
3022 325 : yy_bp = (yytext_ptr) + YY_MORE_ADJ;
3023 325 : goto yy_match;
3024 :
3025 0 : case EOB_ACT_LAST_MATCH:
3026 0 : (yy_c_buf_p) =
3027 0 : &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[(yy_n_chars)];
3028 :
3029 0 : yy_current_state = yy_get_previous_state( );
3030 :
3031 0 : yy_cp = (yy_c_buf_p);
3032 0 : yy_bp = (yytext_ptr) + YY_MORE_ADJ;
3033 0 : goto yy_find_action;
3034 : }
3035 : break;
3036 : }
3037 :
3038 0 : default:
3039 0 : YY_FATAL_ERROR(
3040 : "fatal flex scanner internal error--no action found" );
3041 : } /* end of action switch */
3042 : } /* end of scanning one token */
3043 : } /* end of user's declarations */
3044 : } /* end of yylex */
3045 :
3046 : /* yy_get_next_buffer - try to read in a new buffer
3047 : *
3048 : * Returns a code representing an action:
3049 : * EOB_ACT_LAST_MATCH -
3050 : * EOB_ACT_CONTINUE_SCAN - continue scanning from current position
3051 : * EOB_ACT_END_OF_FILE - end of file
3052 : */
3053 641 : static int yy_get_next_buffer (void)
3054 : {
3055 641 : char *dest = YY_CURRENT_BUFFER_LVALUE->yy_ch_buf;
3056 641 : char *source = (yytext_ptr);
3057 641 : int number_to_move, i;
3058 641 : int ret_val;
3059 :
3060 641 : if ( (yy_c_buf_p) > &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[(yy_n_chars) + 1] )
3061 0 : YY_FATAL_ERROR(
3062 : "fatal flex scanner internal error--end of buffer missed" );
3063 :
3064 641 : if ( YY_CURRENT_BUFFER_LVALUE->yy_fill_buffer == 0 )
3065 : { /* Don't try to fill the buffer, so this is an EOF. */
3066 0 : if ( (yy_c_buf_p) - (yytext_ptr) - YY_MORE_ADJ == 1 )
3067 : {
3068 : /* We matched a single character, the EOB, so
3069 : * treat this as a final EOF.
3070 : */
3071 : return EOB_ACT_END_OF_FILE;
3072 : }
3073 :
3074 : else
3075 : {
3076 : /* We matched some text prior to the EOB, first
3077 : * process it.
3078 : */
3079 0 : return EOB_ACT_LAST_MATCH;
3080 : }
3081 : }
3082 :
3083 : /* Try to read more data. */
3084 :
3085 : /* First move last chars to start of buffer. */
3086 641 : number_to_move = (int) ((yy_c_buf_p) - (yytext_ptr) - 1);
3087 :
3088 653 : for ( i = 0; i < number_to_move; ++i )
3089 12 : *(dest++) = *(source++);
3090 :
3091 641 : if ( YY_CURRENT_BUFFER_LVALUE->yy_buffer_status == YY_BUFFER_EOF_PENDING )
3092 : /* don't do the read, it's not guaranteed to return an EOF,
3093 : * just force an EOF
3094 : */
3095 0 : YY_CURRENT_BUFFER_LVALUE->yy_n_chars = (yy_n_chars) = 0;
3096 :
3097 : else
3098 : {
3099 641 : int num_to_read =
3100 641 : YY_CURRENT_BUFFER_LVALUE->yy_buf_size - number_to_move - 1;
3101 :
3102 641 : while ( num_to_read <= 0 )
3103 : { /* Not enough room in the buffer - grow it. */
3104 :
3105 : /* just a shorter name for the current buffer */
3106 0 : YY_BUFFER_STATE b = YY_CURRENT_BUFFER_LVALUE;
3107 :
3108 0 : int yy_c_buf_p_offset =
3109 0 : (int) ((yy_c_buf_p) - b->yy_ch_buf);
3110 :
3111 0 : if ( b->yy_is_our_buffer )
3112 : {
3113 0 : int new_size = b->yy_buf_size * 2;
3114 :
3115 0 : if ( new_size <= 0 )
3116 0 : b->yy_buf_size += b->yy_buf_size / 8;
3117 : else
3118 0 : b->yy_buf_size *= 2;
3119 :
3120 0 : b->yy_ch_buf = (char *)
3121 : /* Include room in for 2 EOB chars. */
3122 0 : yyrealloc( (void *) b->yy_ch_buf,
3123 0 : (yy_size_t) (b->yy_buf_size + 2) );
3124 : }
3125 : else
3126 : /* Can't grow it, we don't own it. */
3127 0 : b->yy_ch_buf = NULL;
3128 :
3129 0 : if ( ! b->yy_ch_buf )
3130 0 : YY_FATAL_ERROR(
3131 : "fatal error - scanner input buffer overflow" );
3132 :
3133 0 : (yy_c_buf_p) = &b->yy_ch_buf[yy_c_buf_p_offset];
3134 :
3135 0 : num_to_read = YY_CURRENT_BUFFER_LVALUE->yy_buf_size -
3136 : number_to_move - 1;
3137 :
3138 : }
3139 :
3140 641 : if ( num_to_read > YY_READ_BUF_SIZE )
3141 : num_to_read = YY_READ_BUF_SIZE;
3142 :
3143 : /* Read in more data. */
3144 1282 : YY_INPUT( (&YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[number_to_move]),
3145 641 : (yy_n_chars), num_to_read );
3146 :
3147 641 : YY_CURRENT_BUFFER_LVALUE->yy_n_chars = (yy_n_chars);
3148 : }
3149 :
3150 641 : if ( (yy_n_chars) == 0 )
3151 : {
3152 316 : if ( number_to_move == YY_MORE_ADJ )
3153 : {
3154 316 : ret_val = EOB_ACT_END_OF_FILE;
3155 316 : yyrestart( yyin );
3156 : }
3157 :
3158 : else
3159 : {
3160 0 : ret_val = EOB_ACT_LAST_MATCH;
3161 0 : YY_CURRENT_BUFFER_LVALUE->yy_buffer_status =
3162 : YY_BUFFER_EOF_PENDING;
3163 : }
3164 : }
3165 :
3166 : else
3167 : ret_val = EOB_ACT_CONTINUE_SCAN;
3168 :
3169 641 : if (((yy_n_chars) + number_to_move) > YY_CURRENT_BUFFER_LVALUE->yy_buf_size) {
3170 : /* Extend the array by 50%, plus the number we really need. */
3171 0 : int new_size = (yy_n_chars) + number_to_move + ((yy_n_chars) >> 1);
3172 0 : YY_CURRENT_BUFFER_LVALUE->yy_ch_buf = (char *) yyrealloc(
3173 0 : (void *) YY_CURRENT_BUFFER_LVALUE->yy_ch_buf, (yy_size_t) new_size );
3174 0 : if ( ! YY_CURRENT_BUFFER_LVALUE->yy_ch_buf )
3175 0 : YY_FATAL_ERROR( "out of dynamic memory in yy_get_next_buffer()" );
3176 : /* "- 2" to take care of EOB's */
3177 0 : YY_CURRENT_BUFFER_LVALUE->yy_buf_size = (int) (new_size - 2);
3178 : }
3179 :
3180 641 : (yy_n_chars) += number_to_move;
3181 641 : YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[(yy_n_chars)] = YY_END_OF_BUFFER_CHAR;
3182 641 : YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[(yy_n_chars) + 1] = YY_END_OF_BUFFER_CHAR;
3183 :
3184 641 : (yytext_ptr) = &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[0];
3185 :
3186 641 : return ret_val;
3187 : }
3188 :
3189 : /* yy_get_previous_state - get the state just before the EOB char was reached */
3190 :
3191 325 : static yy_state_type yy_get_previous_state (void)
3192 : {
3193 325 : yy_state_type yy_current_state;
3194 325 : char *yy_cp;
3195 :
3196 325 : yy_current_state = (yy_start);
3197 325 : yy_current_state += YY_AT_BOL();
3198 :
3199 337 : for ( yy_cp = (yytext_ptr) + YY_MORE_ADJ; yy_cp < (yy_c_buf_p); ++yy_cp )
3200 : {
3201 12 : YY_CHAR yy_c = (*yy_cp ? yy_ec[YY_SC_TO_UI(*yy_cp)] : 1);
3202 12 : if ( yy_accept[yy_current_state] )
3203 : {
3204 7 : (yy_last_accepting_state) = yy_current_state;
3205 7 : (yy_last_accepting_cpos) = yy_cp;
3206 : }
3207 18 : while ( yy_chk[yy_base[yy_current_state] + yy_c] != yy_current_state )
3208 : {
3209 6 : yy_current_state = (int) yy_def[yy_current_state];
3210 6 : if ( yy_current_state >= 207 )
3211 6 : yy_c = yy_meta[yy_c];
3212 : }
3213 12 : yy_current_state = yy_nxt[yy_base[yy_current_state] + yy_c];
3214 : }
3215 :
3216 325 : return yy_current_state;
3217 : }
3218 :
3219 : /* yy_try_NUL_trans - try to make a transition on the NUL character
3220 : *
3221 : * synopsis
3222 : * next_state = yy_try_NUL_trans( current_state );
3223 : */
3224 0 : static yy_state_type yy_try_NUL_trans (yy_state_type yy_current_state )
3225 : {
3226 0 : int yy_is_jam;
3227 0 : char *yy_cp = (yy_c_buf_p);
3228 :
3229 0 : YY_CHAR yy_c = 1;
3230 0 : if ( yy_accept[yy_current_state] )
3231 : {
3232 0 : (yy_last_accepting_state) = yy_current_state;
3233 0 : (yy_last_accepting_cpos) = yy_cp;
3234 : }
3235 0 : while ( yy_chk[yy_base[yy_current_state] + yy_c] != yy_current_state )
3236 : {
3237 0 : yy_current_state = (int) yy_def[yy_current_state];
3238 0 : if ( yy_current_state >= 207 )
3239 : yy_c = yy_meta[yy_c];
3240 : }
3241 0 : yy_current_state = yy_nxt[yy_base[yy_current_state] + yy_c];
3242 0 : yy_is_jam = (yy_current_state == 206);
3243 :
3244 0 : return yy_is_jam ? 0 : yy_current_state;
3245 : }
3246 :
3247 : #ifndef YY_NO_UNPUT
3248 :
3249 : static void yyunput (int c, char * yy_bp )
3250 : {
3251 : char *yy_cp;
3252 :
3253 : yy_cp = (yy_c_buf_p);
3254 :
3255 : /* undo effects of setting up yytext */
3256 : *yy_cp = (yy_hold_char);
3257 :
3258 : if ( yy_cp < YY_CURRENT_BUFFER_LVALUE->yy_ch_buf + 2 )
3259 : { /* need to shift things up to make room */
3260 : /* +2 for EOB chars. */
3261 : int number_to_move = (yy_n_chars) + 2;
3262 : char *dest = &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[
3263 : YY_CURRENT_BUFFER_LVALUE->yy_buf_size + 2];
3264 : char *source =
3265 : &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[number_to_move];
3266 :
3267 : while ( source > YY_CURRENT_BUFFER_LVALUE->yy_ch_buf )
3268 : *--dest = *--source;
3269 :
3270 : yy_cp += (int) (dest - source);
3271 : yy_bp += (int) (dest - source);
3272 : YY_CURRENT_BUFFER_LVALUE->yy_n_chars =
3273 : (yy_n_chars) = (int) YY_CURRENT_BUFFER_LVALUE->yy_buf_size;
3274 :
3275 : if ( yy_cp < YY_CURRENT_BUFFER_LVALUE->yy_ch_buf + 2 )
3276 : YY_FATAL_ERROR( "flex scanner push-back overflow" );
3277 : }
3278 :
3279 : *--yy_cp = (char) c;
3280 :
3281 : (yytext_ptr) = yy_bp;
3282 : (yy_hold_char) = *yy_cp;
3283 : (yy_c_buf_p) = yy_cp;
3284 : }
3285 :
3286 : #endif
3287 :
3288 : #ifndef YY_NO_INPUT
3289 : #ifdef __cplusplus
3290 : static int yyinput (void)
3291 : #else
3292 : static int input (void)
3293 : #endif
3294 :
3295 : {
3296 : int c;
3297 :
3298 : *(yy_c_buf_p) = (yy_hold_char);
3299 :
3300 : if ( *(yy_c_buf_p) == YY_END_OF_BUFFER_CHAR )
3301 : {
3302 : /* yy_c_buf_p now points to the character we want to return.
3303 : * If this occurs *before* the EOB characters, then it's a
3304 : * valid NUL; if not, then we've hit the end of the buffer.
3305 : */
3306 : if ( (yy_c_buf_p) < &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[(yy_n_chars)] )
3307 : /* This was really a NUL. */
3308 : *(yy_c_buf_p) = '\0';
3309 :
3310 : else
3311 : { /* need more input */
3312 : int offset = (int) ((yy_c_buf_p) - (yytext_ptr));
3313 : ++(yy_c_buf_p);
3314 :
3315 : switch ( yy_get_next_buffer( ) )
3316 : {
3317 : case EOB_ACT_LAST_MATCH:
3318 : /* This happens because yy_g_n_b()
3319 : * sees that we've accumulated a
3320 : * token and flags that we need to
3321 : * try matching the token before
3322 : * proceeding. But for input(),
3323 : * there's no matching to consider.
3324 : * So convert the EOB_ACT_LAST_MATCH
3325 : * to EOB_ACT_END_OF_FILE.
3326 : */
3327 :
3328 : /* Reset buffer status. */
3329 : yyrestart( yyin );
3330 :
3331 : /*FALLTHROUGH*/
3332 :
3333 : case EOB_ACT_END_OF_FILE:
3334 : {
3335 : if ( yywrap( ) )
3336 : return 0;
3337 :
3338 : if ( ! (yy_did_buffer_switch_on_eof) )
3339 : YY_NEW_FILE;
3340 : #ifdef __cplusplus
3341 : return yyinput();
3342 : #else
3343 : return input();
3344 : #endif
3345 : }
3346 :
3347 : case EOB_ACT_CONTINUE_SCAN:
3348 : (yy_c_buf_p) = (yytext_ptr) + offset;
3349 : break;
3350 : }
3351 : }
3352 : }
3353 :
3354 : c = *(unsigned char *) (yy_c_buf_p); /* cast for 8-bit char's */
3355 : *(yy_c_buf_p) = '\0'; /* preserve yytext */
3356 : (yy_hold_char) = *++(yy_c_buf_p);
3357 :
3358 : YY_CURRENT_BUFFER_LVALUE->yy_at_bol = (c == '\n');
3359 :
3360 : return c;
3361 : }
3362 : #endif /* ifndef YY_NO_INPUT */
3363 :
3364 : /** Immediately switch to a different input stream.
3365 : * @param input_file A readable stream.
3366 : *
3367 : * @note This function does not reset the start condition to @c INITIAL .
3368 : */
3369 316 : void yyrestart (FILE * input_file )
3370 : {
3371 :
3372 316 : if ( ! YY_CURRENT_BUFFER ){
3373 0 : yyensure_buffer_stack ();
3374 0 : YY_CURRENT_BUFFER_LVALUE =
3375 0 : yy_create_buffer( yyin, YY_BUF_SIZE );
3376 : }
3377 :
3378 316 : yy_init_buffer( YY_CURRENT_BUFFER, input_file );
3379 316 : yy_load_buffer_state( );
3380 316 : }
3381 :
3382 : /** Switch to a different input buffer.
3383 : * @param new_buffer The new input buffer.
3384 : *
3385 : */
3386 0 : void yy_switch_to_buffer (YY_BUFFER_STATE new_buffer )
3387 : {
3388 :
3389 : /* TODO. We should be able to replace this entire function body
3390 : * with
3391 : * yypop_buffer_state();
3392 : * yypush_buffer_state(new_buffer);
3393 : */
3394 0 : yyensure_buffer_stack ();
3395 0 : if ( YY_CURRENT_BUFFER == new_buffer )
3396 : return;
3397 :
3398 0 : if ( YY_CURRENT_BUFFER )
3399 : {
3400 : /* Flush out information for old buffer. */
3401 0 : *(yy_c_buf_p) = (yy_hold_char);
3402 0 : YY_CURRENT_BUFFER_LVALUE->yy_buf_pos = (yy_c_buf_p);
3403 0 : YY_CURRENT_BUFFER_LVALUE->yy_n_chars = (yy_n_chars);
3404 : }
3405 :
3406 0 : YY_CURRENT_BUFFER_LVALUE = new_buffer;
3407 0 : yy_load_buffer_state( );
3408 :
3409 : /* We don't actually know whether we did this switch during
3410 : * EOF (yywrap()) processing, but the only time this flag
3411 : * is looked at is after yywrap() is called, so it's safe
3412 : * to go ahead and always set it.
3413 : */
3414 0 : (yy_did_buffer_switch_on_eof) = 1;
3415 : }
3416 :
3417 947 : static void yy_load_buffer_state (void)
3418 : {
3419 947 : (yy_n_chars) = YY_CURRENT_BUFFER_LVALUE->yy_n_chars;
3420 947 : (yytext_ptr) = (yy_c_buf_p) = YY_CURRENT_BUFFER_LVALUE->yy_buf_pos;
3421 947 : yyin = YY_CURRENT_BUFFER_LVALUE->yy_input_file;
3422 0 : (yy_hold_char) = *(yy_c_buf_p);
3423 315 : }
3424 :
3425 : /** Allocate and initialize an input buffer state.
3426 : * @param file A readable stream.
3427 : * @param size The character buffer size in bytes. When in doubt, use @c YY_BUF_SIZE.
3428 : *
3429 : * @return the allocated buffer state.
3430 : */
3431 315 : YY_BUFFER_STATE yy_create_buffer (FILE * file, int size )
3432 : {
3433 315 : YY_BUFFER_STATE b;
3434 :
3435 315 : b = (YY_BUFFER_STATE) yyalloc( sizeof( struct yy_buffer_state ) );
3436 315 : if ( ! b )
3437 0 : YY_FATAL_ERROR( "out of dynamic memory in yy_create_buffer()" );
3438 :
3439 315 : b->yy_buf_size = size;
3440 :
3441 : /* yy_ch_buf has to be 2 characters longer than the size given because
3442 : * we need to put in 2 end-of-buffer characters.
3443 : */
3444 315 : b->yy_ch_buf = (char *) yyalloc( (yy_size_t) (b->yy_buf_size + 2) );
3445 315 : if ( ! b->yy_ch_buf )
3446 0 : YY_FATAL_ERROR( "out of dynamic memory in yy_create_buffer()" );
3447 :
3448 315 : b->yy_is_our_buffer = 1;
3449 :
3450 315 : yy_init_buffer( b, file );
3451 :
3452 315 : return b;
3453 : }
3454 :
3455 : /** Destroy the buffer.
3456 : * @param b a buffer created with yy_create_buffer()
3457 : *
3458 : */
3459 0 : void yy_delete_buffer (YY_BUFFER_STATE b )
3460 : {
3461 :
3462 0 : if ( ! b )
3463 : return;
3464 :
3465 0 : if ( b == YY_CURRENT_BUFFER ) /* Not sure if we should pop here. */
3466 0 : YY_CURRENT_BUFFER_LVALUE = (YY_BUFFER_STATE) 0;
3467 :
3468 0 : if ( b->yy_is_our_buffer )
3469 0 : yyfree( (void *) b->yy_ch_buf );
3470 :
3471 0 : yyfree( (void *) b );
3472 : }
3473 :
3474 : /* Initializes or reinitializes a buffer.
3475 : * This function is sometimes called more than once on the same buffer,
3476 : * such as during a yyrestart() or at EOF.
3477 : */
3478 631 : static void yy_init_buffer (YY_BUFFER_STATE b, FILE * file )
3479 :
3480 : {
3481 631 : int oerrno = errno;
3482 :
3483 631 : yy_flush_buffer( b );
3484 :
3485 631 : b->yy_input_file = file;
3486 631 : b->yy_fill_buffer = 1;
3487 :
3488 : /* If b is the current buffer, then yy_init_buffer was _probably_
3489 : * called from yyrestart() or through yy_get_next_buffer.
3490 : * In that case, we don't want to reset the lineno or column.
3491 : */
3492 631 : if (b != YY_CURRENT_BUFFER){
3493 315 : b->yy_bs_lineno = 1;
3494 315 : b->yy_bs_column = 0;
3495 : }
3496 :
3497 631 : b->yy_is_interactive = file ? (isatty( fileno(file) ) > 0) : 0;
3498 :
3499 631 : errno = oerrno;
3500 631 : }
3501 :
3502 : /** Discard all buffered characters. On the next scan, YY_INPUT will be called.
3503 : * @param b the buffer state to be flushed, usually @c YY_CURRENT_BUFFER.
3504 : *
3505 : */
3506 631 : void yy_flush_buffer (YY_BUFFER_STATE b )
3507 : {
3508 631 : if ( ! b )
3509 : return;
3510 :
3511 631 : b->yy_n_chars = 0;
3512 :
3513 : /* We always need two end-of-buffer characters. The first causes
3514 : * a transition to the end-of-buffer state. The second causes
3515 : * a jam in that state.
3516 : */
3517 631 : b->yy_ch_buf[0] = YY_END_OF_BUFFER_CHAR;
3518 631 : b->yy_ch_buf[1] = YY_END_OF_BUFFER_CHAR;
3519 :
3520 631 : b->yy_buf_pos = &b->yy_ch_buf[0];
3521 :
3522 631 : b->yy_at_bol = 1;
3523 631 : b->yy_buffer_status = YY_BUFFER_NEW;
3524 :
3525 631 : if ( b == YY_CURRENT_BUFFER )
3526 316 : yy_load_buffer_state( );
3527 : }
3528 :
3529 : /** Pushes the new state onto the stack. The new state becomes
3530 : * the current state. This function will allocate the stack
3531 : * if necessary.
3532 : * @param new_buffer The new state.
3533 : *
3534 : */
3535 0 : void yypush_buffer_state (YY_BUFFER_STATE new_buffer )
3536 : {
3537 0 : if (new_buffer == NULL)
3538 : return;
3539 :
3540 0 : yyensure_buffer_stack();
3541 :
3542 : /* This block is copied from yy_switch_to_buffer. */
3543 0 : if ( YY_CURRENT_BUFFER )
3544 : {
3545 : /* Flush out information for old buffer. */
3546 0 : *(yy_c_buf_p) = (yy_hold_char);
3547 0 : YY_CURRENT_BUFFER_LVALUE->yy_buf_pos = (yy_c_buf_p);
3548 0 : YY_CURRENT_BUFFER_LVALUE->yy_n_chars = (yy_n_chars);
3549 : }
3550 :
3551 : /* Only push if top exists. Otherwise, replace top. */
3552 0 : if (YY_CURRENT_BUFFER)
3553 0 : (yy_buffer_stack_top)++;
3554 0 : YY_CURRENT_BUFFER_LVALUE = new_buffer;
3555 :
3556 : /* copied from yy_switch_to_buffer. */
3557 0 : yy_load_buffer_state( );
3558 0 : (yy_did_buffer_switch_on_eof) = 1;
3559 : }
3560 :
3561 : /** Removes and deletes the top of the stack, if present.
3562 : * The next element becomes the new top.
3563 : *
3564 : */
3565 0 : void yypop_buffer_state (void)
3566 : {
3567 0 : if (!YY_CURRENT_BUFFER)
3568 : return;
3569 :
3570 0 : yy_delete_buffer(YY_CURRENT_BUFFER );
3571 0 : YY_CURRENT_BUFFER_LVALUE = NULL;
3572 0 : if ((yy_buffer_stack_top) > 0)
3573 0 : --(yy_buffer_stack_top);
3574 :
3575 0 : if (YY_CURRENT_BUFFER) {
3576 0 : yy_load_buffer_state( );
3577 0 : (yy_did_buffer_switch_on_eof) = 1;
3578 : }
3579 : }
3580 :
3581 : /* Allocates the stack if it does not exist.
3582 : * Guarantees space for at least one push.
3583 : */
3584 315 : static void yyensure_buffer_stack (void)
3585 : {
3586 315 : yy_size_t num_to_alloc;
3587 :
3588 315 : if (!(yy_buffer_stack)) {
3589 :
3590 : /* First allocation is just for 2 elements, since we don't know if this
3591 : * scanner will even need a stack. We use 2 instead of 1 to avoid an
3592 : * immediate realloc on the next call.
3593 : */
3594 315 : num_to_alloc = 1; /* After all that talk, this was set to 1 anyways... */
3595 630 : (yy_buffer_stack) = (struct yy_buffer_state**)yyalloc
3596 315 : (num_to_alloc * sizeof(struct yy_buffer_state*)
3597 : );
3598 315 : if ( ! (yy_buffer_stack) )
3599 0 : YY_FATAL_ERROR( "out of dynamic memory in yyensure_buffer_stack()" );
3600 :
3601 315 : memset((yy_buffer_stack), 0, num_to_alloc * sizeof(struct yy_buffer_state*));
3602 :
3603 315 : (yy_buffer_stack_max) = num_to_alloc;
3604 315 : (yy_buffer_stack_top) = 0;
3605 315 : return;
3606 : }
3607 :
3608 0 : if ((yy_buffer_stack_top) >= ((yy_buffer_stack_max)) - 1){
3609 :
3610 : /* Increase the buffer to prepare for a possible push. */
3611 0 : yy_size_t grow_size = 8 /* arbitrary grow size */;
3612 :
3613 0 : num_to_alloc = (yy_buffer_stack_max) + grow_size;
3614 0 : (yy_buffer_stack) = (struct yy_buffer_state**)yyrealloc
3615 0 : ((yy_buffer_stack),
3616 : num_to_alloc * sizeof(struct yy_buffer_state*)
3617 : );
3618 0 : if ( ! (yy_buffer_stack) )
3619 0 : YY_FATAL_ERROR( "out of dynamic memory in yyensure_buffer_stack()" );
3620 :
3621 : /* zero only the new slots.*/
3622 0 : memset((yy_buffer_stack) + (yy_buffer_stack_max), 0, grow_size * sizeof(struct yy_buffer_state*));
3623 0 : (yy_buffer_stack_max) = num_to_alloc;
3624 : }
3625 : }
3626 :
3627 : /** Setup the input buffer state to scan directly from a user-specified character buffer.
3628 : * @param base the character buffer
3629 : * @param size the size in bytes of the character buffer
3630 : *
3631 : * @return the newly allocated buffer state object.
3632 : */
3633 0 : YY_BUFFER_STATE yy_scan_buffer (char * base, yy_size_t size )
3634 : {
3635 0 : YY_BUFFER_STATE b;
3636 :
3637 0 : if ( size < 2 ||
3638 0 : base[size-2] != YY_END_OF_BUFFER_CHAR ||
3639 0 : base[size-1] != YY_END_OF_BUFFER_CHAR )
3640 : /* They forgot to leave room for the EOB's. */
3641 : return NULL;
3642 :
3643 0 : b = (YY_BUFFER_STATE) yyalloc( sizeof( struct yy_buffer_state ) );
3644 0 : if ( ! b )
3645 0 : YY_FATAL_ERROR( "out of dynamic memory in yy_scan_buffer()" );
3646 :
3647 0 : b->yy_buf_size = (int) (size - 2); /* "- 2" to take care of EOB's */
3648 0 : b->yy_buf_pos = b->yy_ch_buf = base;
3649 0 : b->yy_is_our_buffer = 0;
3650 0 : b->yy_input_file = NULL;
3651 0 : b->yy_n_chars = b->yy_buf_size;
3652 0 : b->yy_is_interactive = 0;
3653 0 : b->yy_at_bol = 1;
3654 0 : b->yy_fill_buffer = 0;
3655 0 : b->yy_buffer_status = YY_BUFFER_NEW;
3656 :
3657 0 : yy_switch_to_buffer( b );
3658 :
3659 0 : return b;
3660 : }
3661 :
3662 : /** Setup the input buffer state to scan a string. The next call to yylex() will
3663 : * scan from a @e copy of @a str.
3664 : * @param yystr a NUL-terminated string to scan
3665 : *
3666 : * @return the newly allocated buffer state object.
3667 : * @note If you want to scan bytes that may contain NUL values, then use
3668 : * yy_scan_bytes() instead.
3669 : */
3670 0 : YY_BUFFER_STATE yy_scan_string (const char * yystr )
3671 : {
3672 :
3673 0 : return yy_scan_bytes( yystr, (int) strlen(yystr) );
3674 : }
3675 :
3676 : /** Setup the input buffer state to scan the given bytes. The next call to yylex() will
3677 : * scan from a @e copy of @a bytes.
3678 : * @param yybytes the byte buffer to scan
3679 : * @param _yybytes_len the number of bytes in the buffer pointed to by @a bytes.
3680 : *
3681 : * @return the newly allocated buffer state object.
3682 : */
3683 0 : YY_BUFFER_STATE yy_scan_bytes (const char * yybytes, int _yybytes_len )
3684 : {
3685 0 : YY_BUFFER_STATE b;
3686 0 : char *buf;
3687 0 : yy_size_t n;
3688 0 : int i;
3689 :
3690 : /* Get memory for full buffer, including space for trailing EOB's. */
3691 0 : n = (yy_size_t) (_yybytes_len + 2);
3692 0 : buf = (char *) yyalloc( n );
3693 0 : if ( ! buf )
3694 0 : YY_FATAL_ERROR( "out of dynamic memory in yy_scan_bytes()" );
3695 :
3696 0 : for ( i = 0; i < _yybytes_len; ++i )
3697 0 : buf[i] = yybytes[i];
3698 :
3699 0 : buf[_yybytes_len] = buf[_yybytes_len+1] = YY_END_OF_BUFFER_CHAR;
3700 :
3701 0 : b = yy_scan_buffer( buf, n );
3702 0 : if ( ! b )
3703 0 : YY_FATAL_ERROR( "bad buffer in yy_scan_bytes()" );
3704 :
3705 : /* It's okay to grow etc. this buffer, and we should throw it
3706 : * away when we're done.
3707 : */
3708 0 : b->yy_is_our_buffer = 1;
3709 :
3710 0 : return b;
3711 : }
3712 :
3713 : #ifndef YY_EXIT_FAILURE
3714 : #define YY_EXIT_FAILURE 2
3715 : #endif
3716 :
3717 0 : static void yynoreturn yy_fatal_error (const char* msg )
3718 : {
3719 0 : fprintf( stderr, "%s\n", msg );
3720 0 : exit( YY_EXIT_FAILURE );
3721 : }
3722 :
3723 : /* Redefine yyless() so it works in section 3 code. */
3724 :
3725 : #undef yyless
3726 : #define yyless(n) \
3727 : do \
3728 : { \
3729 : /* Undo effects of setting up yytext. */ \
3730 : int yyless_macro_arg = (n); \
3731 : YY_LESS_LINENO(yyless_macro_arg);\
3732 : yytext[yyleng] = (yy_hold_char); \
3733 : (yy_c_buf_p) = yytext + yyless_macro_arg; \
3734 : (yy_hold_char) = *(yy_c_buf_p); \
3735 : *(yy_c_buf_p) = '\0'; \
3736 : yyleng = yyless_macro_arg; \
3737 : } \
3738 : while ( 0 )
3739 :
3740 : /* Accessor methods (get/set functions) to struct members. */
3741 :
3742 : /** Get the current line number.
3743 : *
3744 : */
3745 0 : int yyget_lineno (void)
3746 : {
3747 :
3748 0 : return yylineno;
3749 : }
3750 :
3751 : /** Get the input stream.
3752 : *
3753 : */
3754 0 : FILE *yyget_in (void)
3755 : {
3756 0 : return yyin;
3757 : }
3758 :
3759 : /** Get the output stream.
3760 : *
3761 : */
3762 0 : FILE *yyget_out (void)
3763 : {
3764 0 : return yyout;
3765 : }
3766 :
3767 : /** Get the length of the current token.
3768 : *
3769 : */
3770 0 : int yyget_leng (void)
3771 : {
3772 0 : return yyleng;
3773 : }
3774 :
3775 : /** Get the current token.
3776 : *
3777 : */
3778 :
3779 0 : char *yyget_text (void)
3780 : {
3781 0 : return yytext;
3782 : }
3783 :
3784 : /** Set the current line number.
3785 : * @param _line_number line number
3786 : *
3787 : */
3788 0 : void yyset_lineno (int _line_number )
3789 : {
3790 :
3791 0 : yylineno = _line_number;
3792 0 : }
3793 :
3794 : /** Set the input stream. This does not discard the current
3795 : * input buffer.
3796 : * @param _in_str A readable stream.
3797 : *
3798 : * @see yy_switch_to_buffer
3799 : */
3800 0 : void yyset_in (FILE * _in_str )
3801 : {
3802 0 : yyin = _in_str ;
3803 0 : }
3804 :
3805 0 : void yyset_out (FILE * _out_str )
3806 : {
3807 0 : yyout = _out_str ;
3808 0 : }
3809 :
3810 0 : int yyget_debug (void)
3811 : {
3812 0 : return yy_flex_debug;
3813 : }
3814 :
3815 0 : void yyset_debug (int _bdebug )
3816 : {
3817 0 : yy_flex_debug = _bdebug ;
3818 0 : }
3819 :
3820 0 : static int yy_init_globals (void)
3821 : {
3822 : /* Initialization is the same as for the non-reentrant scanner.
3823 : * This function is called from yylex_destroy(), so don't allocate here.
3824 : */
3825 :
3826 0 : (yy_buffer_stack) = NULL;
3827 0 : (yy_buffer_stack_top) = 0;
3828 0 : (yy_buffer_stack_max) = 0;
3829 0 : (yy_c_buf_p) = NULL;
3830 0 : (yy_init) = 0;
3831 0 : (yy_start) = 0;
3832 :
3833 : /* Defined in main.c */
3834 : #ifdef YY_STDINIT
3835 : yyin = stdin;
3836 : yyout = stdout;
3837 : #else
3838 0 : yyin = NULL;
3839 0 : yyout = NULL;
3840 : #endif
3841 :
3842 : /* For future reference: Set errno on error, since we are called by
3843 : * yylex_init()
3844 : */
3845 0 : return 0;
3846 : }
3847 :
3848 : /* yylex_destroy is for both reentrant and non-reentrant scanners. */
3849 0 : int yylex_destroy (void)
3850 : {
3851 :
3852 : /* Pop the buffer stack, destroying each element. */
3853 0 : while(YY_CURRENT_BUFFER){
3854 0 : yy_delete_buffer( YY_CURRENT_BUFFER );
3855 0 : YY_CURRENT_BUFFER_LVALUE = NULL;
3856 0 : yypop_buffer_state();
3857 : }
3858 :
3859 : /* Destroy the stack itself. */
3860 0 : yyfree((yy_buffer_stack) );
3861 0 : (yy_buffer_stack) = NULL;
3862 :
3863 : /* Reset the globals. This is important in a non-reentrant scanner so the next time
3864 : * yylex() is called, initialization will occur. */
3865 0 : yy_init_globals( );
3866 :
3867 0 : return 0;
3868 : }
3869 :
3870 : /*
3871 : * Internal utility routines.
3872 : */
3873 :
3874 : #ifndef yytext_ptr
3875 : static void yy_flex_strncpy (char* s1, const char * s2, int n )
3876 : {
3877 :
3878 : int i;
3879 : for ( i = 0; i < n; ++i )
3880 : s1[i] = s2[i];
3881 : }
3882 : #endif
3883 :
3884 : #ifdef YY_NEED_STRLEN
3885 : static int yy_flex_strlen (const char * s )
3886 : {
3887 : int n;
3888 : for ( n = 0; s[n]; ++n )
3889 : ;
3890 :
3891 : return n;
3892 : }
3893 : #endif
3894 :
3895 945 : void *yyalloc (yy_size_t size )
3896 : {
3897 945 : return malloc(size);
3898 : }
3899 :
3900 0 : void *yyrealloc (void * ptr, yy_size_t size )
3901 : {
3902 :
3903 : /* The cast to (char *) in the following accommodates both
3904 : * implementations that use char* generic pointers, and those
3905 : * that use void* generic pointers. It works with the latter
3906 : * because both ANSI C and C++ allow castless assignment from
3907 : * any pointer type to void*, and deal with argument conversions
3908 : * as though doing an assignment.
3909 : */
3910 0 : return realloc(ptr, size);
3911 : }
3912 :
3913 0 : void yyfree (void * ptr )
3914 : {
3915 0 : free( (char *) ptr ); /* see yyrealloc() for (char *) cast */
3916 0 : }
3917 :
3918 : #define YYTABLES_NAME "yytables"
3919 :
3920 : #line 1441 "../../../../rexompiler/src/frontend/SageIII/preproc-c.ll"
3921 :
3922 :
3923 : const int maxstacksize=500;
3924 : int bracestack[maxstacksize];
3925 :
3926 : int top=0;
3927 : void pushbracestack(int brace_no) { bracestack[top++]=brace_no; }
3928 : int topcurlybracestack() { if(top) return bracestack[top-1]; else return -1; }
3929 : int popbracestack() { return bracestack[--top]; }
3930 : bool isemptystack() { return top==0; }
3931 :
3932 : int num_of_newlines(char* s)
3933 : {
3934 : int num = 0;
3935 : while(*s != '\0')
3936 : {
3937 : if(*s == '\n')
3938 : num++;
3939 : s++;
3940 : }
3941 : return num;
3942 : }
3943 :
3944 :
3945 : // DQ (1/4/2021): Adding support for comments and CPP directives and tokens to use new_filename.
3946 : // DQ (3/30/2006): Modified to use C++ style string instead of C style char* string
3947 : // ROSEAttributesList *getPreprocessorDirectives( char *fileName)
3948 : //! This function extracts the comments and CPP preprocessor control directives from the input file.
3949 : // ROSEAttributesList *getPreprocessorDirectives( std::string fileName )
3950 : // ROSEAttributesList *getPreprocessorDirectives( std::string fileName, LexTokenStreamTypePointer & input_token_stream_pointer )
3951 : // ROSEAttributesList *getPreprocessorDirectives( std::string fileName )
3952 : ROSEAttributesList *getPreprocessorDirectives( std::string fileName, std::string new_filename )
3953 : {
3954 : // DQ (11/9/2020): Introduce tracking of performance of ROSE.
3955 : TimingPerformance timer ("AST collect comments and CPP directives():");
3956 :
3957 : FILE *fp = NULL;
3958 : ROSEAttributesList *preprocessorInfoList = new ROSEAttributesList; // create a new list
3959 : ROSE_ASSERT (preprocessorInfoList != NULL);
3960 :
3961 : #if 0
3962 : // DQ (8/18/2019): Debugging the performance overhead of the header file unparsing support.
3963 : printf ("&&&&&&&&&&&&&&&&&&& Inside of lex file: getPreprocessorDirectives(): fileName = %s new_filename = %s \n",fileName.c_str(),new_filename.c_str());
3964 : #endif
3965 :
3966 : #if 0
3967 : printf ("Saving list of processed files to insure that files are not processed more than once! \n");
3968 : #endif
3969 : #if 0
3970 : static std::set<std::string> file_set;
3971 : if (file_set.find(fileName) == file_set.end())
3972 : {
3973 : file_set.insert(fileName);
3974 : }
3975 : else
3976 : {
3977 : // DQ (5/22/2020): We need to allow this in the narrow case of a source file that is being copied.
3978 : printf ("WARNING: fileName has been processed previously (allowed for source files being copied): %s \n",fileName.c_str());
3979 : // ROSE_ASSERT(false);
3980 : }
3981 : #endif
3982 :
3983 : #if 0
3984 : // DQ (8/18/2019): Trying to find where this is called in the processing of the header files.
3985 : static int counter = 0;
3986 : if (counter > 10)
3987 : {
3988 : printf ("Exiting as a test while processing the 10th file \n");
3989 : ROSE_ASSERT(false);
3990 : }
3991 : counter++;
3992 : #endif
3993 :
3994 : // printf ("Inside of lex file: getPreprocessorDirectives() \n");
3995 : // ROSE_ASSERT(false);
3996 :
3997 : // assert(input_token_stream_pointer == NULL);
3998 : ROSE_token_stream_pointer = new LexTokenStreamType;
3999 : assert(ROSE_token_stream_pointer != NULL);
4000 :
4001 : // Share a pointer to the same LexTokenStreamType just allocated
4002 : // input_token_stream_pointer = ROSE_token_stream_pointer;
4003 : // assert(input_token_stream_pointer != NULL);
4004 :
4005 : // Attach the token stream to the ROSEAttributesList being returned.
4006 : preprocessorInfoList->set_rawTokenStream(ROSE_token_stream_pointer);
4007 :
4008 : // Set the global filename to be used in the PreprocessingInfo constructor.
4009 : // globalFileName = fileName;
4010 : if (new_filename != "")
4011 : {
4012 : globalFileName = new_filename;
4013 : #if 0
4014 : printf ("Using non-physical new_filename: globalFileName = %s \n",globalFileName.c_str());
4015 : #endif
4016 : }
4017 : else
4018 : {
4019 : globalFileName = fileName;
4020 : #if 0
4021 : printf ("Using physical filename: globalFileName = %s \n",globalFileName.c_str());
4022 : #endif
4023 : }
4024 :
4025 :
4026 : if ( fileName.empty() == false )
4027 : {
4028 : std::map<std::string,ROSEAttributesList* >::iterator iItr = mapFilenameToAttributes.find(fileName);
4029 : // std::cout << "Trying to find fileName " << fileName << std::endl;
4030 : if ( iItr != mapFilenameToAttributes.end())
4031 : {
4032 : // std::cout << "Found requested file: " << fileName << " size: " << iItr->second->size() << std::endl;
4033 : for(std::vector<PreprocessingInfo*>::iterator jItr = iItr->second->getList().begin(); jItr != iItr->second->getList().end(); ++jItr)
4034 : {
4035 : // std::cout << "Inserting element" << (*jItr)->getString() << std::endl;
4036 : preprocessorInfoList->insertElement(**jItr);
4037 : }
4038 :
4039 : }
4040 : else
4041 : {
4042 : fp = fopen( fileName.c_str(), "r");
4043 : if (fp)
4044 : {
4045 : yyin = fp;
4046 : #if DEBUG_LEX_PASS
4047 : printf ("In getPreprocessorDirectives(): calling yylex() \n");
4048 : #endif
4049 : yylex();
4050 : #if DEBUG_LEX_PASS
4051 : printf ("In getPreprocessorDirectives(): DONE: calling yylex() \n");
4052 : #endif
4053 :
4054 : #if 0
4055 : // DQ (8/17/2020): Debugging code.
4056 : // Writes all gathered information to stdout
4057 : preprocessorList.display("TEST Collection of Comments and CPP Directives");
4058 : #endif
4059 : // bugfix (9/29/2001)
4060 : // The semantics required here is to move the elements accumulated into the
4061 : // preprocessorList into the preprocessorInfoList and delete them from the
4062 : // preprocessorList (which will be used again to accumulate PreprocessingInfo objects
4063 : // when the next file is processed). We have to be able to process several files using
4064 : // this getPreprocessorDirectives() function.
4065 : preprocessorInfoList->moveElements( preprocessorList ); // create a copy that we can pass on
4066 :
4067 : // The accumulator list should now be empty
4068 : assert (preprocessorList.getLength() == 0);
4069 : fclose(fp);
4070 : }
4071 : else
4072 : {
4073 : // DQ (5/14/2006): Added error checking for collection of comments and CPP directives.
4074 : printf ("Error: can't find the requested file (%s) \n",fileName.c_str());
4075 :
4076 : // DQ (11/8/2019): Uncomment so that we can identify calling location where this is called with a filename that does not exist (see buildFile()).
4077 : // ROSE_ASSERT(false);
4078 : ROSE_ASSERT(false);
4079 : }
4080 : }
4081 : }
4082 :
4083 : // DQ (1/4/2021): We need to use the globalFileName and the logic which sets it above.
4084 : // preprocessorInfoList->setFileName(fileName);
4085 : preprocessorInfoList->setFileName(globalFileName);
4086 :
4087 : // DQ (11/3/2019): Make sure that the filename is filled in.
4088 : ROSE_ASSERT(preprocessorInfoList->getFileName() != "");
4089 :
4090 : #if DEBUG_LEX_PASS || 0
4091 : printf ("Leaving getPreprocessorDirectives(fileName = %s): preprocessorInfoList->size() = %d \n",fileName.c_str(),(int)preprocessorInfoList->size());
4092 : printf (" --- preprocessorInfoList->getFileName() = %s \n",preprocessorInfoList->getFileName().c_str());
4093 : printf (" --- preprocessorInfoList->getList().size() = %zu \n",preprocessorInfoList->getList().size());
4094 : #endif
4095 :
4096 : // DQ (9/29/2013): Added assertion (debugging token handling in ROSE).
4097 : ROSE_ASSERT(preprocessorInfoList->get_rawTokenStream() != NULL);
4098 :
4099 : #if DEBUG_LEX_PASS || 0
4100 : printf ("Leaving getPreprocessorDirectives(): preprocessorInfoList->get_rawTokenStream() = %p \n",preprocessorInfoList->get_rawTokenStream());
4101 : printf ("Leaving getPreprocessorDirectives(): preprocessorInfoList->get_rawTokenStream()->size() = %" PRIuPTR " \n",preprocessorInfoList->get_rawTokenStream()->size());
4102 : #endif
4103 :
4104 : #if 0
4105 : if (preprocessorInfoList->getFileName() == "/home/quinlan1/ROSE/git_rose_development/tests/nonsmoke/functional/CompileTests/UnparseHeadersUsingTokenStream_tests/test0/Simple.h")
4106 : {
4107 : printf ("Found specific file: tests/nonsmoke/functional/CompileTests/UnparseHeadersUsingTokenStream_tests/test0/Simple.h \n");
4108 : ROSE_ASSERT(false);
4109 : }
4110 : #endif
4111 :
4112 : #if 0
4113 : printf ("Exiting in getPreprocessorDirectives() \n");
4114 : ROSE_ASSERT(false);
4115 : #endif
4116 :
4117 : return preprocessorInfoList;
4118 : }
4119 :
|