2 #line 3 "gras/DataDesc/ddt_parse.yy.c"
4 #define YY_INT_ALIGNED short int
6 /* A lexical scanner generated by flex */
9 #define YY_FLEX_MAJOR_VERSION 2
10 #define YY_FLEX_MINOR_VERSION 5
11 #define YY_FLEX_SUBMINOR_VERSION 31
12 #if YY_FLEX_SUBMINOR_VERSION > 0
16 /* First, we deal with platform-specific or compiler-specific issues. */
18 /* begin standard C headers. */
24 /* end standard C headers. */
26 /* flex integer type definitions */
31 /* C99 systems have <inttypes.h>. Non-C99 systems may or may not. */
33 #if defined __STDC_VERSION__ && __STDC_VERSION__ >= 199901L
35 typedef int8_t flex_int8_t;
36 typedef uint8_t flex_uint8_t;
37 typedef int16_t flex_int16_t;
38 typedef uint16_t flex_uint16_t;
39 typedef int32_t flex_int32_t;
40 typedef uint32_t flex_uint32_t;
42 typedef signed char flex_int8_t;
43 typedef short int flex_int16_t;
44 typedef int flex_int32_t;
45 typedef unsigned char flex_uint8_t;
46 typedef unsigned short int flex_uint16_t;
47 typedef unsigned int flex_uint32_t;
50 /* Limits of integral types. */
52 #define INT8_MIN (-128)
55 #define INT16_MIN (-32767-1)
58 #define INT32_MIN (-2147483647-1)
61 #define INT8_MAX (127)
64 #define INT16_MAX (32767)
67 #define INT32_MAX (2147483647)
70 #define UINT8_MAX (255U)
73 #define UINT16_MAX (65535U)
76 #define UINT32_MAX (4294967295U)
79 #endif /* ! FLEXINT_H */
83 /* The "const" storage-class-modifier is valid. */
86 #else /* ! __cplusplus */
93 #endif /* ! __cplusplus */
101 /* Returned upon end-of-file. */
104 /* Promotes a possibly negative, possibly signed char to an unsigned
105 * integer for use as an array index. If the signed char is negative,
106 * we want to instead treat it as an 8-bit unsigned char, hence the
109 #define YY_SC_TO_UI(c) ((unsigned int) (unsigned char) c)
111 /* Enter a start condition. This macro really ought to take a parameter,
112 * but we do it the disgusting crufty way forced on us by the ()-less
113 * definition of BEGIN.
115 #define BEGIN (yy_start) = 1 + 2 *
117 /* Translate the current start state into a value that can be later handed
118 * to BEGIN to return to the state. The YYSTATE alias is for lex
121 #define YY_START (((yy_start) - 1) / 2)
122 #define YYSTATE YY_START
124 /* Action number for EOF rule of a given start state. */
125 #define YY_STATE_EOF(state) (YY_END_OF_BUFFER + state + 1)
127 /* Special action meaning "start processing a new file". */
128 #define YY_NEW_FILE gras_ddt_parse_restart(gras_ddt_parse_in )
130 #define YY_END_OF_BUFFER_CHAR 0
132 /* Size of default input buffer. */
134 #define YY_BUF_SIZE 16384
137 #ifndef YY_TYPEDEF_YY_BUFFER_STATE
138 #define YY_TYPEDEF_YY_BUFFER_STATE
139 typedef struct yy_buffer_state *YY_BUFFER_STATE;
142 extern int gras_ddt_parse_leng;
144 extern FILE *gras_ddt_parse_in, *gras_ddt_parse_out;
146 #define EOB_ACT_CONTINUE_SCAN 0
147 #define EOB_ACT_END_OF_FILE 1
148 #define EOB_ACT_LAST_MATCH 2
150 #define YY_LESS_LINENO(n)
152 /* Return all but the first "n" matched characters back to the input stream. */
156 /* Undo effects of setting up gras_ddt_parse_text. */ \
157 int yyless_macro_arg = (n); \
158 YY_LESS_LINENO(yyless_macro_arg);\
159 *yy_cp = (yy_hold_char); \
160 YY_RESTORE_YY_MORE_OFFSET \
161 (yy_c_buf_p) = yy_cp = yy_bp + yyless_macro_arg - YY_MORE_ADJ; \
162 YY_DO_BEFORE_ACTION; /* set up gras_ddt_parse_text again */ \
166 #define unput(c) yyunput( c, (yytext_ptr) )
168 /* The following is because we cannot portably get our hands on size_t
169 * (without autoconf's help, which isn't available because we want
170 * flex-generated scanners to compile on their own).
173 #ifndef YY_TYPEDEF_YY_SIZE_T
174 #define YY_TYPEDEF_YY_SIZE_T
175 typedef unsigned int yy_size_t;
178 #ifndef YY_STRUCT_YY_BUFFER_STATE
179 #define YY_STRUCT_YY_BUFFER_STATE
180 struct yy_buffer_state
184 char *yy_ch_buf; /* input buffer */
185 char *yy_buf_pos; /* current position in input buffer */
187 /* Size of input buffer in bytes, not including room for EOB
190 yy_size_t yy_buf_size;
192 /* Number of characters read into yy_ch_buf, not including EOB
197 /* Whether we "own" the buffer - i.e., we know we created it,
198 * and can realloc() it to grow it, and should free() it to
201 int yy_is_our_buffer;
203 /* Whether this is an "interactive" input source; if so, and
204 * if we're using stdio for input, then we want to use getc()
205 * instead of fread(), to make sure we stop fetching input after
208 int yy_is_interactive;
210 /* Whether we're considered to be at the beginning of a line.
211 * If so, '^' rules will be active on the next match, otherwise
216 int yy_bs_lineno; /**< The line count. */
217 int yy_bs_column; /**< The column count. */
219 /* Whether to try to fill the input buffer when we reach the
224 int yy_buffer_status;
226 #define YY_BUFFER_NEW 0
227 #define YY_BUFFER_NORMAL 1
228 /* When an EOF's been seen but there's still some text to process
229 * then we mark the buffer as YY_EOF_PENDING, to indicate that we
230 * shouldn't try reading from the input source any more. We might
231 * still have a bunch of tokens to match, though, because of
232 * possible backing-up.
234 * When we actually see the EOF, we change the status to "new"
235 * (via gras_ddt_parse_restart()), so that the user can continue scanning by
236 * just pointing gras_ddt_parse_in at a new input file.
238 #define YY_BUFFER_EOF_PENDING 2
241 #endif /* !YY_STRUCT_YY_BUFFER_STATE */
243 /* Stack of input buffers. */
244 static size_t yy_buffer_stack_top = 0; /**< index of top of stack. */
245 static size_t yy_buffer_stack_max = 0; /**< capacity of stack. */
246 static YY_BUFFER_STATE * yy_buffer_stack = 0; /**< Stack as an array. */
248 /* We provide macros for accessing buffer states in case in the
249 * future we want to put the buffer states in a more general
252 * Returns the top of the stack, or NULL.
254 #define YY_CURRENT_BUFFER ( (yy_buffer_stack) \
255 ? (yy_buffer_stack)[(yy_buffer_stack_top)] \
258 /* Same as previous macro, but useful when we know that the buffer stack is not
259 * NULL or when we need an lvalue. For internal use only.
261 #define YY_CURRENT_BUFFER_LVALUE (yy_buffer_stack)[(yy_buffer_stack_top)]
263 /* yy_hold_char holds the character lost when gras_ddt_parse_text is formed. */
264 static char yy_hold_char;
265 static int yy_n_chars; /* number of characters read into yy_ch_buf */
266 int gras_ddt_parse_leng;
268 /* Points to current character in buffer. */
269 static char *yy_c_buf_p = (char *) 0;
270 static int yy_init = 1; /* whether we need to initialize */
271 static int yy_start = 0; /* start state number */
273 /* Flag which is used to allow gras_ddt_parse_wrap()'s to do buffer switches
274 * instead of setting up a fresh gras_ddt_parse_in. A bit of a hack ...
276 static int yy_did_buffer_switch_on_eof;
278 void gras_ddt_parse_restart (FILE *input_file );
279 void gras_ddt_parse__switch_to_buffer (YY_BUFFER_STATE new_buffer );
280 YY_BUFFER_STATE gras_ddt_parse__create_buffer (FILE *file,int size );
281 void gras_ddt_parse__delete_buffer (YY_BUFFER_STATE b );
282 void gras_ddt_parse__flush_buffer (YY_BUFFER_STATE b );
283 void gras_ddt_parse_push_buffer_state (YY_BUFFER_STATE new_buffer );
284 void gras_ddt_parse_pop_buffer_state (void );
286 static void gras_ddt_parse_ensure_buffer_stack (void );
287 static void gras_ddt_parse__load_buffer_state (void );
288 static void gras_ddt_parse__init_buffer (YY_BUFFER_STATE b,FILE *file );
290 #define YY_FLUSH_BUFFER gras_ddt_parse__flush_buffer(YY_CURRENT_BUFFER )
292 YY_BUFFER_STATE gras_ddt_parse__scan_buffer (char *base,yy_size_t size );
293 YY_BUFFER_STATE gras_ddt_parse__scan_string (yyconst char *yy_str );
294 YY_BUFFER_STATE gras_ddt_parse__scan_bytes (yyconst char *bytes,int len );
296 void *gras_ddt_parse_alloc (yy_size_t );
297 void *gras_ddt_parse_realloc (void *,yy_size_t );
298 void gras_ddt_parse_free (void * );
300 #define yy_new_buffer gras_ddt_parse__create_buffer
302 #define yy_set_interactive(is_interactive) \
304 if ( ! YY_CURRENT_BUFFER ){ \
305 gras_ddt_parse_ensure_buffer_stack (); \
306 YY_CURRENT_BUFFER_LVALUE = \
307 gras_ddt_parse__create_buffer(gras_ddt_parse_in,YY_BUF_SIZE ); \
309 YY_CURRENT_BUFFER_LVALUE->yy_is_interactive = is_interactive; \
312 #define yy_set_bol(at_bol) \
314 if ( ! YY_CURRENT_BUFFER ){\
315 gras_ddt_parse_ensure_buffer_stack (); \
316 YY_CURRENT_BUFFER_LVALUE = \
317 gras_ddt_parse__create_buffer(gras_ddt_parse_in,YY_BUF_SIZE ); \
319 YY_CURRENT_BUFFER_LVALUE->yy_at_bol = at_bol; \
322 #define YY_AT_BOL() (YY_CURRENT_BUFFER_LVALUE->yy_at_bol)
324 /* Begin user sect3 */
326 #define gras_ddt_parse_wrap() 1
327 #define YY_SKIP_YYWRAP
329 typedef unsigned char YY_CHAR;
331 FILE *gras_ddt_parse_in = (FILE *) 0, *gras_ddt_parse_out = (FILE *) 0;
333 typedef int yy_state_type;
335 extern int gras_ddt_parse_lineno;
337 int gras_ddt_parse_lineno = 1;
339 extern char *gras_ddt_parse_text;
340 #define yytext_ptr gras_ddt_parse_text
342 static yy_state_type yy_get_previous_state (void );
343 static yy_state_type yy_try_NUL_trans (yy_state_type current_state );
344 static int yy_get_next_buffer (void );
345 static void yy_fatal_error (yyconst char msg[] );
347 /* Done after the current pattern has been matched and before the
348 * corresponding action - sets up gras_ddt_parse_text.
350 #define YY_DO_BEFORE_ACTION \
351 (yytext_ptr) = yy_bp; \
352 gras_ddt_parse_leng = (size_t) (yy_cp - yy_bp); \
353 (yy_hold_char) = *yy_cp; \
355 (yy_c_buf_p) = yy_cp;
357 #define YY_NUM_RULES 26
358 #define YY_END_OF_BUFFER 27
359 /* This struct is not used in this scanner,
360 but its presence is necessary. */
363 flex_int32_t yy_verify;
366 static yyconst flex_int16_t yy_accept[61] =
368 14, 14, 7, 7, 10, 10, 0, 0, 27, 25,
369 24, 19, 20, 21, 23, 14, 25, 22, 17, 18,
370 15, 16, 7, 7, 6, 7, 7, 10, 12, 11,
371 26, 26, 14, 0, 1, 7, 7, 7, 5, 7,
372 10, 11, 11, 13, 0, 0, 2, 1, 4, 0,
373 3, 0, 2, 0, 3, 0, 0, 8, 9, 0
376 static yyconst flex_int32_t yy_ec[256] =
378 1, 1, 1, 1, 1, 1, 1, 1, 2, 3,
379 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
380 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
381 1, 2, 1, 1, 1, 1, 1, 1, 1, 4,
382 5, 6, 1, 7, 8, 8, 9, 10, 10, 10,
383 10, 10, 10, 10, 10, 10, 10, 1, 11, 1,
384 1, 1, 1, 1, 8, 8, 8, 8, 8, 8,
385 8, 8, 8, 8, 8, 8, 8, 8, 8, 8,
386 8, 8, 8, 8, 8, 8, 8, 8, 8, 8,
387 12, 1, 13, 14, 8, 1, 8, 8, 8, 8,
389 8, 8, 15, 8, 8, 8, 8, 8, 8, 8,
390 8, 8, 8, 8, 8, 8, 8, 8, 8, 8,
391 8, 8, 16, 1, 17, 1, 1, 1, 1, 1,
392 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
393 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
394 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
395 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
396 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
397 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
398 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
400 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
401 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
402 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
403 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
404 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
408 static yyconst flex_int32_t yy_meta[18] =
410 1, 1, 2, 1, 1, 3, 1, 4, 1, 4,
414 static yyconst flex_int16_t yy_base[69] =
416 0, 0, 16, 30, 17, 18, 78, 77, 85, 88,
417 88, 88, 88, 88, 88, 0, 19, 88, 88, 88,
418 88, 88, 0, 24, 88, 75, 77, 0, 88, 21,
419 88, 76, 0, 22, 0, 0, 27, 75, 0, 71,
420 0, 29, 34, 88, 29, 65, 76, 0, 0, 63,
421 74, 60, 72, 56, 65, 51, 50, 88, 88, 88,
422 45, 49, 53, 55, 57, 61, 65, 69
425 static yyconst flex_int16_t yy_def[69] =
427 60, 1, 61, 61, 62, 62, 63, 63, 60, 60,
428 60, 60, 60, 60, 60, 64, 60, 60, 60, 60,
429 60, 60, 65, 65, 60, 65, 65, 66, 60, 67,
430 60, 60, 64, 60, 68, 65, 65, 65, 65, 65,
431 66, 67, 67, 60, 60, 60, 60, 68, 65, 60,
432 60, 60, 60, 60, 60, 60, 60, 60, 60, 0,
433 60, 60, 60, 60, 60, 60, 60, 60
436 static yyconst flex_int16_t yy_nxt[106] =
438 10, 10, 11, 12, 13, 14, 15, 16, 17, 16,
439 18, 19, 20, 10, 16, 21, 22, 24, 25, 29,
440 29, 26, 30, 30, 34, 37, 43, 35, 37, 44,
441 27, 24, 25, 46, 60, 26, 47, 60, 38, 43,
442 50, 38, 44, 51, 27, 23, 23, 23, 23, 28,
443 28, 28, 28, 31, 31, 31, 31, 36, 33, 36,
444 36, 41, 59, 58, 41, 42, 55, 42, 42, 48,
445 57, 48, 48, 53, 56, 55, 54, 53, 52, 49,
446 40, 45, 40, 39, 60, 32, 32, 9, 60, 60,
447 60, 60, 60, 60, 60, 60, 60, 60, 60, 60,
452 static yyconst flex_int16_t yy_chk[106] =
454 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
455 1, 1, 1, 1, 1, 1, 1, 3, 3, 5,
456 6, 3, 5, 6, 17, 24, 30, 17, 37, 30,
457 3, 4, 4, 34, 42, 4, 34, 42, 24, 43,
458 45, 37, 43, 45, 4, 61, 61, 61, 61, 62,
459 62, 62, 62, 63, 63, 63, 63, 65, 64, 65,
460 65, 66, 57, 56, 66, 67, 55, 67, 67, 68,
461 54, 68, 68, 53, 52, 51, 50, 47, 46, 40,
462 38, 32, 27, 26, 9, 8, 7, 60, 60, 60,
463 60, 60, 60, 60, 60, 60, 60, 60, 60, 60,
468 static yy_state_type yy_last_accepting_state;
469 static char *yy_last_accepting_cpos;
471 extern int gras_ddt_parse__flex_debug;
472 int gras_ddt_parse__flex_debug = 0;
474 /* The intent behind this definition is that it'll catch
475 * any uses of REJECT which flex missed.
477 #define REJECT reject_used_but_not_detected
478 #define yymore() yymore_used_but_not_detected
479 #define YY_MORE_ADJ 0
480 #define YY_RESTORE_YY_MORE_OFFSET
481 char *gras_ddt_parse_text;
483 /* DataDesc/ddt_parse -- automatic parsing of data structures */
484 /* Copyright (c) 2004 Arnaud Legrand, Martin Quinson. All rights reserved. */
485 /* This program is free software; you can redistribute it and/or modify it
486 * under the terms of the license (GNU LGPL) which comes with this package. */
487 #include "gras/DataDesc/datadesc_private.h"
488 #include "gras/DataDesc/ddt_parse.yy.h"
490 YY_BUFFER_STATE gras_ddt_input_buffer;
491 FILE *gras_ddt_file_to_parse;
493 int gras_ddt_parse_line_pos = 1;
494 int gras_ddt_parse_col_pos = 0;
495 int gras_ddt_parse_char_pos = 0;
496 int gras_ddt_parse_tok_num = 0;
497 const char *definition;
498 XBT_LOG_NEW_DEFAULT_SUBCATEGORY(gras_ddt_lexer,gras_ddt_parse,"The crude internals of the lexer used for type parsing");
499 #define SHOW_WHERE DEBUG4("%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)
506 #ifndef YY_NO_UNISTD_H
507 /* Special case for "unistd.h", since it is non-ANSI. We include it way
508 * down here because we want the user's section 1 to have been scanned first.
509 * The user has a chance to override it with an option.
514 #ifndef YY_EXTRA_TYPE
515 #define YY_EXTRA_TYPE void *
518 /* Macros after this point can all be overridden by user definitions in
522 #ifndef YY_SKIP_YYWRAP
524 extern "C" int gras_ddt_parse_wrap (void );
526 extern int gras_ddt_parse_wrap (void );
530 static void yyunput (int c,char *buf_ptr );
533 static void yy_flex_strncpy (char *,yyconst char *,int );
536 #ifdef YY_NEED_STRLEN
537 static int yy_flex_strlen (yyconst char * );
543 static int yyinput (void );
545 static int input (void );
550 /* Amount of stuff to slurp up with each read. */
551 #ifndef YY_READ_BUF_SIZE
552 #define YY_READ_BUF_SIZE 8192
555 /* Copy whatever the last rule matched to the standard output. */
557 /* This used to be an fputs(), but since the string might contain NUL's,
558 * we now use fwrite().
560 #define ECHO (void) fwrite( gras_ddt_parse_text, gras_ddt_parse_leng, 1, gras_ddt_parse_out )
563 /* Gets input and stuffs it into "buf". number of characters read, or YY_NULL,
564 * is returned in "result".
567 #define YY_INPUT(buf,result,max_size) \
568 if ( YY_CURRENT_BUFFER_LVALUE->yy_is_interactive ) \
572 for ( n = 0; n < max_size && \
573 (c = getc( gras_ddt_parse_in )) != EOF && c != '\n'; ++n ) \
576 buf[n++] = (char) c; \
577 if ( c == EOF && ferror( gras_ddt_parse_in ) ) \
578 YY_FATAL_ERROR( "input in flex scanner failed" ); \
584 while ( (result = fread(buf, 1, max_size, gras_ddt_parse_in))==0 && ferror(gras_ddt_parse_in)) \
586 if( errno != EINTR) \
588 YY_FATAL_ERROR( "input in flex scanner failed" ); \
592 clearerr(gras_ddt_parse_in); \
599 /* No semi-colon after return; correct usage is to write "yyterminate();" -
600 * we don't want an extra ';' after the "return" because that will cause
601 * some compilers to complain about unreachable statements.
604 #define yyterminate() return YY_NULL
607 /* Number of entries by which start-condition stack grows. */
608 #ifndef YY_START_STACK_INCR
609 #define YY_START_STACK_INCR 25
612 /* Report a fatal error. */
613 #ifndef YY_FATAL_ERROR
614 #define YY_FATAL_ERROR(msg) yy_fatal_error( msg )
617 /* end tables serialization structures and prototypes */
619 /* Default declaration of generated scanner - a define so the user can
620 * easily add parameters.
623 #define YY_DECL_IS_OURS 1
625 extern int gras_ddt_parse_lex (void);
627 #define YY_DECL int gras_ddt_parse_lex (void)
628 #endif /* !YY_DECL */
630 /* Code executed at the beginning of each rule, after gras_ddt_parse_text and gras_ddt_parse_leng
633 #ifndef YY_USER_ACTION
634 #define YY_USER_ACTION
637 /* Code executed at the end of each rule. */
639 #define YY_BREAK break;
642 #define YY_RULE_SETUP \
645 /** The main scanner function which does all the work.
649 register yy_state_type yy_current_state;
650 register char *yy_cp, *yy_bp;
653 int comment_caller=0;
654 int annotate_caller=0;
665 (yy_start) = 1; /* first start state */
667 if ( ! gras_ddt_parse_in )
668 gras_ddt_parse_in = stdin;
670 if ( ! gras_ddt_parse_out )
671 gras_ddt_parse_out = stdout;
673 if ( ! YY_CURRENT_BUFFER ) {
674 gras_ddt_parse_ensure_buffer_stack ();
675 YY_CURRENT_BUFFER_LVALUE =
676 gras_ddt_parse__create_buffer(gras_ddt_parse_in,YY_BUF_SIZE );
679 gras_ddt_parse__load_buffer_state( );
682 while ( 1 ) /* loops until end-of-file is reached */
684 yy_cp = (yy_c_buf_p);
686 /* Support of gras_ddt_parse_text. */
687 *yy_cp = (yy_hold_char);
689 /* yy_bp points to the position in yy_ch_buf of the start of
694 yy_current_state = (yy_start);
698 register YY_CHAR yy_c = yy_ec[YY_SC_TO_UI(*yy_cp)];
699 if ( yy_accept[yy_current_state] )
701 (yy_last_accepting_state) = yy_current_state;
702 (yy_last_accepting_cpos) = yy_cp;
704 while ( yy_chk[yy_base[yy_current_state] + yy_c] != yy_current_state )
706 yy_current_state = (int) yy_def[yy_current_state];
707 if ( yy_current_state >= 61 )
708 yy_c = yy_meta[(unsigned int) yy_c];
710 yy_current_state = yy_nxt[yy_base[yy_current_state] + (unsigned int) yy_c];
713 while ( yy_base[yy_current_state] != 88 );
716 yy_act = yy_accept[yy_current_state];
718 { /* have to back up */
719 yy_cp = (yy_last_accepting_cpos);
720 yy_current_state = (yy_last_accepting_state);
721 yy_act = yy_accept[yy_current_state];
726 do_action: /* This label is used only to access EOF actions. */
729 { /* beginning of action switch */
730 case 0: /* must back up */
731 /* undo the effects of YY_DO_BEFORE_ACTION */
732 *yy_cp = (yy_hold_char);
733 yy_cp = (yy_last_accepting_cpos);
734 yy_current_state = (yy_last_accepting_state);
743 { /****************** ANNOTATION ************************/
744 DEBUG0("Begin annotation");
745 annotate_caller = INITIAL;
746 gras_ddt_parse_char_pos+= strlen(gras_ddt_parse_text);
747 gras_ddt_parse_col_pos+= strlen(gras_ddt_parse_text);
753 { /* trim annotation */
754 DEBUG0("Begin annotation");
755 annotate_caller = foo;
756 gras_ddt_parse_char_pos+= strlen(gras_ddt_parse_text);
757 gras_ddt_parse_col_pos+= strlen(gras_ddt_parse_text);
764 DEBUG0("End annotation");
765 gras_ddt_parse_char_pos+= strlen(gras_ddt_parse_text);
766 gras_ddt_parse_col_pos+= strlen(gras_ddt_parse_text);
767 BEGIN(annotate_caller);
773 PARSE_ERROR0("``/*g'' construct closed by a regular ``*/''");
777 /* rule 6 can match eol */
780 PARSE_ERROR0("Type annotation cannot spread over several lines");
786 gras_ddt_parse_char_pos+= strlen(gras_ddt_parse_text);
787 gras_ddt_parse_col_pos+= strlen(gras_ddt_parse_text);
788 return GRAS_DDT_PARSE_TOKEN_ANNOTATE;
793 { /****************** COMMENTS ************************/
794 /* constructs like : */
796 /* are not comments but size annotations */
797 comment_caller = INITIAL;
804 comment_caller = foo;
810 { /* eat anything that's not a '*' */
815 { /* eat up '*'s not followed by '/'s */
819 /* rule 12 can match eol */
822 ++gras_ddt_parse_line_pos;
823 gras_ddt_parse_col_pos=0;
824 gras_ddt_parse_char_pos++;
830 gras_ddt_parse_char_pos+= strlen(gras_ddt_parse_text);
831 gras_ddt_parse_col_pos+= strlen(gras_ddt_parse_text);
832 BEGIN(comment_caller);
837 { /****************** STATEMENTS ************************/
838 gras_ddt_parse_char_pos += strlen(gras_ddt_parse_text);
839 gras_ddt_parse_col_pos += strlen(gras_ddt_parse_text);
841 return(GRAS_DDT_PARSE_TOKEN_WORD);
847 gras_ddt_parse_char_pos++;
848 gras_ddt_parse_col_pos++;
850 return(GRAS_DDT_PARSE_TOKEN_LA);
856 gras_ddt_parse_char_pos++;
857 gras_ddt_parse_col_pos++;
859 return(GRAS_DDT_PARSE_TOKEN_RA);
865 gras_ddt_parse_char_pos++;
866 gras_ddt_parse_col_pos++;
868 return(GRAS_DDT_PARSE_TOKEN_LB);
874 gras_ddt_parse_char_pos++;
875 gras_ddt_parse_col_pos++;
877 return(GRAS_DDT_PARSE_TOKEN_RB);
883 gras_ddt_parse_char_pos++;
884 gras_ddt_parse_col_pos++;
886 return(GRAS_DDT_PARSE_TOKEN_LP);
892 gras_ddt_parse_char_pos++;
893 gras_ddt_parse_col_pos++;
895 return(GRAS_DDT_PARSE_TOKEN_RP);
901 gras_ddt_parse_char_pos++;
902 gras_ddt_parse_col_pos++;
904 return(GRAS_DDT_PARSE_TOKEN_STAR);
910 gras_ddt_parse_char_pos++;
911 gras_ddt_parse_col_pos++;
913 return(GRAS_DDT_PARSE_TOKEN_SEMI_COLON);
919 gras_ddt_parse_char_pos++;
920 gras_ddt_parse_col_pos++;
922 return(GRAS_DDT_PARSE_TOKEN_COLON);
926 /* rule 24 can match eol */
929 gras_ddt_parse_line_pos++;
930 gras_ddt_parse_char_pos++;
931 gras_ddt_parse_col_pos=0;
938 gras_ddt_parse_char_pos++;
939 gras_ddt_parse_col_pos++;
947 case YY_STATE_EOF(INITIAL):
948 case YY_STATE_EOF(annotate):
949 case YY_STATE_EOF(comment):
950 case YY_STATE_EOF(foo):
953 case YY_END_OF_BUFFER:
955 /* Amount of text matched not including the EOB char. */
956 int yy_amount_of_matched_text = (int) (yy_cp - (yytext_ptr)) - 1;
958 /* Undo the effects of YY_DO_BEFORE_ACTION. */
959 *yy_cp = (yy_hold_char);
960 YY_RESTORE_YY_MORE_OFFSET
962 if ( YY_CURRENT_BUFFER_LVALUE->yy_buffer_status == YY_BUFFER_NEW )
964 /* We're scanning a new file or input source. It's
965 * possible that this happened because the user
966 * just pointed gras_ddt_parse_in at a new source and called
967 * gras_ddt_parse_lex(). If so, then we have to assure
968 * consistency between YY_CURRENT_BUFFER and our
969 * globals. Here is the right place to do so, because
970 * this is the first action (other than possibly a
971 * back-up) that will match for the new input source.
973 (yy_n_chars) = YY_CURRENT_BUFFER_LVALUE->yy_n_chars;
974 YY_CURRENT_BUFFER_LVALUE->yy_input_file = gras_ddt_parse_in;
975 YY_CURRENT_BUFFER_LVALUE->yy_buffer_status = YY_BUFFER_NORMAL;
978 /* Note that here we test for yy_c_buf_p "<=" to the position
979 * of the first EOB in the buffer, since yy_c_buf_p will
980 * already have been incremented past the NUL character
981 * (since all states make transitions on EOB to the
982 * end-of-buffer state). Contrast this with the test
985 if ( (yy_c_buf_p) <= &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[(yy_n_chars)] )
986 { /* This was really a NUL. */
987 yy_state_type yy_next_state;
989 (yy_c_buf_p) = (yytext_ptr) + yy_amount_of_matched_text;
991 yy_current_state = yy_get_previous_state( );
993 /* Okay, we're now positioned to make the NUL
994 * transition. We couldn't have
995 * yy_get_previous_state() go ahead and do it
996 * for us because it doesn't know how to deal
997 * with the possibility of jamming (and we don't
998 * want to build jamming into it because then it
999 * will run more slowly).
1002 yy_next_state = yy_try_NUL_trans( yy_current_state );
1004 yy_bp = (yytext_ptr) + YY_MORE_ADJ;
1006 if ( yy_next_state )
1008 /* Consume the NUL. */
1009 yy_cp = ++(yy_c_buf_p);
1010 yy_current_state = yy_next_state;
1016 yy_cp = (yy_c_buf_p);
1017 goto yy_find_action;
1021 else switch ( yy_get_next_buffer( ) )
1023 case EOB_ACT_END_OF_FILE:
1025 (yy_did_buffer_switch_on_eof) = 0;
1027 if ( gras_ddt_parse_wrap( ) )
1029 /* Note: because we've taken care in
1030 * yy_get_next_buffer() to have set up
1031 * gras_ddt_parse_text, we can now set up
1032 * yy_c_buf_p so that if some total
1033 * hoser (like flex itself) wants to
1034 * call the scanner after we return the
1035 * YY_NULL, it'll still work - another
1036 * YY_NULL will get returned.
1038 (yy_c_buf_p) = (yytext_ptr) + YY_MORE_ADJ;
1040 yy_act = YY_STATE_EOF(YY_START);
1046 if ( ! (yy_did_buffer_switch_on_eof) )
1052 case EOB_ACT_CONTINUE_SCAN:
1054 (yytext_ptr) + yy_amount_of_matched_text;
1056 yy_current_state = yy_get_previous_state( );
1058 yy_cp = (yy_c_buf_p);
1059 yy_bp = (yytext_ptr) + YY_MORE_ADJ;
1062 case EOB_ACT_LAST_MATCH:
1064 &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[(yy_n_chars)];
1066 yy_current_state = yy_get_previous_state( );
1068 yy_cp = (yy_c_buf_p);
1069 yy_bp = (yytext_ptr) + YY_MORE_ADJ;
1070 goto yy_find_action;
1077 "fatal flex scanner internal error--no action found" );
1078 } /* end of action switch */
1079 } /* end of scanning one token */
1080 } /* end of gras_ddt_parse_lex */
1082 /* yy_get_next_buffer - try to read in a new buffer
1084 * Returns a code representing an action:
1085 * EOB_ACT_LAST_MATCH -
1086 * EOB_ACT_CONTINUE_SCAN - continue scanning from current position
1087 * EOB_ACT_END_OF_FILE - end of file
1089 static int yy_get_next_buffer (void)
1091 register char *dest = YY_CURRENT_BUFFER_LVALUE->yy_ch_buf;
1092 register char *source = (yytext_ptr);
1093 register int number_to_move, i;
1096 if ( (yy_c_buf_p) > &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[(yy_n_chars) + 1] )
1098 "fatal flex scanner internal error--end of buffer missed" );
1100 if ( YY_CURRENT_BUFFER_LVALUE->yy_fill_buffer == 0 )
1101 { /* Don't try to fill the buffer, so this is an EOF. */
1102 if ( (yy_c_buf_p) - (yytext_ptr) - YY_MORE_ADJ == 1 )
1104 /* We matched a single character, the EOB, so
1105 * treat this as a final EOF.
1107 return EOB_ACT_END_OF_FILE;
1112 /* We matched some text prior to the EOB, first
1115 return EOB_ACT_LAST_MATCH;
1119 /* Try to read more data. */
1121 /* First move last chars to start of buffer. */
1122 number_to_move = (int) ((yy_c_buf_p) - (yytext_ptr)) - 1;
1124 for ( i = 0; i < number_to_move; ++i )
1125 *(dest++) = *(source++);
1127 if ( YY_CURRENT_BUFFER_LVALUE->yy_buffer_status == YY_BUFFER_EOF_PENDING )
1128 /* don't do the read, it's not guaranteed to return an EOF,
1131 YY_CURRENT_BUFFER_LVALUE->yy_n_chars = (yy_n_chars) = 0;
1136 YY_CURRENT_BUFFER_LVALUE->yy_buf_size - number_to_move - 1;
1138 while ( num_to_read <= 0 )
1139 { /* Not enough room in the buffer - grow it. */
1141 /* just a shorter name for the current buffer */
1142 YY_BUFFER_STATE b = YY_CURRENT_BUFFER;
1144 int yy_c_buf_p_offset =
1145 (int) ((yy_c_buf_p) - b->yy_ch_buf);
1147 if ( b->yy_is_our_buffer )
1149 int new_size = b->yy_buf_size * 2;
1151 if ( new_size <= 0 )
1152 b->yy_buf_size += b->yy_buf_size / 8;
1154 b->yy_buf_size *= 2;
1156 b->yy_ch_buf = (char *)
1157 /* Include room in for 2 EOB chars. */
1158 gras_ddt_parse_realloc((void *) b->yy_ch_buf,b->yy_buf_size + 2 );
1161 /* Can't grow it, we don't own it. */
1164 if ( ! b->yy_ch_buf )
1166 "fatal error - scanner input buffer overflow" );
1168 (yy_c_buf_p) = &b->yy_ch_buf[yy_c_buf_p_offset];
1170 num_to_read = YY_CURRENT_BUFFER_LVALUE->yy_buf_size -
1175 if ( num_to_read > YY_READ_BUF_SIZE )
1176 num_to_read = YY_READ_BUF_SIZE;
1178 /* Read in more data. */
1179 YY_INPUT( (&YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[number_to_move]),
1180 (yy_n_chars), num_to_read );
1182 YY_CURRENT_BUFFER_LVALUE->yy_n_chars = (yy_n_chars);
1185 if ( (yy_n_chars) == 0 )
1187 if ( number_to_move == YY_MORE_ADJ )
1189 ret_val = EOB_ACT_END_OF_FILE;
1190 gras_ddt_parse_restart(gras_ddt_parse_in );
1195 ret_val = EOB_ACT_LAST_MATCH;
1196 YY_CURRENT_BUFFER_LVALUE->yy_buffer_status =
1197 YY_BUFFER_EOF_PENDING;
1202 ret_val = EOB_ACT_CONTINUE_SCAN;
1204 (yy_n_chars) += number_to_move;
1205 YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[(yy_n_chars)] = YY_END_OF_BUFFER_CHAR;
1206 YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[(yy_n_chars) + 1] = YY_END_OF_BUFFER_CHAR;
1208 (yytext_ptr) = &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[0];
1213 /* yy_get_previous_state - get the state just before the EOB char was reached */
1215 static yy_state_type yy_get_previous_state (void)
1217 register yy_state_type yy_current_state;
1218 register char *yy_cp;
1220 yy_current_state = (yy_start);
1222 for ( yy_cp = (yytext_ptr) + YY_MORE_ADJ; yy_cp < (yy_c_buf_p); ++yy_cp )
1224 register YY_CHAR yy_c = (*yy_cp ? yy_ec[YY_SC_TO_UI(*yy_cp)] : 1);
1225 if ( yy_accept[yy_current_state] )
1227 (yy_last_accepting_state) = yy_current_state;
1228 (yy_last_accepting_cpos) = yy_cp;
1230 while ( yy_chk[yy_base[yy_current_state] + yy_c] != yy_current_state )
1232 yy_current_state = (int) yy_def[yy_current_state];
1233 if ( yy_current_state >= 61 )
1234 yy_c = yy_meta[(unsigned int) yy_c];
1236 yy_current_state = yy_nxt[yy_base[yy_current_state] + (unsigned int) yy_c];
1239 return yy_current_state;
1242 /* yy_try_NUL_trans - try to make a transition on the NUL character
1245 * next_state = yy_try_NUL_trans( current_state );
1247 static yy_state_type yy_try_NUL_trans (yy_state_type yy_current_state )
1249 register int yy_is_jam;
1250 register char *yy_cp = (yy_c_buf_p);
1252 register YY_CHAR yy_c = 1;
1253 if ( yy_accept[yy_current_state] )
1255 (yy_last_accepting_state) = yy_current_state;
1256 (yy_last_accepting_cpos) = yy_cp;
1258 while ( yy_chk[yy_base[yy_current_state] + yy_c] != yy_current_state )
1260 yy_current_state = (int) yy_def[yy_current_state];
1261 if ( yy_current_state >= 61 )
1262 yy_c = yy_meta[(unsigned int) yy_c];
1264 yy_current_state = yy_nxt[yy_base[yy_current_state] + (unsigned int) yy_c];
1265 yy_is_jam = (yy_current_state == 60);
1267 return yy_is_jam ? 0 : yy_current_state;
1270 static void yyunput (int c, register char * yy_bp )
1272 register char *yy_cp;
1274 yy_cp = (yy_c_buf_p);
1276 /* undo effects of setting up gras_ddt_parse_text */
1277 *yy_cp = (yy_hold_char);
1279 if ( yy_cp < YY_CURRENT_BUFFER_LVALUE->yy_ch_buf + 2 )
1280 { /* need to shift things up to make room */
1281 /* +2 for EOB chars. */
1282 register int number_to_move = (yy_n_chars) + 2;
1283 register char *dest = &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[
1284 YY_CURRENT_BUFFER_LVALUE->yy_buf_size + 2];
1285 register char *source =
1286 &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[number_to_move];
1288 while ( source > YY_CURRENT_BUFFER_LVALUE->yy_ch_buf )
1289 *--dest = *--source;
1291 yy_cp += (int) (dest - source);
1292 yy_bp += (int) (dest - source);
1293 YY_CURRENT_BUFFER_LVALUE->yy_n_chars =
1294 (yy_n_chars) = YY_CURRENT_BUFFER_LVALUE->yy_buf_size;
1296 if ( yy_cp < YY_CURRENT_BUFFER_LVALUE->yy_ch_buf + 2 )
1297 YY_FATAL_ERROR( "flex scanner push-back overflow" );
1300 *--yy_cp = (char) c;
1302 (yytext_ptr) = yy_bp;
1303 (yy_hold_char) = *yy_cp;
1304 (yy_c_buf_p) = yy_cp;
1309 static int yyinput (void)
1311 static int input (void)
1317 *(yy_c_buf_p) = (yy_hold_char);
1319 if ( *(yy_c_buf_p) == YY_END_OF_BUFFER_CHAR )
1321 /* yy_c_buf_p now points to the character we want to return.
1322 * If this occurs *before* the EOB characters, then it's a
1323 * valid NUL; if not, then we've hit the end of the buffer.
1325 if ( (yy_c_buf_p) < &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[(yy_n_chars)] )
1326 /* This was really a NUL. */
1327 *(yy_c_buf_p) = '\0';
1330 { /* need more input */
1331 int offset = (yy_c_buf_p) - (yytext_ptr);
1334 switch ( yy_get_next_buffer( ) )
1336 case EOB_ACT_LAST_MATCH:
1337 /* This happens because yy_g_n_b()
1338 * sees that we've accumulated a
1339 * token and flags that we need to
1340 * try matching the token before
1341 * proceeding. But for input(),
1342 * there's no matching to consider.
1343 * So convert the EOB_ACT_LAST_MATCH
1344 * to EOB_ACT_END_OF_FILE.
1347 /* Reset buffer status. */
1348 gras_ddt_parse_restart(gras_ddt_parse_in );
1352 case EOB_ACT_END_OF_FILE:
1354 if ( gras_ddt_parse_wrap( ) )
1357 if ( ! (yy_did_buffer_switch_on_eof) )
1366 case EOB_ACT_CONTINUE_SCAN:
1367 (yy_c_buf_p) = (yytext_ptr) + offset;
1373 c = *(unsigned char *) (yy_c_buf_p); /* cast for 8-bit char's */
1374 *(yy_c_buf_p) = '\0'; /* preserve gras_ddt_parse_text */
1375 (yy_hold_char) = *++(yy_c_buf_p);
1379 #endif /* ifndef YY_NO_INPUT */
1381 /** Immediately switch to a different input stream.
1382 * @param input_file A readable stream.
1384 * @note This function does not reset the start condition to @c INITIAL .
1386 void gras_ddt_parse_restart (FILE * input_file )
1389 if ( ! YY_CURRENT_BUFFER ){
1390 gras_ddt_parse_ensure_buffer_stack ();
1391 YY_CURRENT_BUFFER_LVALUE =
1392 gras_ddt_parse__create_buffer(gras_ddt_parse_in,YY_BUF_SIZE );
1395 gras_ddt_parse__init_buffer(YY_CURRENT_BUFFER,input_file );
1396 gras_ddt_parse__load_buffer_state( );
1399 /** Switch to a different input buffer.
1400 * @param new_buffer The new input buffer.
1403 void gras_ddt_parse__switch_to_buffer (YY_BUFFER_STATE new_buffer )
1406 /* TODO. We should be able to replace this entire function body
1408 * gras_ddt_parse_pop_buffer_state();
1409 * gras_ddt_parse_push_buffer_state(new_buffer);
1411 gras_ddt_parse_ensure_buffer_stack ();
1412 if ( YY_CURRENT_BUFFER == new_buffer )
1415 if ( YY_CURRENT_BUFFER )
1417 /* Flush out information for old buffer. */
1418 *(yy_c_buf_p) = (yy_hold_char);
1419 YY_CURRENT_BUFFER_LVALUE->yy_buf_pos = (yy_c_buf_p);
1420 YY_CURRENT_BUFFER_LVALUE->yy_n_chars = (yy_n_chars);
1423 YY_CURRENT_BUFFER_LVALUE = new_buffer;
1424 gras_ddt_parse__load_buffer_state( );
1426 /* We don't actually know whether we did this switch during
1427 * EOF (gras_ddt_parse_wrap()) processing, but the only time this flag
1428 * is looked at is after gras_ddt_parse_wrap() is called, so it's safe
1429 * to go ahead and always set it.
1431 (yy_did_buffer_switch_on_eof) = 1;
1434 static void gras_ddt_parse__load_buffer_state (void)
1436 (yy_n_chars) = YY_CURRENT_BUFFER_LVALUE->yy_n_chars;
1437 (yytext_ptr) = (yy_c_buf_p) = YY_CURRENT_BUFFER_LVALUE->yy_buf_pos;
1438 gras_ddt_parse_in = YY_CURRENT_BUFFER_LVALUE->yy_input_file;
1439 (yy_hold_char) = *(yy_c_buf_p);
1442 /** Allocate and initialize an input buffer state.
1443 * @param file A readable stream.
1444 * @param size The character buffer size in bytes. When in doubt, use @c YY_BUF_SIZE.
1446 * @return the allocated buffer state.
1448 YY_BUFFER_STATE gras_ddt_parse__create_buffer (FILE * file, int size )
1452 b = (YY_BUFFER_STATE) gras_ddt_parse_alloc(sizeof( struct yy_buffer_state ) );
1454 YY_FATAL_ERROR( "out of dynamic memory in gras_ddt_parse__create_buffer()" );
1456 b->yy_buf_size = size;
1458 /* yy_ch_buf has to be 2 characters longer than the size given because
1459 * we need to put in 2 end-of-buffer characters.
1461 b->yy_ch_buf = (char *) gras_ddt_parse_alloc(b->yy_buf_size + 2 );
1462 if ( ! b->yy_ch_buf )
1463 YY_FATAL_ERROR( "out of dynamic memory in gras_ddt_parse__create_buffer()" );
1465 b->yy_is_our_buffer = 1;
1467 gras_ddt_parse__init_buffer(b,file );
1472 /** Destroy the buffer.
1473 * @param b a buffer created with gras_ddt_parse__create_buffer()
1476 void gras_ddt_parse__delete_buffer (YY_BUFFER_STATE b )
1482 if ( b == YY_CURRENT_BUFFER ) /* Not sure if we should pop here. */
1483 YY_CURRENT_BUFFER_LVALUE = (YY_BUFFER_STATE) 0;
1485 if ( b->yy_is_our_buffer )
1486 gras_ddt_parse_free((void *) b->yy_ch_buf );
1488 gras_ddt_parse_free((void *) b );
1493 extern int isatty (int );
1495 #endif /* __cplusplus */
1497 /* Initializes or reinitializes a buffer.
1498 * This function is sometimes called more than once on the same buffer,
1499 * such as during a gras_ddt_parse_restart() or at EOF.
1501 static void gras_ddt_parse__init_buffer (YY_BUFFER_STATE b, FILE * file )
1506 gras_ddt_parse__flush_buffer(b );
1508 b->yy_input_file = file;
1509 b->yy_fill_buffer = 1;
1511 /* If b is the current buffer, then gras_ddt_parse__init_buffer was _probably_
1512 * called from gras_ddt_parse_restart() or through yy_get_next_buffer.
1513 * In that case, we don't want to reset the lineno or column.
1515 if (b != YY_CURRENT_BUFFER){
1516 b->yy_bs_lineno = 1;
1517 b->yy_bs_column = 0;
1520 b->yy_is_interactive = file ? (isatty( fileno(file) ) > 0) : 0;
1525 /** Discard all buffered characters. On the next scan, YY_INPUT will be called.
1526 * @param b the buffer state to be flushed, usually @c YY_CURRENT_BUFFER.
1529 void gras_ddt_parse__flush_buffer (YY_BUFFER_STATE b )
1536 /* We always need two end-of-buffer characters. The first causes
1537 * a transition to the end-of-buffer state. The second causes
1538 * a jam in that state.
1540 b->yy_ch_buf[0] = YY_END_OF_BUFFER_CHAR;
1541 b->yy_ch_buf[1] = YY_END_OF_BUFFER_CHAR;
1543 b->yy_buf_pos = &b->yy_ch_buf[0];
1546 b->yy_buffer_status = YY_BUFFER_NEW;
1548 if ( b == YY_CURRENT_BUFFER )
1549 gras_ddt_parse__load_buffer_state( );
1552 /** Pushes the new state onto the stack. The new state becomes
1553 * the current state. This function will allocate the stack
1555 * @param new_buffer The new state.
1558 void gras_ddt_parse_push_buffer_state (YY_BUFFER_STATE new_buffer )
1560 if (new_buffer == NULL)
1563 gras_ddt_parse_ensure_buffer_stack();
1565 /* This block is copied from gras_ddt_parse__switch_to_buffer. */
1566 if ( YY_CURRENT_BUFFER )
1568 /* Flush out information for old buffer. */
1569 *(yy_c_buf_p) = (yy_hold_char);
1570 YY_CURRENT_BUFFER_LVALUE->yy_buf_pos = (yy_c_buf_p);
1571 YY_CURRENT_BUFFER_LVALUE->yy_n_chars = (yy_n_chars);
1574 /* Only push if top exists. Otherwise, replace top. */
1575 if (YY_CURRENT_BUFFER)
1576 (yy_buffer_stack_top)++;
1577 YY_CURRENT_BUFFER_LVALUE = new_buffer;
1579 /* copied from gras_ddt_parse__switch_to_buffer. */
1580 gras_ddt_parse__load_buffer_state( );
1581 (yy_did_buffer_switch_on_eof) = 1;
1584 /** Removes and deletes the top of the stack, if present.
1585 * The next element becomes the new top.
1588 void gras_ddt_parse_pop_buffer_state (void)
1590 if (!YY_CURRENT_BUFFER)
1593 gras_ddt_parse__delete_buffer(YY_CURRENT_BUFFER );
1594 YY_CURRENT_BUFFER_LVALUE = NULL;
1595 if ((yy_buffer_stack_top) > 0)
1596 --(yy_buffer_stack_top);
1598 if (YY_CURRENT_BUFFER) {
1599 gras_ddt_parse__load_buffer_state( );
1600 (yy_did_buffer_switch_on_eof) = 1;
1604 /* Allocates the stack if it does not exist.
1605 * Guarantees space for at least one push.
1607 static void gras_ddt_parse_ensure_buffer_stack (void)
1611 if (!(yy_buffer_stack)) {
1613 /* First allocation is just for 2 elements, since we don't know if this
1614 * scanner will even need a stack. We use 2 instead of 1 to avoid an
1615 * immediate realloc on the next call.
1618 (yy_buffer_stack) = (struct yy_buffer_state**)gras_ddt_parse_alloc
1619 (num_to_alloc * sizeof(struct yy_buffer_state*)
1622 memset((yy_buffer_stack), 0, num_to_alloc * sizeof(struct yy_buffer_state*));
1624 (yy_buffer_stack_max) = num_to_alloc;
1625 (yy_buffer_stack_top) = 0;
1629 if ((yy_buffer_stack_top) >= ((yy_buffer_stack_max)) - 1){
1631 /* Increase the buffer to prepare for a possible push. */
1632 int grow_size = 8 /* arbitrary grow size */;
1634 num_to_alloc = (yy_buffer_stack_max) + grow_size;
1635 (yy_buffer_stack) = (struct yy_buffer_state**)gras_ddt_parse_realloc
1637 num_to_alloc * sizeof(struct yy_buffer_state*)
1640 /* zero only the new slots.*/
1641 memset((yy_buffer_stack) + (yy_buffer_stack_max), 0, grow_size * sizeof(struct yy_buffer_state*));
1642 (yy_buffer_stack_max) = num_to_alloc;
1646 /** Setup the input buffer state to scan directly from a user-specified character buffer.
1647 * @param base the character buffer
1648 * @param size the size in bytes of the character buffer
1650 * @return the newly allocated buffer state object.
1652 YY_BUFFER_STATE gras_ddt_parse__scan_buffer (char * base, yy_size_t size )
1657 base[size-2] != YY_END_OF_BUFFER_CHAR ||
1658 base[size-1] != YY_END_OF_BUFFER_CHAR )
1659 /* They forgot to leave room for the EOB's. */
1662 b = (YY_BUFFER_STATE) gras_ddt_parse_alloc(sizeof( struct yy_buffer_state ) );
1664 YY_FATAL_ERROR( "out of dynamic memory in gras_ddt_parse__scan_buffer()" );
1666 b->yy_buf_size = size - 2; /* "- 2" to take care of EOB's */
1667 b->yy_buf_pos = b->yy_ch_buf = base;
1668 b->yy_is_our_buffer = 0;
1669 b->yy_input_file = 0;
1670 b->yy_n_chars = b->yy_buf_size;
1671 b->yy_is_interactive = 0;
1673 b->yy_fill_buffer = 0;
1674 b->yy_buffer_status = YY_BUFFER_NEW;
1676 gras_ddt_parse__switch_to_buffer(b );
1681 /** Setup the input buffer state to scan a string. The next call to gras_ddt_parse_lex() will
1682 * scan from a @e copy of @a str.
1683 * @param str a NUL-terminated string to scan
1685 * @return the newly allocated buffer state object.
1686 * @note If you want to scan bytes that may contain NUL values, then use
1687 * gras_ddt_parse__scan_bytes() instead.
1689 YY_BUFFER_STATE gras_ddt_parse__scan_string (yyconst char * yy_str )
1692 return gras_ddt_parse__scan_bytes(yy_str,strlen(yy_str) );
1695 /** Setup the input buffer state to scan the given bytes. The next call to gras_ddt_parse_lex() will
1696 * scan from a @e copy of @a bytes.
1697 * @param bytes the byte buffer to scan
1698 * @param len the number of bytes in the buffer pointed to by @a bytes.
1700 * @return the newly allocated buffer state object.
1702 YY_BUFFER_STATE gras_ddt_parse__scan_bytes (yyconst char * bytes, int len )
1709 /* Get memory for full buffer, including space for trailing EOB's. */
1711 buf = (char *) gras_ddt_parse_alloc(n );
1713 YY_FATAL_ERROR( "out of dynamic memory in gras_ddt_parse__scan_bytes()" );
1715 for ( i = 0; i < len; ++i )
1718 buf[len] = buf[len+1] = YY_END_OF_BUFFER_CHAR;
1720 b = gras_ddt_parse__scan_buffer(buf,n );
1722 YY_FATAL_ERROR( "bad buffer in gras_ddt_parse__scan_bytes()" );
1724 /* It's okay to grow etc. this buffer, and we should throw it
1725 * away when we're done.
1727 b->yy_is_our_buffer = 1;
1732 #ifndef YY_EXIT_FAILURE
1733 #define YY_EXIT_FAILURE 2
1736 static void yy_fatal_error (yyconst char* msg )
1738 (void) fprintf( stderr, "%s\n", msg );
1739 exit( YY_EXIT_FAILURE );
1742 /* Redefine yyless() so it works in section 3 code. */
1748 /* Undo effects of setting up gras_ddt_parse_text. */ \
1749 int yyless_macro_arg = (n); \
1750 YY_LESS_LINENO(yyless_macro_arg);\
1751 gras_ddt_parse_text[gras_ddt_parse_leng] = (yy_hold_char); \
1752 (yy_c_buf_p) = gras_ddt_parse_text + yyless_macro_arg; \
1753 (yy_hold_char) = *(yy_c_buf_p); \
1754 *(yy_c_buf_p) = '\0'; \
1755 gras_ddt_parse_leng = yyless_macro_arg; \
1759 /* Accessor methods (get/set functions) to struct members. */
1761 /** Get the current line number.
1764 int gras_ddt_parse_get_lineno (void)
1767 return gras_ddt_parse_lineno;
1770 /** Get the input stream.
1773 FILE *gras_ddt_parse_get_in (void)
1775 return gras_ddt_parse_in;
1778 /** Get the output stream.
1781 FILE *gras_ddt_parse_get_out (void)
1783 return gras_ddt_parse_out;
1786 /** Get the length of the current token.
1789 int gras_ddt_parse_get_leng (void)
1791 return gras_ddt_parse_leng;
1794 /** Get the current token.
1798 char *gras_ddt_parse_get_text (void)
1800 return gras_ddt_parse_text;
1803 /** Set the current line number.
1804 * @param line_number
1807 void gras_ddt_parse_set_lineno (int line_number )
1810 gras_ddt_parse_lineno = line_number;
1813 /** Set the input stream. This does not discard the current
1815 * @param in_str A readable stream.
1817 * @see gras_ddt_parse__switch_to_buffer
1819 void gras_ddt_parse_set_in (FILE * in_str )
1821 gras_ddt_parse_in = in_str ;
1824 void gras_ddt_parse_set_out (FILE * out_str )
1826 gras_ddt_parse_out = out_str ;
1829 int gras_ddt_parse_get_debug (void)
1831 return gras_ddt_parse__flex_debug;
1834 void gras_ddt_parse_set_debug (int bdebug )
1836 gras_ddt_parse__flex_debug = bdebug ;
1839 /* gras_ddt_parse_lex_destroy is for both reentrant and non-reentrant scanners. */
1840 int gras_ddt_parse_lex_destroy (void)
1843 /* Pop the buffer stack, destroying each element. */
1844 while(YY_CURRENT_BUFFER){
1845 gras_ddt_parse__delete_buffer(YY_CURRENT_BUFFER );
1846 YY_CURRENT_BUFFER_LVALUE = NULL;
1847 gras_ddt_parse_pop_buffer_state();
1850 /* Destroy the stack itself. */
1851 gras_ddt_parse_free((yy_buffer_stack) );
1852 (yy_buffer_stack) = NULL;
1858 * Internal utility routines.
1862 static void yy_flex_strncpy (char* s1, yyconst char * s2, int n )
1865 for ( i = 0; i < n; ++i )
1870 #ifdef YY_NEED_STRLEN
1871 static int yy_flex_strlen (yyconst char * s )
1874 for ( n = 0; s[n]; ++n )
1881 void *gras_ddt_parse_alloc (yy_size_t size )
1883 return (void *) malloc( size );
1886 void *gras_ddt_parse_realloc (void * ptr, yy_size_t size )
1888 /* The cast to (char *) in the following accommodates both
1889 * implementations that use char* generic pointers, and those
1890 * that use void* generic pointers. It works with the latter
1891 * because both ANSI C and C++ allow castless assignment from
1892 * any pointer type to void*, and deal with argument conversions
1893 * as though doing an assignment.
1895 return (void *) realloc( (char *) ptr, size );
1898 void gras_ddt_parse_free (void * ptr )
1900 free( (char *) ptr ); /* see gras_ddt_parse_realloc() for (char *) cast */
1903 #define YYTABLES_NAME "yytables"
1906 #undef YY_FLUSH_BUFFER
1908 #undef yy_new_buffer
1909 #undef yy_set_interactive
1911 #undef YY_DO_BEFORE_ACTION
1913 #ifdef YY_DECL_IS_OURS
1914 #undef YY_DECL_IS_OURS
1918 /* {space}+ { return(TOKEN_SPACE);} */
1920 void gras_ddt_parse_dump(void) {
1921 switch(gras_ddt_parse_tok_num) {
1922 case GRAS_DDT_PARSE_TOKEN_LA : {printf("TOKEN_LA ");break;}
1923 case GRAS_DDT_PARSE_TOKEN_RA : {printf("TOKEN_RA ");break;}
1924 case GRAS_DDT_PARSE_TOKEN_WORD : {printf("TOKEN_WORD ");break;}
1925 /* case GRAS_DDT_PARSE_TOKEN_SPACE : {printf("TOKEN_SPACE ");break;}*/
1926 /* case GRAS_DDT_PARSE_TOKEN_COMMENT : {printf("TOKEN_COMMENT ");break;}*/
1927 case GRAS_DDT_PARSE_TOKEN_NEWLINE : {printf("TOKEN_NEWLINE\n");return;}
1928 case GRAS_DDT_PARSE_TOKEN_EMPTY : {printf("TOKEN_EMPTY\n");return;}
1929 default : {printf("Unknown token %d\n", gras_ddt_parse_tok_num);return;}
1931 printf("-->%s<-- [line %d, pos %d]\n",gras_ddt_parse_text,gras_ddt_parse_line_pos,gras_ddt_parse_char_pos);
1935 int gras_ddt_parse_lex_n_dump(void) {
1936 gras_ddt_parse_tok_num = gras_ddt_parse_lex();
1937 /* gras_ddt_parse_char_pos += strlen(gras_ddt_parse_text);*/
1938 return(gras_ddt_parse_tok_num);
1941 void gras_ddt_parse_pointer_init(const char *file) {
1942 gras_ddt_file_to_parse = fopen(file,"r");
1943 gras_ddt_input_buffer = gras_ddt_parse__create_buffer(gras_ddt_file_to_parse,10 );
1944 gras_ddt_parse__switch_to_buffer(gras_ddt_input_buffer);
1946 gras_ddt_parse_line_pos = 1;
1947 gras_ddt_parse_char_pos = 0;
1948 gras_ddt_parse_col_pos = 0;
1949 gras_ddt_parse_tok_num = 0;
1952 void gras_ddt_parse_pointer_close(void) {
1953 gras_ddt_parse__delete_buffer(gras_ddt_input_buffer);
1954 fclose(gras_ddt_file_to_parse);
1956 gras_ddt_parse_line_pos = 1;
1957 gras_ddt_parse_char_pos = 0;
1958 gras_ddt_parse_tok_num = 0;
1961 void gras_ddt_parse_pointer_string_init(const char *string_to_parse) {
1962 gras_ddt_input_buffer = gras_ddt_parse__scan_string (string_to_parse);
1963 definition = string_to_parse;
1964 gras_ddt_parse__switch_to_buffer(gras_ddt_input_buffer);
1966 gras_ddt_parse_line_pos = 1;
1967 gras_ddt_parse_char_pos = 0;
1968 gras_ddt_parse_tok_num = 0;
1971 void gras_ddt_parse_pointer_string_close(void) {
1972 gras_ddt_parse__delete_buffer(gras_ddt_input_buffer);
1974 gras_ddt_parse_line_pos = 1;
1975 gras_ddt_parse_char_pos = 0;
1976 gras_ddt_parse_tok_num = 0;
1979 yyunput('\0',NULL); /* fake a use of this function to calm gcc down */
1982 /* Local variables:*/