2 #line 3 "src/gras/DataDesc/ddt_parse.yy.c"
4 #define YY_INT_ALIGNED short int
6 /* A lexical scanner generated by flex */
8 #define yy_create_buffer gras_ddt_parse__create_buffer
9 #define yy_delete_buffer gras_ddt_parse__delete_buffer
10 #define yy_flex_debug gras_ddt_parse__flex_debug
11 #define yy_init_buffer gras_ddt_parse__init_buffer
12 #define yy_flush_buffer gras_ddt_parse__flush_buffer
13 #define yy_load_buffer_state gras_ddt_parse__load_buffer_state
14 #define yy_switch_to_buffer gras_ddt_parse__switch_to_buffer
15 #define yyin gras_ddt_parse_in
16 #define yyleng gras_ddt_parse_leng
17 #define yylex gras_ddt_parse_lex
18 #define yylineno gras_ddt_parse_lineno
19 #define yyout gras_ddt_parse_out
20 #define yyrestart gras_ddt_parse_restart
21 #define yytext gras_ddt_parse_text
22 #define yywrap gras_ddt_parse_wrap
23 #define yyalloc gras_ddt_parse_alloc
24 #define yyrealloc gras_ddt_parse_realloc
25 #define yyfree gras_ddt_parse_free
28 #define YY_FLEX_MAJOR_VERSION 2
29 #define YY_FLEX_MINOR_VERSION 5
30 #define YY_FLEX_SUBMINOR_VERSION 35
31 #if YY_FLEX_SUBMINOR_VERSION > 0
35 /* First, we deal with platform-specific or compiler-specific issues. */
37 /* begin standard C headers. */
43 /* end standard C headers. */
45 /* flex integer type definitions */
50 /* C99 systems have <inttypes.h>. Non-C99 systems may or may not. */
52 #if defined (__STDC_VERSION__) && __STDC_VERSION__ >= 199901L
54 /* C99 says to define __STDC_LIMIT_MACROS before including stdint.h,
55 * if you want the limit (max/min) macros for int types.
57 #ifndef __STDC_LIMIT_MACROS
58 #define __STDC_LIMIT_MACROS 1
62 typedef int8_t flex_int8_t;
63 typedef uint8_t flex_uint8_t;
64 typedef int16_t flex_int16_t;
65 typedef uint16_t flex_uint16_t;
66 typedef int32_t flex_int32_t;
67 typedef uint32_t flex_uint32_t;
69 typedef signed char flex_int8_t;
70 typedef short int flex_int16_t;
71 typedef int flex_int32_t;
72 typedef unsigned char flex_uint8_t;
73 typedef unsigned short int flex_uint16_t;
74 typedef unsigned int flex_uint32_t;
76 /* Limits of integral types. */
78 #define INT8_MIN (-128)
81 #define INT16_MIN (-32767-1)
84 #define INT32_MIN (-2147483647-1)
87 #define INT8_MAX (127)
90 #define INT16_MAX (32767)
93 #define INT32_MAX (2147483647)
96 #define UINT8_MAX (255U)
99 #define UINT16_MAX (65535U)
102 #define UINT32_MAX (4294967295U)
107 #endif /* ! FLEXINT_H */
111 /* The "const" storage-class-modifier is valid. */
114 #else /* ! __cplusplus */
116 /* C99 requires __STDC__ to be defined as 1. */
117 #if defined (__STDC__)
121 #endif /* defined (__STDC__) */
122 #endif /* ! __cplusplus */
125 #define yyconst const
130 /* Returned upon end-of-file. */
133 /* Promotes a possibly negative, possibly signed char to an unsigned
134 * integer for use as an array index. If the signed char is negative,
135 * we want to instead treat it as an 8-bit unsigned char, hence the
138 #define YY_SC_TO_UI(c) ((unsigned int) (unsigned char) c)
140 /* Enter a start condition. This macro really ought to take a parameter,
141 * but we do it the disgusting crufty way forced on us by the ()-less
142 * definition of BEGIN.
144 #define BEGIN (yy_start) = 1 + 2 *
146 /* Translate the current start state into a value that can be later handed
147 * to BEGIN to return to the state. The YYSTATE alias is for lex
150 #define YY_START (((yy_start) - 1) / 2)
151 #define YYSTATE YY_START
153 /* Action number for EOF rule of a given start state. */
154 #define YY_STATE_EOF(state) (YY_END_OF_BUFFER + state + 1)
156 /* Special action meaning "start processing a new file". */
157 #define YY_NEW_FILE gras_ddt_parse_restart(gras_ddt_parse_in )
159 #define YY_END_OF_BUFFER_CHAR 0
161 /* Size of default input buffer. */
164 /* On IA-64, the buffer size is 16k, not 8k.
165 * Moreover, YY_BUF_SIZE is 2*YY_READ_BUF_SIZE in the general case.
166 * Ditto for the __ia64__ case accordingly.
168 #define YY_BUF_SIZE 32768
170 #define YY_BUF_SIZE 16384
171 #endif /* __ia64__ */
174 /* The state buf must be large enough to hold one state per character in the main buffer.
176 #define YY_STATE_BUF_SIZE ((YY_BUF_SIZE + 2) * sizeof(yy_state_type))
178 #ifndef YY_TYPEDEF_YY_BUFFER_STATE
179 #define YY_TYPEDEF_YY_BUFFER_STATE
180 typedef struct yy_buffer_state *YY_BUFFER_STATE;
183 extern int gras_ddt_parse_leng;
185 extern FILE *gras_ddt_parse_in, *gras_ddt_parse_out;
187 #define EOB_ACT_CONTINUE_SCAN 0
188 #define EOB_ACT_END_OF_FILE 1
189 #define EOB_ACT_LAST_MATCH 2
191 #define YY_LESS_LINENO(n)
193 /* Return all but the first "n" matched characters back to the input stream. */
197 /* Undo effects of setting up gras_ddt_parse_text. */ \
198 int yyless_macro_arg = (n); \
199 YY_LESS_LINENO(yyless_macro_arg);\
200 *yy_cp = (yy_hold_char); \
201 YY_RESTORE_YY_MORE_OFFSET \
202 (yy_c_buf_p) = yy_cp = yy_bp + yyless_macro_arg - YY_MORE_ADJ; \
203 YY_DO_BEFORE_ACTION; /* set up gras_ddt_parse_text again */ \
207 #define unput(c) yyunput( c, (yytext_ptr) )
209 #ifndef YY_TYPEDEF_YY_SIZE_T
210 #define YY_TYPEDEF_YY_SIZE_T
211 typedef size_t yy_size_t;
214 #ifndef YY_STRUCT_YY_BUFFER_STATE
215 #define YY_STRUCT_YY_BUFFER_STATE
216 struct yy_buffer_state
220 char *yy_ch_buf; /* input buffer */
221 char *yy_buf_pos; /* current position in input buffer */
223 /* Size of input buffer in bytes, not including room for EOB
226 yy_size_t yy_buf_size;
228 /* Number of characters read into yy_ch_buf, not including EOB
233 /* Whether we "own" the buffer - i.e., we know we created it,
234 * and can realloc() it to grow it, and should free() it to
237 int yy_is_our_buffer;
239 /* Whether this is an "interactive" input source; if so, and
240 * if we're using stdio for input, then we want to use getc()
241 * instead of fread(), to make sure we stop fetching input after
244 int yy_is_interactive;
246 /* Whether we're considered to be at the beginning of a line.
247 * If so, '^' rules will be active on the next match, otherwise
252 int yy_bs_lineno; /**< The line count. */
253 int yy_bs_column; /**< The column count. */
255 /* Whether to try to fill the input buffer when we reach the
260 int yy_buffer_status;
262 #define YY_BUFFER_NEW 0
263 #define YY_BUFFER_NORMAL 1
264 /* When an EOF's been seen but there's still some text to process
265 * then we mark the buffer as YY_EOF_PENDING, to indicate that we
266 * shouldn't try reading from the input source any more. We might
267 * still have a bunch of tokens to match, though, because of
268 * possible backing-up.
270 * When we actually see the EOF, we change the status to "new"
271 * (via gras_ddt_parse_restart()), so that the user can continue scanning by
272 * just pointing gras_ddt_parse_in at a new input file.
274 #define YY_BUFFER_EOF_PENDING 2
277 #endif /* !YY_STRUCT_YY_BUFFER_STATE */
279 /* Stack of input buffers. */
280 static size_t yy_buffer_stack_top = 0; /**< index of top of stack. */
281 static size_t yy_buffer_stack_max = 0; /**< capacity of stack. */
282 static YY_BUFFER_STATE * yy_buffer_stack = 0; /**< Stack as an array. */
284 /* We provide macros for accessing buffer states in case in the
285 * future we want to put the buffer states in a more general
288 * Returns the top of the stack, or NULL.
290 #define YY_CURRENT_BUFFER ( (yy_buffer_stack) \
291 ? (yy_buffer_stack)[(yy_buffer_stack_top)] \
294 /* Same as previous macro, but useful when we know that the buffer stack is not
295 * NULL or when we need an lvalue. For internal use only.
297 #define YY_CURRENT_BUFFER_LVALUE (yy_buffer_stack)[(yy_buffer_stack_top)]
299 /* yy_hold_char holds the character lost when gras_ddt_parse_text is formed. */
300 static char yy_hold_char;
301 static int yy_n_chars; /* number of characters read into yy_ch_buf */
302 int gras_ddt_parse_leng;
304 /* Points to current character in buffer. */
305 static char *yy_c_buf_p = (char *) 0;
306 static int yy_init = 0; /* whether we need to initialize */
307 static int yy_start = 0; /* start state number */
309 /* Flag which is used to allow gras_ddt_parse_wrap()'s to do buffer switches
310 * instead of setting up a fresh gras_ddt_parse_in. A bit of a hack ...
312 static int yy_did_buffer_switch_on_eof;
314 void gras_ddt_parse_restart (FILE *input_file );
315 void gras_ddt_parse__switch_to_buffer (YY_BUFFER_STATE new_buffer );
316 YY_BUFFER_STATE gras_ddt_parse__create_buffer (FILE *file,int size );
317 void gras_ddt_parse__delete_buffer (YY_BUFFER_STATE b );
318 void gras_ddt_parse__flush_buffer (YY_BUFFER_STATE b );
319 void gras_ddt_parse_push_buffer_state (YY_BUFFER_STATE new_buffer );
320 void gras_ddt_parse_pop_buffer_state (void );
322 static void gras_ddt_parse_ensure_buffer_stack (void );
323 static void gras_ddt_parse__load_buffer_state (void );
324 static void gras_ddt_parse__init_buffer (YY_BUFFER_STATE b,FILE *file );
326 #define YY_FLUSH_BUFFER gras_ddt_parse__flush_buffer(YY_CURRENT_BUFFER )
328 YY_BUFFER_STATE gras_ddt_parse__scan_buffer (char *base,yy_size_t size );
329 YY_BUFFER_STATE gras_ddt_parse__scan_string (yyconst char *yy_str );
330 YY_BUFFER_STATE gras_ddt_parse__scan_bytes (yyconst char *bytes,int len );
332 void *gras_ddt_parse_alloc (yy_size_t );
333 void *gras_ddt_parse_realloc (void *,yy_size_t );
334 void gras_ddt_parse_free (void * );
336 #define yy_new_buffer gras_ddt_parse__create_buffer
338 #define yy_set_interactive(is_interactive) \
340 if ( ! YY_CURRENT_BUFFER ){ \
341 gras_ddt_parse_ensure_buffer_stack (); \
342 YY_CURRENT_BUFFER_LVALUE = \
343 gras_ddt_parse__create_buffer(gras_ddt_parse_in,YY_BUF_SIZE ); \
345 YY_CURRENT_BUFFER_LVALUE->yy_is_interactive = is_interactive; \
348 #define yy_set_bol(at_bol) \
350 if ( ! YY_CURRENT_BUFFER ){\
351 gras_ddt_parse_ensure_buffer_stack (); \
352 YY_CURRENT_BUFFER_LVALUE = \
353 gras_ddt_parse__create_buffer(gras_ddt_parse_in,YY_BUF_SIZE ); \
355 YY_CURRENT_BUFFER_LVALUE->yy_at_bol = at_bol; \
358 #define YY_AT_BOL() (YY_CURRENT_BUFFER_LVALUE->yy_at_bol)
360 /* Begin user sect3 */
362 #define gras_ddt_parse_wrap(n) 1
363 #define YY_SKIP_YYWRAP
365 typedef unsigned char YY_CHAR;
367 FILE *gras_ddt_parse_in = (FILE *) 0, *gras_ddt_parse_out = (FILE *) 0;
369 typedef int yy_state_type;
371 extern int gras_ddt_parse_lineno;
373 int gras_ddt_parse_lineno = 1;
375 extern char *gras_ddt_parse_text;
376 #define yytext_ptr gras_ddt_parse_text
378 static yy_state_type yy_get_previous_state (void );
379 static yy_state_type yy_try_NUL_trans (yy_state_type current_state );
380 static int yy_get_next_buffer (void );
381 static void yy_fatal_error (yyconst char msg[] );
383 /* Done after the current pattern has been matched and before the
384 * corresponding action - sets up gras_ddt_parse_text.
386 #define YY_DO_BEFORE_ACTION \
387 (yytext_ptr) = yy_bp; \
388 gras_ddt_parse_leng = (size_t) (yy_cp - yy_bp); \
389 (yy_hold_char) = *yy_cp; \
391 (yy_c_buf_p) = yy_cp;
393 #define YY_NUM_RULES 26
394 #define YY_END_OF_BUFFER 27
395 /* This struct is not used in this scanner,
396 but its presence is necessary. */
399 flex_int32_t yy_verify;
402 static yyconst flex_int16_t yy_accept[61] =
404 14, 14, 7, 7, 10, 10, 0, 0, 27, 25,
405 24, 19, 20, 21, 23, 14, 25, 22, 17, 18,
406 15, 16, 7, 7, 6, 7, 7, 10, 12, 11,
407 26, 26, 14, 0, 1, 7, 7, 7, 5, 7,
408 10, 11, 11, 13, 0, 0, 2, 1, 4, 0,
409 3, 0, 2, 0, 3, 0, 0, 8, 9, 0
412 static yyconst flex_int32_t yy_ec[256] =
414 1, 1, 1, 1, 1, 1, 1, 1, 2, 3,
415 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
416 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
417 1, 2, 1, 1, 1, 1, 1, 1, 1, 4,
418 5, 6, 1, 7, 8, 8, 9, 10, 10, 10,
419 10, 10, 10, 10, 10, 10, 10, 1, 11, 1,
420 1, 1, 1, 1, 8, 8, 8, 8, 8, 8,
421 8, 8, 8, 8, 8, 8, 8, 8, 8, 8,
422 8, 8, 8, 8, 8, 8, 8, 8, 8, 8,
423 12, 1, 13, 14, 8, 1, 8, 8, 8, 8,
425 8, 8, 15, 8, 8, 8, 8, 8, 8, 8,
426 8, 8, 8, 8, 8, 8, 8, 8, 8, 8,
427 8, 8, 16, 1, 17, 1, 1, 1, 1, 1,
428 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
429 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
430 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
431 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
432 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
433 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
434 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
436 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
437 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
438 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
439 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
440 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
444 static yyconst flex_int32_t yy_meta[18] =
446 1, 1, 2, 1, 1, 3, 1, 4, 1, 4,
450 static yyconst flex_int16_t yy_base[69] =
452 0, 0, 16, 30, 17, 18, 78, 77, 85, 88,
453 88, 88, 88, 88, 88, 0, 19, 88, 88, 88,
454 88, 88, 0, 24, 88, 75, 77, 0, 88, 21,
455 88, 76, 0, 22, 0, 0, 27, 75, 0, 71,
456 0, 29, 34, 88, 29, 65, 76, 0, 0, 63,
457 74, 60, 72, 56, 65, 51, 50, 88, 88, 88,
458 45, 49, 53, 55, 57, 61, 65, 69
461 static yyconst flex_int16_t yy_def[69] =
463 60, 1, 61, 61, 62, 62, 63, 63, 60, 60,
464 60, 60, 60, 60, 60, 64, 60, 60, 60, 60,
465 60, 60, 65, 65, 60, 65, 65, 66, 60, 67,
466 60, 60, 64, 60, 68, 65, 65, 65, 65, 65,
467 66, 67, 67, 60, 60, 60, 60, 68, 65, 60,
468 60, 60, 60, 60, 60, 60, 60, 60, 60, 0,
469 60, 60, 60, 60, 60, 60, 60, 60
472 static yyconst flex_int16_t yy_nxt[106] =
474 10, 10, 11, 12, 13, 14, 15, 16, 17, 16,
475 18, 19, 20, 10, 16, 21, 22, 24, 25, 29,
476 29, 26, 30, 30, 34, 37, 43, 35, 37, 44,
477 27, 24, 25, 46, 60, 26, 47, 60, 38, 43,
478 50, 38, 44, 51, 27, 23, 23, 23, 23, 28,
479 28, 28, 28, 31, 31, 31, 31, 36, 33, 36,
480 36, 41, 59, 58, 41, 42, 55, 42, 42, 48,
481 57, 48, 48, 53, 56, 55, 54, 53, 52, 49,
482 40, 45, 40, 39, 60, 32, 32, 9, 60, 60,
483 60, 60, 60, 60, 60, 60, 60, 60, 60, 60,
488 static yyconst flex_int16_t yy_chk[106] =
490 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
491 1, 1, 1, 1, 1, 1, 1, 3, 3, 5,
492 6, 3, 5, 6, 17, 24, 30, 17, 37, 30,
493 3, 4, 4, 34, 42, 4, 34, 42, 24, 43,
494 45, 37, 43, 45, 4, 61, 61, 61, 61, 62,
495 62, 62, 62, 63, 63, 63, 63, 65, 64, 65,
496 65, 66, 57, 56, 66, 67, 55, 67, 67, 68,
497 54, 68, 68, 53, 52, 51, 50, 47, 46, 40,
498 38, 32, 27, 26, 9, 8, 7, 60, 60, 60,
499 60, 60, 60, 60, 60, 60, 60, 60, 60, 60,
504 static yy_state_type yy_last_accepting_state;
505 static char *yy_last_accepting_cpos;
507 extern int gras_ddt_parse__flex_debug;
508 int gras_ddt_parse__flex_debug = 0;
510 /* The intent behind this definition is that it'll catch
511 * any uses of REJECT which flex missed.
513 #define REJECT reject_used_but_not_detected
514 #define yymore() yymore_used_but_not_detected
515 #define YY_MORE_ADJ 0
516 #define YY_RESTORE_YY_MORE_OFFSET
517 char *gras_ddt_parse_text;
518 /* DataDesc/ddt_parse -- automatic parsing of data structures */
519 /* Copyright (c) 2004 Arnaud Legrand, Martin Quinson. All rights reserved. */
520 /* This program is free software; you can redistribute it and/or modify it
521 * under the terms of the license (GNU LGPL) which comes with this package. */
522 #include "gras/DataDesc/datadesc_private.h"
523 #include "gras/DataDesc/ddt_parse.yy.h"
525 YY_BUFFER_STATE gras_ddt_input_buffer;
526 FILE *gras_ddt_file_to_parse;
528 int gras_ddt_parse_line_pos = 1;
529 int gras_ddt_parse_col_pos = 0;
530 int gras_ddt_parse_char_pos = 0;
531 int gras_ddt_parse_tok_num = 0;
532 const char *definition;
533 XBT_LOG_NEW_DEFAULT_SUBCATEGORY(gras_ddt_lexer,gras_ddt_parse,"The crude internals of the lexer used for type parsing");
534 #define SHOW_WHERE XBT_DEBUG("%d:%d (char #%d): seen '%s'", gras_ddt_parse_line_pos,gras_ddt_parse_col_pos,gras_ddt_parse_char_pos,gras_ddt_parse_text)
541 #ifndef YY_NO_UNISTD_H
542 /* Special case for "unistd.h", since it is non-ANSI. We include it way
543 * down here because we want the user's section 1 to have been scanned first.
544 * The user has a chance to override it with an option.
549 #ifndef YY_EXTRA_TYPE
550 #define YY_EXTRA_TYPE void *
553 static int yy_init_globals (void );
555 /* Accessor methods to globals.
556 These are made visible to non-reentrant scanners for convenience. */
558 int gras_ddt_parse_lex_destroy (void );
560 int gras_ddt_parse_get_debug (void );
562 void gras_ddt_parse_set_debug (int debug_flag );
564 YY_EXTRA_TYPE gras_ddt_parse_get_extra (void );
566 void gras_ddt_parse_set_extra (YY_EXTRA_TYPE user_defined );
568 FILE *gras_ddt_parse_get_in (void );
570 void gras_ddt_parse_set_in (FILE * in_str );
572 FILE *gras_ddt_parse_get_out (void );
574 void gras_ddt_parse_set_out (FILE * out_str );
576 int gras_ddt_parse_get_leng (void );
578 char *gras_ddt_parse_get_text (void );
580 int gras_ddt_parse_get_lineno (void );
582 void gras_ddt_parse_set_lineno (int line_number );
584 /* Macros after this point can all be overridden by user definitions in
588 #ifndef YY_SKIP_YYWRAP
590 extern "C" int gras_ddt_parse_wrap (void );
592 extern int gras_ddt_parse_wrap (void );
596 static void yyunput (int c,char *buf_ptr );
599 static void yy_flex_strncpy (char *,yyconst char *,int );
602 #ifdef YY_NEED_STRLEN
603 static int yy_flex_strlen (yyconst char * );
609 static int yyinput (void );
611 static int input (void );
616 /* Amount of stuff to slurp up with each read. */
617 #ifndef YY_READ_BUF_SIZE
619 /* On IA-64, the buffer size is 16k, not 8k */
620 #define YY_READ_BUF_SIZE 16384
622 #define YY_READ_BUF_SIZE 8192
623 #endif /* __ia64__ */
626 /* Copy whatever the last rule matched to the standard output. */
628 /* This used to be an fputs(), but since the string might contain NUL's,
629 * we now use fwrite().
631 #define ECHO do { if (fwrite( gras_ddt_parse_text, gras_ddt_parse_leng, 1, gras_ddt_parse_out )) {} } while (0)
634 /* Gets input and stuffs it into "buf". number of characters read, or YY_NULL,
635 * is returned in "result".
638 #define YY_INPUT(buf,result,max_size) \
639 if ( YY_CURRENT_BUFFER_LVALUE->yy_is_interactive ) \
643 for ( n = 0; n < max_size && \
644 (c = getc( gras_ddt_parse_in )) != EOF && c != '\n'; ++n ) \
647 buf[n++] = (char) c; \
648 if ( c == EOF && ferror( gras_ddt_parse_in ) ) \
649 YY_FATAL_ERROR( "input in flex scanner failed" ); \
655 while ( (result = fread(buf, 1, max_size, gras_ddt_parse_in))==0 && ferror(gras_ddt_parse_in)) \
657 if( errno != EINTR) \
659 YY_FATAL_ERROR( "input in flex scanner failed" ); \
663 clearerr(gras_ddt_parse_in); \
670 /* No semi-colon after return; correct usage is to write "yyterminate();" -
671 * we don't want an extra ';' after the "return" because that will cause
672 * some compilers to complain about unreachable statements.
675 #define yyterminate() return YY_NULL
678 /* Number of entries by which start-condition stack grows. */
679 #ifndef YY_START_STACK_INCR
680 #define YY_START_STACK_INCR 25
683 /* Report a fatal error. */
684 #ifndef YY_FATAL_ERROR
685 #define YY_FATAL_ERROR(msg) yy_fatal_error( msg )
688 /* end tables serialization structures and prototypes */
690 /* Default declaration of generated scanner - a define so the user can
691 * easily add parameters.
694 #define YY_DECL_IS_OURS 1
696 extern int gras_ddt_parse_lex (void);
698 #define YY_DECL int gras_ddt_parse_lex (void)
699 #endif /* !YY_DECL */
701 /* Code executed at the beginning of each rule, after gras_ddt_parse_text and gras_ddt_parse_leng
704 #ifndef YY_USER_ACTION
705 #define YY_USER_ACTION
708 /* Code executed at the end of each rule. */
710 #define YY_BREAK break;
713 #define YY_RULE_SETUP \
716 /** The main scanner function which does all the work.
720 register yy_state_type yy_current_state;
721 register char *yy_cp, *yy_bp;
724 int comment_caller=0;
725 int annotate_caller=0;
736 (yy_start) = 1; /* first start state */
738 if ( ! gras_ddt_parse_in )
739 gras_ddt_parse_in = stdin;
741 if ( ! gras_ddt_parse_out )
742 gras_ddt_parse_out = stdout;
744 if ( ! YY_CURRENT_BUFFER ) {
745 gras_ddt_parse_ensure_buffer_stack ();
746 YY_CURRENT_BUFFER_LVALUE =
747 gras_ddt_parse__create_buffer(gras_ddt_parse_in,YY_BUF_SIZE );
750 gras_ddt_parse__load_buffer_state( );
753 while ( 1 ) /* loops until end-of-file is reached */
755 yy_cp = (yy_c_buf_p);
757 /* Support of gras_ddt_parse_text. */
758 *yy_cp = (yy_hold_char);
760 /* yy_bp points to the position in yy_ch_buf of the start of
765 yy_current_state = (yy_start);
769 register YY_CHAR yy_c = yy_ec[YY_SC_TO_UI(*yy_cp)];
770 if ( yy_accept[yy_current_state] )
772 (yy_last_accepting_state) = yy_current_state;
773 (yy_last_accepting_cpos) = yy_cp;
775 while ( yy_chk[yy_base[yy_current_state] + yy_c] != yy_current_state )
777 yy_current_state = (int) yy_def[yy_current_state];
778 if ( yy_current_state >= 61 )
779 yy_c = yy_meta[(unsigned int) yy_c];
781 yy_current_state = yy_nxt[yy_base[yy_current_state] + (unsigned int) yy_c];
784 while ( yy_base[yy_current_state] != 88 );
787 yy_act = yy_accept[yy_current_state];
789 { /* have to back up */
790 yy_cp = (yy_last_accepting_cpos);
791 yy_current_state = (yy_last_accepting_state);
792 yy_act = yy_accept[yy_current_state];
797 do_action: /* This label is used only to access EOF actions. */
800 { /* beginning of action switch */
801 case 0: /* must back up */
802 /* undo the effects of YY_DO_BEFORE_ACTION */
803 *yy_cp = (yy_hold_char);
804 yy_cp = (yy_last_accepting_cpos);
805 yy_current_state = (yy_last_accepting_state);
814 { /****************** ANNOTATION ************************/
815 XBT_DEBUG("Begin annotation");
816 annotate_caller = INITIAL;
817 gras_ddt_parse_char_pos+= strlen(gras_ddt_parse_text);
818 gras_ddt_parse_col_pos+= strlen(gras_ddt_parse_text);
824 { /* trim annotation */
825 XBT_DEBUG("Begin annotation");
826 annotate_caller = foo;
827 gras_ddt_parse_char_pos+= strlen(gras_ddt_parse_text);
828 gras_ddt_parse_col_pos+= strlen(gras_ddt_parse_text);
835 XBT_DEBUG("End annotation");
836 gras_ddt_parse_char_pos+= strlen(gras_ddt_parse_text);
837 gras_ddt_parse_col_pos+= strlen(gras_ddt_parse_text);
838 BEGIN(annotate_caller);
844 PARSE_ERROR("``/*g'' construct closed by a regular ``*/''");
848 /* rule 6 can match eol */
851 PARSE_ERROR("Type annotation cannot spread over several lines");
857 gras_ddt_parse_char_pos+= strlen(gras_ddt_parse_text);
858 gras_ddt_parse_col_pos+= strlen(gras_ddt_parse_text);
859 return GRAS_DDT_PARSE_TOKEN_ANNOTATE;
864 { /****************** COMMENTS ************************/
865 /* constructs like : */
867 /* are not comments but size annotations */
868 comment_caller = INITIAL;
875 comment_caller = foo;
881 { /* eat anything that's not a '*' */
886 { /* eat up '*'s not followed by '/'s */
890 /* rule 12 can match eol */
893 ++gras_ddt_parse_line_pos;
894 gras_ddt_parse_col_pos=0;
895 gras_ddt_parse_char_pos++;
901 gras_ddt_parse_char_pos+= strlen(gras_ddt_parse_text);
902 gras_ddt_parse_col_pos+= strlen(gras_ddt_parse_text);
903 BEGIN(comment_caller);
908 { /****************** STATEMENTS ************************/
909 gras_ddt_parse_char_pos += strlen(gras_ddt_parse_text);
910 gras_ddt_parse_col_pos += strlen(gras_ddt_parse_text);
912 return(GRAS_DDT_PARSE_TOKEN_WORD);
918 gras_ddt_parse_char_pos++;
919 gras_ddt_parse_col_pos++;
921 return(GRAS_DDT_PARSE_TOKEN_LA);
927 gras_ddt_parse_char_pos++;
928 gras_ddt_parse_col_pos++;
930 return(GRAS_DDT_PARSE_TOKEN_RA);
936 gras_ddt_parse_char_pos++;
937 gras_ddt_parse_col_pos++;
939 return(GRAS_DDT_PARSE_TOKEN_LB);
945 gras_ddt_parse_char_pos++;
946 gras_ddt_parse_col_pos++;
948 return(GRAS_DDT_PARSE_TOKEN_RB);
954 gras_ddt_parse_char_pos++;
955 gras_ddt_parse_col_pos++;
957 return(GRAS_DDT_PARSE_TOKEN_LP);
963 gras_ddt_parse_char_pos++;
964 gras_ddt_parse_col_pos++;
966 return(GRAS_DDT_PARSE_TOKEN_RP);
972 gras_ddt_parse_char_pos++;
973 gras_ddt_parse_col_pos++;
975 return(GRAS_DDT_PARSE_TOKEN_STAR);
981 gras_ddt_parse_char_pos++;
982 gras_ddt_parse_col_pos++;
984 return(GRAS_DDT_PARSE_TOKEN_SEMI_COLON);
990 gras_ddt_parse_char_pos++;
991 gras_ddt_parse_col_pos++;
993 return(GRAS_DDT_PARSE_TOKEN_COLON);
997 /* rule 24 can match eol */
1000 gras_ddt_parse_line_pos++;
1001 gras_ddt_parse_char_pos++;
1002 gras_ddt_parse_col_pos=0;
1009 gras_ddt_parse_char_pos++;
1010 gras_ddt_parse_col_pos++;
1018 case YY_STATE_EOF(INITIAL):
1019 case YY_STATE_EOF(annotate):
1020 case YY_STATE_EOF(comment):
1021 case YY_STATE_EOF(foo):
1024 case YY_END_OF_BUFFER:
1026 /* Amount of text matched not including the EOB char. */
1027 int yy_amount_of_matched_text = (int) (yy_cp - (yytext_ptr)) - 1;
1029 /* Undo the effects of YY_DO_BEFORE_ACTION. */
1030 *yy_cp = (yy_hold_char);
1031 YY_RESTORE_YY_MORE_OFFSET
1033 if ( YY_CURRENT_BUFFER_LVALUE->yy_buffer_status == YY_BUFFER_NEW )
1035 /* We're scanning a new file or input source. It's
1036 * possible that this happened because the user
1037 * just pointed gras_ddt_parse_in at a new source and called
1038 * gras_ddt_parse_lex(). If so, then we have to assure
1039 * consistency between YY_CURRENT_BUFFER and our
1040 * globals. Here is the right place to do so, because
1041 * this is the first action (other than possibly a
1042 * back-up) that will match for the new input source.
1044 (yy_n_chars) = YY_CURRENT_BUFFER_LVALUE->yy_n_chars;
1045 YY_CURRENT_BUFFER_LVALUE->yy_input_file = gras_ddt_parse_in;
1046 YY_CURRENT_BUFFER_LVALUE->yy_buffer_status = YY_BUFFER_NORMAL;
1049 /* Note that here we test for yy_c_buf_p "<=" to the position
1050 * of the first EOB in the buffer, since yy_c_buf_p will
1051 * already have been incremented past the NUL character
1052 * (since all states make transitions on EOB to the
1053 * end-of-buffer state). Contrast this with the test
1056 if ( (yy_c_buf_p) <= &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[(yy_n_chars)] )
1057 { /* This was really a NUL. */
1058 yy_state_type yy_next_state;
1060 (yy_c_buf_p) = (yytext_ptr) + yy_amount_of_matched_text;
1062 yy_current_state = yy_get_previous_state( );
1064 /* Okay, we're now positioned to make the NUL
1065 * transition. We couldn't have
1066 * yy_get_previous_state() go ahead and do it
1067 * for us because it doesn't know how to deal
1068 * with the possibility of jamming (and we don't
1069 * want to build jamming into it because then it
1070 * will run more slowly).
1073 yy_next_state = yy_try_NUL_trans( yy_current_state );
1075 yy_bp = (yytext_ptr) + YY_MORE_ADJ;
1077 if ( yy_next_state )
1079 /* Consume the NUL. */
1080 yy_cp = ++(yy_c_buf_p);
1081 yy_current_state = yy_next_state;
1087 yy_cp = (yy_c_buf_p);
1088 goto yy_find_action;
1092 else switch ( yy_get_next_buffer( ) )
1094 case EOB_ACT_END_OF_FILE:
1096 (yy_did_buffer_switch_on_eof) = 0;
1098 if ( gras_ddt_parse_wrap( ) )
1100 /* Note: because we've taken care in
1101 * yy_get_next_buffer() to have set up
1102 * gras_ddt_parse_text, we can now set up
1103 * yy_c_buf_p so that if some total
1104 * hoser (like flex itself) wants to
1105 * call the scanner after we return the
1106 * YY_NULL, it'll still work - another
1107 * YY_NULL will get returned.
1109 (yy_c_buf_p) = (yytext_ptr) + YY_MORE_ADJ;
1111 yy_act = YY_STATE_EOF(YY_START);
1117 if ( ! (yy_did_buffer_switch_on_eof) )
1123 case EOB_ACT_CONTINUE_SCAN:
1125 (yytext_ptr) + yy_amount_of_matched_text;
1127 yy_current_state = yy_get_previous_state( );
1129 yy_cp = (yy_c_buf_p);
1130 yy_bp = (yytext_ptr) + YY_MORE_ADJ;
1133 case EOB_ACT_LAST_MATCH:
1135 &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[(yy_n_chars)];
1137 yy_current_state = yy_get_previous_state( );
1139 yy_cp = (yy_c_buf_p);
1140 yy_bp = (yytext_ptr) + YY_MORE_ADJ;
1141 goto yy_find_action;
1148 "fatal flex scanner internal error--no action found" );
1149 } /* end of action switch */
1150 } /* end of scanning one token */
1151 } /* end of gras_ddt_parse_lex */
1153 /* yy_get_next_buffer - try to read in a new buffer
1155 * Returns a code representing an action:
1156 * EOB_ACT_LAST_MATCH -
1157 * EOB_ACT_CONTINUE_SCAN - continue scanning from current position
1158 * EOB_ACT_END_OF_FILE - end of file
1160 static int yy_get_next_buffer (void)
1162 register char *dest = YY_CURRENT_BUFFER_LVALUE->yy_ch_buf;
1163 register char *source = (yytext_ptr);
1164 register int number_to_move, i;
1167 if ( (yy_c_buf_p) > &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[(yy_n_chars) + 1] )
1169 "fatal flex scanner internal error--end of buffer missed" );
1171 if ( YY_CURRENT_BUFFER_LVALUE->yy_fill_buffer == 0 )
1172 { /* Don't try to fill the buffer, so this is an EOF. */
1173 if ( (yy_c_buf_p) - (yytext_ptr) - YY_MORE_ADJ == 1 )
1175 /* We matched a single character, the EOB, so
1176 * treat this as a final EOF.
1178 return EOB_ACT_END_OF_FILE;
1183 /* We matched some text prior to the EOB, first
1186 return EOB_ACT_LAST_MATCH;
1190 /* Try to read more data. */
1192 /* First move last chars to start of buffer. */
1193 number_to_move = (int) ((yy_c_buf_p) - (yytext_ptr)) - 1;
1195 for ( i = 0; i < number_to_move; ++i )
1196 *(dest++) = *(source++);
1198 if ( YY_CURRENT_BUFFER_LVALUE->yy_buffer_status == YY_BUFFER_EOF_PENDING )
1199 /* don't do the read, it's not guaranteed to return an EOF,
1202 YY_CURRENT_BUFFER_LVALUE->yy_n_chars = (yy_n_chars) = 0;
1207 YY_CURRENT_BUFFER_LVALUE->yy_buf_size - number_to_move - 1;
1209 while ( num_to_read <= 0 )
1210 { /* Not enough room in the buffer - grow it. */
1212 /* just a shorter name for the current buffer */
1213 YY_BUFFER_STATE b = YY_CURRENT_BUFFER;
1215 int yy_c_buf_p_offset =
1216 (int) ((yy_c_buf_p) - b->yy_ch_buf);
1218 if ( b->yy_is_our_buffer )
1220 int new_size = b->yy_buf_size * 2;
1222 if ( new_size <= 0 )
1223 b->yy_buf_size += b->yy_buf_size / 8;
1225 b->yy_buf_size *= 2;
1227 b->yy_ch_buf = (char *)
1228 /* Include room in for 2 EOB chars. */
1229 gras_ddt_parse_realloc((void *) b->yy_ch_buf,b->yy_buf_size + 2 );
1232 /* Can't grow it, we don't own it. */
1235 if ( ! b->yy_ch_buf )
1237 "fatal error - scanner input buffer overflow" );
1239 (yy_c_buf_p) = &b->yy_ch_buf[yy_c_buf_p_offset];
1241 num_to_read = YY_CURRENT_BUFFER_LVALUE->yy_buf_size -
1246 if ( num_to_read > YY_READ_BUF_SIZE )
1247 num_to_read = YY_READ_BUF_SIZE;
1249 /* Read in more data. */
1250 YY_INPUT( (&YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[number_to_move]),
1251 (yy_n_chars), (size_t) num_to_read );
1253 YY_CURRENT_BUFFER_LVALUE->yy_n_chars = (yy_n_chars);
1256 if ( (yy_n_chars) == 0 )
1258 if ( number_to_move == YY_MORE_ADJ )
1260 ret_val = EOB_ACT_END_OF_FILE;
1261 gras_ddt_parse_restart(gras_ddt_parse_in );
1266 ret_val = EOB_ACT_LAST_MATCH;
1267 YY_CURRENT_BUFFER_LVALUE->yy_buffer_status =
1268 YY_BUFFER_EOF_PENDING;
1273 ret_val = EOB_ACT_CONTINUE_SCAN;
1275 if ((yy_size_t) ((yy_n_chars) + number_to_move) > YY_CURRENT_BUFFER_LVALUE->yy_buf_size) {
1276 /* Extend the array by 50%, plus the number we really need. */
1277 yy_size_t new_size = (yy_n_chars) + number_to_move + ((yy_n_chars) >> 1);
1278 YY_CURRENT_BUFFER_LVALUE->yy_ch_buf = (char *) gras_ddt_parse_realloc((void *) YY_CURRENT_BUFFER_LVALUE->yy_ch_buf,new_size );
1279 if ( ! YY_CURRENT_BUFFER_LVALUE->yy_ch_buf )
1280 YY_FATAL_ERROR( "out of dynamic memory in yy_get_next_buffer()" );
1283 (yy_n_chars) += number_to_move;
1284 YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[(yy_n_chars)] = YY_END_OF_BUFFER_CHAR;
1285 YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[(yy_n_chars) + 1] = YY_END_OF_BUFFER_CHAR;
1287 (yytext_ptr) = &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[0];
1292 /* yy_get_previous_state - get the state just before the EOB char was reached */
1294 static yy_state_type yy_get_previous_state (void)
1296 register yy_state_type yy_current_state;
1297 register char *yy_cp;
1299 yy_current_state = (yy_start);
1301 for ( yy_cp = (yytext_ptr) + YY_MORE_ADJ; yy_cp < (yy_c_buf_p); ++yy_cp )
1303 register YY_CHAR yy_c = (*yy_cp ? yy_ec[YY_SC_TO_UI(*yy_cp)] : 1);
1304 if ( yy_accept[yy_current_state] )
1306 (yy_last_accepting_state) = yy_current_state;
1307 (yy_last_accepting_cpos) = yy_cp;
1309 while ( yy_chk[yy_base[yy_current_state] + yy_c] != yy_current_state )
1311 yy_current_state = (int) yy_def[yy_current_state];
1312 if ( yy_current_state >= 61 )
1313 yy_c = yy_meta[(unsigned int) yy_c];
1315 yy_current_state = yy_nxt[yy_base[yy_current_state] + (unsigned int) yy_c];
1318 return yy_current_state;
1321 /* yy_try_NUL_trans - try to make a transition on the NUL character
1324 * next_state = yy_try_NUL_trans( current_state );
1326 static yy_state_type yy_try_NUL_trans (yy_state_type yy_current_state )
1328 register int yy_is_jam;
1329 register char *yy_cp = (yy_c_buf_p);
1331 register YY_CHAR yy_c = 1;
1332 if ( yy_accept[yy_current_state] )
1334 (yy_last_accepting_state) = yy_current_state;
1335 (yy_last_accepting_cpos) = yy_cp;
1337 while ( yy_chk[yy_base[yy_current_state] + yy_c] != yy_current_state )
1339 yy_current_state = (int) yy_def[yy_current_state];
1340 if ( yy_current_state >= 61 )
1341 yy_c = yy_meta[(unsigned int) yy_c];
1343 yy_current_state = yy_nxt[yy_base[yy_current_state] + (unsigned int) yy_c];
1344 yy_is_jam = (yy_current_state == 60);
1346 return yy_is_jam ? 0 : yy_current_state;
1349 static void yyunput (int c, register char * yy_bp )
1351 register char *yy_cp;
1353 yy_cp = (yy_c_buf_p);
1355 /* undo effects of setting up gras_ddt_parse_text */
1356 *yy_cp = (yy_hold_char);
1358 if ( yy_cp < YY_CURRENT_BUFFER_LVALUE->yy_ch_buf + 2 )
1359 { /* need to shift things up to make room */
1360 /* +2 for EOB chars. */
1361 register int number_to_move = (yy_n_chars) + 2;
1362 register char *dest = &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[
1363 YY_CURRENT_BUFFER_LVALUE->yy_buf_size + 2];
1364 register char *source =
1365 &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[number_to_move];
1367 while ( source > YY_CURRENT_BUFFER_LVALUE->yy_ch_buf )
1368 *--dest = *--source;
1370 yy_cp += (int) (dest - source);
1371 yy_bp += (int) (dest - source);
1372 YY_CURRENT_BUFFER_LVALUE->yy_n_chars =
1373 (yy_n_chars) = YY_CURRENT_BUFFER_LVALUE->yy_buf_size;
1375 if ( yy_cp < YY_CURRENT_BUFFER_LVALUE->yy_ch_buf + 2 )
1376 YY_FATAL_ERROR( "flex scanner push-back overflow" );
1379 *--yy_cp = (char) c;
1381 (yytext_ptr) = yy_bp;
1382 (yy_hold_char) = *yy_cp;
1383 (yy_c_buf_p) = yy_cp;
1388 static int yyinput (void)
1390 static int input (void)
1396 *(yy_c_buf_p) = (yy_hold_char);
1398 if ( *(yy_c_buf_p) == YY_END_OF_BUFFER_CHAR )
1400 /* yy_c_buf_p now points to the character we want to return.
1401 * If this occurs *before* the EOB characters, then it's a
1402 * valid NUL; if not, then we've hit the end of the buffer.
1404 if ( (yy_c_buf_p) < &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[(yy_n_chars)] )
1405 /* This was really a NUL. */
1406 *(yy_c_buf_p) = '\0';
1409 { /* need more input */
1410 int offset = (yy_c_buf_p) - (yytext_ptr);
1413 switch ( yy_get_next_buffer( ) )
1415 case EOB_ACT_LAST_MATCH:
1416 /* This happens because yy_g_n_b()
1417 * sees that we've accumulated a
1418 * token and flags that we need to
1419 * try matching the token before
1420 * proceeding. But for input(),
1421 * there's no matching to consider.
1422 * So convert the EOB_ACT_LAST_MATCH
1423 * to EOB_ACT_END_OF_FILE.
1426 /* Reset buffer status. */
1427 gras_ddt_parse_restart(gras_ddt_parse_in );
1431 case EOB_ACT_END_OF_FILE:
1433 if ( gras_ddt_parse_wrap( ) )
1436 if ( ! (yy_did_buffer_switch_on_eof) )
1445 case EOB_ACT_CONTINUE_SCAN:
1446 (yy_c_buf_p) = (yytext_ptr) + offset;
1452 c = *(unsigned char *) (yy_c_buf_p); /* cast for 8-bit char's */
1453 *(yy_c_buf_p) = '\0'; /* preserve gras_ddt_parse_text */
1454 (yy_hold_char) = *++(yy_c_buf_p);
1458 #endif /* ifndef YY_NO_INPUT */
1460 /** Immediately switch to a different input stream.
1461 * @param input_file A readable stream.
1463 * @note This function does not reset the start condition to @c INITIAL .
1465 void gras_ddt_parse_restart (FILE * input_file )
1468 if ( ! YY_CURRENT_BUFFER ){
1469 gras_ddt_parse_ensure_buffer_stack ();
1470 YY_CURRENT_BUFFER_LVALUE =
1471 gras_ddt_parse__create_buffer(gras_ddt_parse_in,YY_BUF_SIZE );
1474 gras_ddt_parse__init_buffer(YY_CURRENT_BUFFER,input_file );
1475 gras_ddt_parse__load_buffer_state( );
1478 /** Switch to a different input buffer.
1479 * @param new_buffer The new input buffer.
1482 void gras_ddt_parse__switch_to_buffer (YY_BUFFER_STATE new_buffer )
1485 /* TODO. We should be able to replace this entire function body
1487 * gras_ddt_parse_pop_buffer_state();
1488 * gras_ddt_parse_push_buffer_state(new_buffer);
1490 gras_ddt_parse_ensure_buffer_stack ();
1491 if ( YY_CURRENT_BUFFER == new_buffer )
1494 if ( YY_CURRENT_BUFFER )
1496 /* Flush out information for old buffer. */
1497 *(yy_c_buf_p) = (yy_hold_char);
1498 YY_CURRENT_BUFFER_LVALUE->yy_buf_pos = (yy_c_buf_p);
1499 YY_CURRENT_BUFFER_LVALUE->yy_n_chars = (yy_n_chars);
1502 YY_CURRENT_BUFFER_LVALUE = new_buffer;
1503 gras_ddt_parse__load_buffer_state( );
1505 /* We don't actually know whether we did this switch during
1506 * EOF (gras_ddt_parse_wrap()) processing, but the only time this flag
1507 * is looked at is after gras_ddt_parse_wrap() is called, so it's safe
1508 * to go ahead and always set it.
1510 (yy_did_buffer_switch_on_eof) = 1;
1513 static void gras_ddt_parse__load_buffer_state (void)
1515 (yy_n_chars) = YY_CURRENT_BUFFER_LVALUE->yy_n_chars;
1516 (yytext_ptr) = (yy_c_buf_p) = YY_CURRENT_BUFFER_LVALUE->yy_buf_pos;
1517 gras_ddt_parse_in = YY_CURRENT_BUFFER_LVALUE->yy_input_file;
1518 (yy_hold_char) = *(yy_c_buf_p);
1521 /** Allocate and initialize an input buffer state.
1522 * @param file A readable stream.
1523 * @param size The character buffer size in bytes. When in doubt, use @c YY_BUF_SIZE.
1525 * @return the allocated buffer state.
1527 YY_BUFFER_STATE gras_ddt_parse__create_buffer (FILE * file, int size )
1531 b = (YY_BUFFER_STATE) gras_ddt_parse_alloc(sizeof( struct yy_buffer_state ) );
1533 YY_FATAL_ERROR( "out of dynamic memory in gras_ddt_parse__create_buffer()" );
1535 b->yy_buf_size = size;
1537 /* yy_ch_buf has to be 2 characters longer than the size given because
1538 * we need to put in 2 end-of-buffer characters.
1540 b->yy_ch_buf = (char *) gras_ddt_parse_alloc(b->yy_buf_size + 2 );
1541 if ( ! b->yy_ch_buf )
1542 YY_FATAL_ERROR( "out of dynamic memory in gras_ddt_parse__create_buffer()" );
1544 b->yy_is_our_buffer = 1;
1546 gras_ddt_parse__init_buffer(b,file );
1551 /** Destroy the buffer.
1552 * @param b a buffer created with gras_ddt_parse__create_buffer()
1555 void gras_ddt_parse__delete_buffer (YY_BUFFER_STATE b )
1561 if ( b == YY_CURRENT_BUFFER ) /* Not sure if we should pop here. */
1562 YY_CURRENT_BUFFER_LVALUE = (YY_BUFFER_STATE) 0;
1564 if ( b->yy_is_our_buffer )
1565 gras_ddt_parse_free((void *) b->yy_ch_buf );
1567 gras_ddt_parse_free((void *) b );
1571 extern int isatty (int );
1572 #endif /* __cplusplus */
1574 /* Initializes or reinitializes a buffer.
1575 * This function is sometimes called more than once on the same buffer,
1576 * such as during a gras_ddt_parse_restart() or at EOF.
1578 static void gras_ddt_parse__init_buffer (YY_BUFFER_STATE b, FILE * file )
1583 gras_ddt_parse__flush_buffer(b );
1585 b->yy_input_file = file;
1586 b->yy_fill_buffer = 1;
1588 /* If b is the current buffer, then gras_ddt_parse__init_buffer was _probably_
1589 * called from gras_ddt_parse_restart() or through yy_get_next_buffer.
1590 * In that case, we don't want to reset the lineno or column.
1592 if (b != YY_CURRENT_BUFFER){
1593 b->yy_bs_lineno = 1;
1594 b->yy_bs_column = 0;
1597 b->yy_is_interactive = file ? (isatty( fileno(file) ) > 0) : 0;
1602 /** Discard all buffered characters. On the next scan, YY_INPUT will be called.
1603 * @param b the buffer state to be flushed, usually @c YY_CURRENT_BUFFER.
1606 void gras_ddt_parse__flush_buffer (YY_BUFFER_STATE b )
1613 /* We always need two end-of-buffer characters. The first causes
1614 * a transition to the end-of-buffer state. The second causes
1615 * a jam in that state.
1617 b->yy_ch_buf[0] = YY_END_OF_BUFFER_CHAR;
1618 b->yy_ch_buf[1] = YY_END_OF_BUFFER_CHAR;
1620 b->yy_buf_pos = &b->yy_ch_buf[0];
1623 b->yy_buffer_status = YY_BUFFER_NEW;
1625 if ( b == YY_CURRENT_BUFFER )
1626 gras_ddt_parse__load_buffer_state( );
1629 /** Pushes the new state onto the stack. The new state becomes
1630 * the current state. This function will allocate the stack
1632 * @param new_buffer The new state.
1635 void gras_ddt_parse_push_buffer_state (YY_BUFFER_STATE new_buffer )
1637 if (new_buffer == NULL)
1640 gras_ddt_parse_ensure_buffer_stack();
1642 /* This block is copied from gras_ddt_parse__switch_to_buffer. */
1643 if ( YY_CURRENT_BUFFER )
1645 /* Flush out information for old buffer. */
1646 *(yy_c_buf_p) = (yy_hold_char);
1647 YY_CURRENT_BUFFER_LVALUE->yy_buf_pos = (yy_c_buf_p);
1648 YY_CURRENT_BUFFER_LVALUE->yy_n_chars = (yy_n_chars);
1651 /* Only push if top exists. Otherwise, replace top. */
1652 if (YY_CURRENT_BUFFER)
1653 (yy_buffer_stack_top)++;
1654 YY_CURRENT_BUFFER_LVALUE = new_buffer;
1656 /* copied from gras_ddt_parse__switch_to_buffer. */
1657 gras_ddt_parse__load_buffer_state( );
1658 (yy_did_buffer_switch_on_eof) = 1;
1661 /** Removes and deletes the top of the stack, if present.
1662 * The next element becomes the new top.
1665 void gras_ddt_parse_pop_buffer_state (void)
1667 if (!YY_CURRENT_BUFFER)
1670 gras_ddt_parse__delete_buffer(YY_CURRENT_BUFFER );
1671 YY_CURRENT_BUFFER_LVALUE = NULL;
1672 if ((yy_buffer_stack_top) > 0)
1673 --(yy_buffer_stack_top);
1675 if (YY_CURRENT_BUFFER) {
1676 gras_ddt_parse__load_buffer_state( );
1677 (yy_did_buffer_switch_on_eof) = 1;
1681 /* Allocates the stack if it does not exist.
1682 * Guarantees space for at least one push.
1684 static void gras_ddt_parse_ensure_buffer_stack (void)
1688 if (!(yy_buffer_stack)) {
1690 /* First allocation is just for 2 elements, since we don't know if this
1691 * scanner will even need a stack. We use 2 instead of 1 to avoid an
1692 * immediate realloc on the next call.
1695 (yy_buffer_stack) = (struct yy_buffer_state**)gras_ddt_parse_alloc
1696 (num_to_alloc * sizeof(struct yy_buffer_state*)
1698 if ( ! (yy_buffer_stack) )
1699 YY_FATAL_ERROR( "out of dynamic memory in gras_ddt_parse_ensure_buffer_stack()" );
1701 memset((yy_buffer_stack), 0, num_to_alloc * sizeof(struct yy_buffer_state*));
1703 (yy_buffer_stack_max) = num_to_alloc;
1704 (yy_buffer_stack_top) = 0;
1708 if ((yy_buffer_stack_top) >= ((yy_buffer_stack_max)) - 1){
1710 /* Increase the buffer to prepare for a possible push. */
1711 int grow_size = 8 /* arbitrary grow size */;
1713 num_to_alloc = (yy_buffer_stack_max) + grow_size;
1714 (yy_buffer_stack) = (struct yy_buffer_state**)gras_ddt_parse_realloc
1716 num_to_alloc * sizeof(struct yy_buffer_state*)
1718 if ( ! (yy_buffer_stack) )
1719 YY_FATAL_ERROR( "out of dynamic memory in gras_ddt_parse_ensure_buffer_stack()" );
1721 /* zero only the new slots.*/
1722 memset((yy_buffer_stack) + (yy_buffer_stack_max), 0, grow_size * sizeof(struct yy_buffer_state*));
1723 (yy_buffer_stack_max) = num_to_alloc;
1727 /** Setup the input buffer state to scan directly from a user-specified character buffer.
1728 * @param base the character buffer
1729 * @param size the size in bytes of the character buffer
1731 * @return the newly allocated buffer state object.
1733 YY_BUFFER_STATE gras_ddt_parse__scan_buffer (char * base, yy_size_t size )
1738 base[size-2] != YY_END_OF_BUFFER_CHAR ||
1739 base[size-1] != YY_END_OF_BUFFER_CHAR )
1740 /* They forgot to leave room for the EOB's. */
1743 b = (YY_BUFFER_STATE) gras_ddt_parse_alloc(sizeof( struct yy_buffer_state ) );
1745 YY_FATAL_ERROR( "out of dynamic memory in gras_ddt_parse__scan_buffer()" );
1747 b->yy_buf_size = size - 2; /* "- 2" to take care of EOB's */
1748 b->yy_buf_pos = b->yy_ch_buf = base;
1749 b->yy_is_our_buffer = 0;
1750 b->yy_input_file = 0;
1751 b->yy_n_chars = b->yy_buf_size;
1752 b->yy_is_interactive = 0;
1754 b->yy_fill_buffer = 0;
1755 b->yy_buffer_status = YY_BUFFER_NEW;
1757 gras_ddt_parse__switch_to_buffer(b );
1762 /** Setup the input buffer state to scan a string. The next call to gras_ddt_parse_lex() will
1763 * scan from a @e copy of @a str.
1764 * @param yystr a NUL-terminated string to scan
1766 * @return the newly allocated buffer state object.
1767 * @note If you want to scan bytes that may contain NUL values, then use
1768 * gras_ddt_parse__scan_bytes() instead.
1770 YY_BUFFER_STATE gras_ddt_parse__scan_string (yyconst char * yystr )
1773 return gras_ddt_parse__scan_bytes(yystr,strlen(yystr) );
1776 /** Setup the input buffer state to scan the given bytes. The next call to gras_ddt_parse_lex() will
1777 * scan from a @e copy of @a bytes.
1778 * @param yybytes the byte buffer to scan
1779 * @param _yybytes_len the number of bytes in the buffer pointed to by @a bytes.
1781 * @return the newly allocated buffer state object.
1783 YY_BUFFER_STATE gras_ddt_parse__scan_bytes (yyconst char * yybytes, int _yybytes_len )
1790 /* Get memory for full buffer, including space for trailing EOB's. */
1791 n = _yybytes_len + 2;
1792 buf = (char *) gras_ddt_parse_alloc(n );
1794 YY_FATAL_ERROR( "out of dynamic memory in gras_ddt_parse__scan_bytes()" );
1796 for ( i = 0; i < _yybytes_len; ++i )
1797 buf[i] = yybytes[i];
1799 buf[_yybytes_len] = buf[_yybytes_len+1] = YY_END_OF_BUFFER_CHAR;
1801 b = gras_ddt_parse__scan_buffer(buf,n );
1803 YY_FATAL_ERROR( "bad buffer in gras_ddt_parse__scan_bytes()" );
1805 /* It's okay to grow etc. this buffer, and we should throw it
1806 * away when we're done.
1808 b->yy_is_our_buffer = 1;
1813 #ifndef YY_EXIT_FAILURE
1814 #define YY_EXIT_FAILURE 2
1817 static void yy_fatal_error (yyconst char* msg )
1819 (void) fprintf( stderr, "%s\n", msg );
1820 exit( YY_EXIT_FAILURE );
1823 /* Redefine yyless() so it works in section 3 code. */
1829 /* Undo effects of setting up gras_ddt_parse_text. */ \
1830 int yyless_macro_arg = (n); \
1831 YY_LESS_LINENO(yyless_macro_arg);\
1832 gras_ddt_parse_text[gras_ddt_parse_leng] = (yy_hold_char); \
1833 (yy_c_buf_p) = gras_ddt_parse_text + yyless_macro_arg; \
1834 (yy_hold_char) = *(yy_c_buf_p); \
1835 *(yy_c_buf_p) = '\0'; \
1836 gras_ddt_parse_leng = yyless_macro_arg; \
1840 /* Accessor methods (get/set functions) to struct members. */
1842 /** Get the current line number.
1845 int gras_ddt_parse_get_lineno (void)
1848 return gras_ddt_parse_lineno;
1851 /** Get the input stream.
1854 FILE *gras_ddt_parse_get_in (void)
1856 return gras_ddt_parse_in;
1859 /** Get the output stream.
1862 FILE *gras_ddt_parse_get_out (void)
1864 return gras_ddt_parse_out;
1867 /** Get the length of the current token.
1870 int gras_ddt_parse_get_leng (void)
1872 return gras_ddt_parse_leng;
1875 /** Get the current token.
1879 char *gras_ddt_parse_get_text (void)
1881 return gras_ddt_parse_text;
1884 /** Set the current line number.
1885 * @param line_number
1888 void gras_ddt_parse_set_lineno (int line_number )
1891 gras_ddt_parse_lineno = line_number;
1894 /** Set the input stream. This does not discard the current
1896 * @param in_str A readable stream.
1898 * @see gras_ddt_parse__switch_to_buffer
1900 void gras_ddt_parse_set_in (FILE * in_str )
1902 gras_ddt_parse_in = in_str ;
1905 void gras_ddt_parse_set_out (FILE * out_str )
1907 gras_ddt_parse_out = out_str ;
1910 int gras_ddt_parse_get_debug (void)
1912 return gras_ddt_parse__flex_debug;
1915 void gras_ddt_parse_set_debug (int bdebug )
1917 gras_ddt_parse__flex_debug = bdebug ;
1920 static int yy_init_globals (void)
1922 /* Initialization is the same as for the non-reentrant scanner.
1923 * This function is called from gras_ddt_parse_lex_destroy(), so don't allocate here.
1926 (yy_buffer_stack) = 0;
1927 (yy_buffer_stack_top) = 0;
1928 (yy_buffer_stack_max) = 0;
1929 (yy_c_buf_p) = (char *) 0;
1933 /* Defined in main.c */
1935 gras_ddt_parse_in = stdin;
1936 gras_ddt_parse_out = stdout;
1938 gras_ddt_parse_in = (FILE *) 0;
1939 gras_ddt_parse_out = (FILE *) 0;
1942 /* For future reference: Set errno on error, since we are called by
1943 * gras_ddt_parse_lex_init()
1948 /* gras_ddt_parse_lex_destroy is for both reentrant and non-reentrant scanners. */
1949 int gras_ddt_parse_lex_destroy (void)
1952 /* Pop the buffer stack, destroying each element. */
1953 while(YY_CURRENT_BUFFER){
1954 gras_ddt_parse__delete_buffer(YY_CURRENT_BUFFER );
1955 YY_CURRENT_BUFFER_LVALUE = NULL;
1956 gras_ddt_parse_pop_buffer_state();
1959 /* Destroy the stack itself. */
1960 gras_ddt_parse_free((yy_buffer_stack) );
1961 (yy_buffer_stack) = NULL;
1963 /* Reset the globals. This is important in a non-reentrant scanner so the next time
1964 * gras_ddt_parse_lex() is called, initialization will occur. */
1971 * Internal utility routines.
1975 static void yy_flex_strncpy (char* s1, yyconst char * s2, int n )
1978 for ( i = 0; i < n; ++i )
1983 #ifdef YY_NEED_STRLEN
1984 static int yy_flex_strlen (yyconst char * s )
1987 for ( n = 0; s[n]; ++n )
1994 void *gras_ddt_parse_alloc (yy_size_t size )
1996 return (void *) malloc( size );
1999 void *gras_ddt_parse_realloc (void * ptr, yy_size_t size )
2001 /* The cast to (char *) in the following accommodates both
2002 * implementations that use char* generic pointers, and those
2003 * that use void* generic pointers. It works with the latter
2004 * because both ANSI C and C++ allow castless assignment from
2005 * any pointer type to void*, and deal with argument conversions
2006 * as though doing an assignment.
2008 return (void *) realloc( (char *) ptr, size );
2011 void gras_ddt_parse_free (void * ptr )
2013 free( (char *) ptr ); /* see gras_ddt_parse_realloc() for (char *) cast */
2016 #define YYTABLES_NAME "yytables"
2018 /* {space}+ { return(TOKEN_SPACE);} */
2020 void gras_ddt_parse_dump(void) {
2021 switch(gras_ddt_parse_tok_num) {
2022 case GRAS_DDT_PARSE_TOKEN_LA : {printf("TOKEN_LA ");break;}
2023 case GRAS_DDT_PARSE_TOKEN_RA : {printf("TOKEN_RA ");break;}
2024 case GRAS_DDT_PARSE_TOKEN_WORD : {printf("TOKEN_WORD ");break;}
2025 /* case GRAS_DDT_PARSE_TOKEN_SPACE : {printf("TOKEN_SPACE ");break;}*/
2026 /* case GRAS_DDT_PARSE_TOKEN_COMMENT : {printf("TOKEN_COMMENT ");break;}*/
2027 case GRAS_DDT_PARSE_TOKEN_NEWLINE : {printf("TOKEN_NEWLINE\n");return;}
2028 case GRAS_DDT_PARSE_TOKEN_EMPTY : {printf("TOKEN_EMPTY\n");return;}
2029 default : {printf("Unknown token %d\n", gras_ddt_parse_tok_num);return;}
2031 printf("-->%s<-- [line %d, pos %d]\n",gras_ddt_parse_text,gras_ddt_parse_line_pos,gras_ddt_parse_char_pos);
2035 int gras_ddt_parse_lex_n_dump(void) {
2036 gras_ddt_parse_tok_num = gras_ddt_parse_lex();
2037 /* gras_ddt_parse_char_pos += strlen(gras_ddt_parse_text);*/
2038 return(gras_ddt_parse_tok_num);
2041 void gras_ddt_parse_pointer_init(const char *file) {
2042 gras_ddt_file_to_parse = fopen(file,"r");
2043 gras_ddt_input_buffer = gras_ddt_parse__create_buffer(gras_ddt_file_to_parse,10 );
2044 gras_ddt_parse__switch_to_buffer(gras_ddt_input_buffer);
2046 gras_ddt_parse_line_pos = 1;
2047 gras_ddt_parse_char_pos = 0;
2048 gras_ddt_parse_col_pos = 0;
2049 gras_ddt_parse_tok_num = 0;
2052 void gras_ddt_parse_pointer_close(void) {
2053 gras_ddt_parse__delete_buffer(gras_ddt_input_buffer);
2054 fclose(gras_ddt_file_to_parse);
2056 gras_ddt_parse_line_pos = 1;
2057 gras_ddt_parse_char_pos = 0;
2058 gras_ddt_parse_tok_num = 0;
2061 void gras_ddt_parse_pointer_string_init(const char *string_to_parse) {
2062 gras_ddt_input_buffer = gras_ddt_parse__scan_string (string_to_parse);
2063 definition = string_to_parse;
2064 gras_ddt_parse__switch_to_buffer(gras_ddt_input_buffer);
2066 gras_ddt_parse_line_pos = 1;
2067 gras_ddt_parse_char_pos = 0;
2068 gras_ddt_parse_tok_num = 0;
2071 void gras_ddt_parse_pointer_string_close(void) {
2072 gras_ddt_parse__delete_buffer(gras_ddt_input_buffer);
2074 gras_ddt_parse_line_pos = 1;
2075 gras_ddt_parse_char_pos = 0;
2076 gras_ddt_parse_tok_num = 0;
2079 yyunput('\0',NULL); /* fake a use of this function to calm gcc down */
2082 /* Local variables:*/