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 33
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 __STDC_VERSION__ >= 199901L
35 /* C99 says to define __STDC_LIMIT_MACROS before including stdint.h,
36 * if you want the limit (max/min) macros for int types.
38 #ifndef __STDC_LIMIT_MACROS
39 #define __STDC_LIMIT_MACROS 1
43 typedef int8_t flex_int8_t;
44 typedef uint8_t flex_uint8_t;
45 typedef int16_t flex_int16_t;
46 typedef uint16_t flex_uint16_t;
47 typedef int32_t flex_int32_t;
48 typedef uint32_t flex_uint32_t;
50 typedef signed char flex_int8_t;
51 typedef short int flex_int16_t;
52 typedef int flex_int32_t;
53 typedef unsigned char flex_uint8_t;
54 typedef unsigned short int flex_uint16_t;
55 typedef unsigned int flex_uint32_t;
58 /* Limits of integral types. */
60 #define INT8_MIN (-128)
63 #define INT16_MIN (-32767-1)
66 #define INT32_MIN (-2147483647-1)
69 #define INT8_MAX (127)
72 #define INT16_MAX (32767)
75 #define INT32_MAX (2147483647)
78 #define UINT8_MAX (255U)
81 #define UINT16_MAX (65535U)
84 #define UINT32_MAX (4294967295U)
87 #endif /* ! FLEXINT_H */
91 /* The "const" storage-class-modifier is valid. */
94 #else /* ! __cplusplus */
100 #endif /* __STDC__ */
101 #endif /* ! __cplusplus */
104 #define yyconst const
109 /* Returned upon end-of-file. */
112 /* Promotes a possibly negative, possibly signed char to an unsigned
113 * integer for use as an array index. If the signed char is negative,
114 * we want to instead treat it as an 8-bit unsigned char, hence the
117 #define YY_SC_TO_UI(c) ((unsigned int) (unsigned char) c)
119 /* Enter a start condition. This macro really ought to take a parameter,
120 * but we do it the disgusting crufty way forced on us by the ()-less
121 * definition of BEGIN.
123 #define BEGIN (yy_start) = 1 + 2 *
125 /* Translate the current start state into a value that can be later handed
126 * to BEGIN to return to the state. The YYSTATE alias is for lex
129 #define YY_START (((yy_start) - 1) / 2)
130 #define YYSTATE YY_START
132 /* Action number for EOF rule of a given start state. */
133 #define YY_STATE_EOF(state) (YY_END_OF_BUFFER + state + 1)
135 /* Special action meaning "start processing a new file". */
136 #define YY_NEW_FILE gras_ddt_parse_restart(gras_ddt_parse_in )
138 #define YY_END_OF_BUFFER_CHAR 0
140 /* Size of default input buffer. */
142 #define YY_BUF_SIZE 16384
145 /* The state buf must be large enough to hold one state per character in the main buffer.
147 #define YY_STATE_BUF_SIZE ((YY_BUF_SIZE + 2) * sizeof(yy_state_type))
149 #ifndef YY_TYPEDEF_YY_BUFFER_STATE
150 #define YY_TYPEDEF_YY_BUFFER_STATE
151 typedef struct yy_buffer_state *YY_BUFFER_STATE;
154 extern int gras_ddt_parse_leng;
156 extern FILE *gras_ddt_parse_in, *gras_ddt_parse_out;
158 #define EOB_ACT_CONTINUE_SCAN 0
159 #define EOB_ACT_END_OF_FILE 1
160 #define EOB_ACT_LAST_MATCH 2
162 #define YY_LESS_LINENO(n)
164 /* Return all but the first "n" matched characters back to the input stream. */
168 /* Undo effects of setting up gras_ddt_parse_text. */ \
169 int yyless_macro_arg = (n); \
170 YY_LESS_LINENO(yyless_macro_arg);\
171 *yy_cp = (yy_hold_char); \
172 YY_RESTORE_YY_MORE_OFFSET \
173 (yy_c_buf_p) = yy_cp = yy_bp + yyless_macro_arg - YY_MORE_ADJ; \
174 YY_DO_BEFORE_ACTION; /* set up gras_ddt_parse_text again */ \
178 #define unput(c) yyunput( c, (yytext_ptr) )
180 /* The following is because we cannot portably get our hands on size_t
181 * (without autoconf's help, which isn't available because we want
182 * flex-generated scanners to compile on their own).
185 #ifndef YY_TYPEDEF_YY_SIZE_T
186 #define YY_TYPEDEF_YY_SIZE_T
187 typedef unsigned int yy_size_t;
190 #ifndef YY_STRUCT_YY_BUFFER_STATE
191 #define YY_STRUCT_YY_BUFFER_STATE
192 struct yy_buffer_state
196 char *yy_ch_buf; /* input buffer */
197 char *yy_buf_pos; /* current position in input buffer */
199 /* Size of input buffer in bytes, not including room for EOB
202 yy_size_t yy_buf_size;
204 /* Number of characters read into yy_ch_buf, not including EOB
209 /* Whether we "own" the buffer - i.e., we know we created it,
210 * and can realloc() it to grow it, and should free() it to
213 int yy_is_our_buffer;
215 /* Whether this is an "interactive" input source; if so, and
216 * if we're using stdio for input, then we want to use getc()
217 * instead of fread(), to make sure we stop fetching input after
220 int yy_is_interactive;
222 /* Whether we're considered to be at the beginning of a line.
223 * If so, '^' rules will be active on the next match, otherwise
228 int yy_bs_lineno; /**< The line count. */
229 int yy_bs_column; /**< The column count. */
231 /* Whether to try to fill the input buffer when we reach the
236 int yy_buffer_status;
238 #define YY_BUFFER_NEW 0
239 #define YY_BUFFER_NORMAL 1
240 /* When an EOF's been seen but there's still some text to process
241 * then we mark the buffer as YY_EOF_PENDING, to indicate that we
242 * shouldn't try reading from the input source any more. We might
243 * still have a bunch of tokens to match, though, because of
244 * possible backing-up.
246 * When we actually see the EOF, we change the status to "new"
247 * (via gras_ddt_parse_restart()), so that the user can continue scanning by
248 * just pointing gras_ddt_parse_in at a new input file.
250 #define YY_BUFFER_EOF_PENDING 2
253 #endif /* !YY_STRUCT_YY_BUFFER_STATE */
255 /* Stack of input buffers. */
256 static size_t yy_buffer_stack_top = 0; /**< index of top of stack. */
257 static size_t yy_buffer_stack_max = 0; /**< capacity of stack. */
258 static YY_BUFFER_STATE * yy_buffer_stack = 0; /**< Stack as an array. */
260 /* We provide macros for accessing buffer states in case in the
261 * future we want to put the buffer states in a more general
264 * Returns the top of the stack, or NULL.
266 #define YY_CURRENT_BUFFER ( (yy_buffer_stack) \
267 ? (yy_buffer_stack)[(yy_buffer_stack_top)] \
270 /* Same as previous macro, but useful when we know that the buffer stack is not
271 * NULL or when we need an lvalue. For internal use only.
273 #define YY_CURRENT_BUFFER_LVALUE (yy_buffer_stack)[(yy_buffer_stack_top)]
275 /* yy_hold_char holds the character lost when gras_ddt_parse_text is formed. */
276 static char yy_hold_char;
277 static int yy_n_chars; /* number of characters read into yy_ch_buf */
278 int gras_ddt_parse_leng;
280 /* Points to current character in buffer. */
281 static char *yy_c_buf_p = (char *) 0;
282 static int yy_init = 0; /* whether we need to initialize */
283 static int yy_start = 0; /* start state number */
285 /* Flag which is used to allow gras_ddt_parse_wrap()'s to do buffer switches
286 * instead of setting up a fresh gras_ddt_parse_in. A bit of a hack ...
288 static int yy_did_buffer_switch_on_eof;
290 void gras_ddt_parse_restart (FILE *input_file );
291 void gras_ddt_parse__switch_to_buffer (YY_BUFFER_STATE new_buffer );
292 YY_BUFFER_STATE gras_ddt_parse__create_buffer (FILE *file,int size );
293 void gras_ddt_parse__delete_buffer (YY_BUFFER_STATE b );
294 void gras_ddt_parse__flush_buffer (YY_BUFFER_STATE b );
295 void gras_ddt_parse_push_buffer_state (YY_BUFFER_STATE new_buffer );
296 void gras_ddt_parse_pop_buffer_state (void );
298 static void gras_ddt_parse_ensure_buffer_stack (void );
299 static void gras_ddt_parse__load_buffer_state (void );
300 static void gras_ddt_parse__init_buffer (YY_BUFFER_STATE b,FILE *file );
302 #define YY_FLUSH_BUFFER gras_ddt_parse__flush_buffer(YY_CURRENT_BUFFER )
304 YY_BUFFER_STATE gras_ddt_parse__scan_buffer (char *base,yy_size_t size );
305 YY_BUFFER_STATE gras_ddt_parse__scan_string (yyconst char *yy_str );
306 YY_BUFFER_STATE gras_ddt_parse__scan_bytes (yyconst char *bytes,int len );
308 void *gras_ddt_parse_alloc (yy_size_t );
309 void *gras_ddt_parse_realloc (void *,yy_size_t );
310 void gras_ddt_parse_free (void * );
312 #define yy_new_buffer gras_ddt_parse__create_buffer
314 #define yy_set_interactive(is_interactive) \
316 if ( ! YY_CURRENT_BUFFER ){ \
317 gras_ddt_parse_ensure_buffer_stack (); \
318 YY_CURRENT_BUFFER_LVALUE = \
319 gras_ddt_parse__create_buffer(gras_ddt_parse_in,YY_BUF_SIZE ); \
321 YY_CURRENT_BUFFER_LVALUE->yy_is_interactive = is_interactive; \
324 #define yy_set_bol(at_bol) \
326 if ( ! YY_CURRENT_BUFFER ){\
327 gras_ddt_parse_ensure_buffer_stack (); \
328 YY_CURRENT_BUFFER_LVALUE = \
329 gras_ddt_parse__create_buffer(gras_ddt_parse_in,YY_BUF_SIZE ); \
331 YY_CURRENT_BUFFER_LVALUE->yy_at_bol = at_bol; \
334 #define YY_AT_BOL() (YY_CURRENT_BUFFER_LVALUE->yy_at_bol)
336 /* Begin user sect3 */
338 #define gras_ddt_parse_wrap() 1
339 #define YY_SKIP_YYWRAP
341 typedef unsigned char YY_CHAR;
343 FILE *gras_ddt_parse_in = (FILE *) 0, *gras_ddt_parse_out = (FILE *) 0;
345 typedef int yy_state_type;
347 extern int gras_ddt_parse_lineno;
349 int gras_ddt_parse_lineno = 1;
351 extern char *gras_ddt_parse_text;
352 #define yytext_ptr gras_ddt_parse_text
354 static yy_state_type yy_get_previous_state (void );
355 static yy_state_type yy_try_NUL_trans (yy_state_type current_state );
356 static int yy_get_next_buffer (void );
357 static void yy_fatal_error (yyconst char msg[] );
359 /* Done after the current pattern has been matched and before the
360 * corresponding action - sets up gras_ddt_parse_text.
362 #define YY_DO_BEFORE_ACTION \
363 (yytext_ptr) = yy_bp; \
364 gras_ddt_parse_leng = (size_t) (yy_cp - yy_bp); \
365 (yy_hold_char) = *yy_cp; \
367 (yy_c_buf_p) = yy_cp;
369 #define YY_NUM_RULES 26
370 #define YY_END_OF_BUFFER 27
371 /* This struct is not used in this scanner,
372 but its presence is necessary. */
375 flex_int32_t yy_verify;
378 static yyconst flex_int16_t yy_accept[61] =
380 14, 14, 7, 7, 10, 10, 0, 0, 27, 25,
381 24, 19, 20, 21, 23, 14, 25, 22, 17, 18,
382 15, 16, 7, 7, 6, 7, 7, 10, 12, 11,
383 26, 26, 14, 0, 1, 7, 7, 7, 5, 7,
384 10, 11, 11, 13, 0, 0, 2, 1, 4, 0,
385 3, 0, 2, 0, 3, 0, 0, 8, 9, 0
388 static yyconst flex_int32_t yy_ec[256] =
390 1, 1, 1, 1, 1, 1, 1, 1, 2, 3,
391 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
392 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
393 1, 2, 1, 1, 1, 1, 1, 1, 1, 4,
394 5, 6, 1, 7, 8, 8, 9, 10, 10, 10,
395 10, 10, 10, 10, 10, 10, 10, 1, 11, 1,
396 1, 1, 1, 1, 8, 8, 8, 8, 8, 8,
397 8, 8, 8, 8, 8, 8, 8, 8, 8, 8,
398 8, 8, 8, 8, 8, 8, 8, 8, 8, 8,
399 12, 1, 13, 14, 8, 1, 8, 8, 8, 8,
401 8, 8, 15, 8, 8, 8, 8, 8, 8, 8,
402 8, 8, 8, 8, 8, 8, 8, 8, 8, 8,
403 8, 8, 16, 1, 17, 1, 1, 1, 1, 1,
404 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
405 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
406 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
407 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
408 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
409 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
410 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
412 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
413 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
414 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
415 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
416 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
420 static yyconst flex_int32_t yy_meta[18] =
422 1, 1, 2, 1, 1, 3, 1, 4, 1, 4,
426 static yyconst flex_int16_t yy_base[69] =
428 0, 0, 16, 30, 17, 18, 78, 77, 85, 88,
429 88, 88, 88, 88, 88, 0, 19, 88, 88, 88,
430 88, 88, 0, 24, 88, 75, 77, 0, 88, 21,
431 88, 76, 0, 22, 0, 0, 27, 75, 0, 71,
432 0, 29, 34, 88, 29, 65, 76, 0, 0, 63,
433 74, 60, 72, 56, 65, 51, 50, 88, 88, 88,
434 45, 49, 53, 55, 57, 61, 65, 69
437 static yyconst flex_int16_t yy_def[69] =
439 60, 1, 61, 61, 62, 62, 63, 63, 60, 60,
440 60, 60, 60, 60, 60, 64, 60, 60, 60, 60,
441 60, 60, 65, 65, 60, 65, 65, 66, 60, 67,
442 60, 60, 64, 60, 68, 65, 65, 65, 65, 65,
443 66, 67, 67, 60, 60, 60, 60, 68, 65, 60,
444 60, 60, 60, 60, 60, 60, 60, 60, 60, 0,
445 60, 60, 60, 60, 60, 60, 60, 60
448 static yyconst flex_int16_t yy_nxt[106] =
450 10, 10, 11, 12, 13, 14, 15, 16, 17, 16,
451 18, 19, 20, 10, 16, 21, 22, 24, 25, 29,
452 29, 26, 30, 30, 34, 37, 43, 35, 37, 44,
453 27, 24, 25, 46, 60, 26, 47, 60, 38, 43,
454 50, 38, 44, 51, 27, 23, 23, 23, 23, 28,
455 28, 28, 28, 31, 31, 31, 31, 36, 33, 36,
456 36, 41, 59, 58, 41, 42, 55, 42, 42, 48,
457 57, 48, 48, 53, 56, 55, 54, 53, 52, 49,
458 40, 45, 40, 39, 60, 32, 32, 9, 60, 60,
459 60, 60, 60, 60, 60, 60, 60, 60, 60, 60,
464 static yyconst flex_int16_t yy_chk[106] =
466 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
467 1, 1, 1, 1, 1, 1, 1, 3, 3, 5,
468 6, 3, 5, 6, 17, 24, 30, 17, 37, 30,
469 3, 4, 4, 34, 42, 4, 34, 42, 24, 43,
470 45, 37, 43, 45, 4, 61, 61, 61, 61, 62,
471 62, 62, 62, 63, 63, 63, 63, 65, 64, 65,
472 65, 66, 57, 56, 66, 67, 55, 67, 67, 68,
473 54, 68, 68, 53, 52, 51, 50, 47, 46, 40,
474 38, 32, 27, 26, 9, 8, 7, 60, 60, 60,
475 60, 60, 60, 60, 60, 60, 60, 60, 60, 60,
480 static yy_state_type yy_last_accepting_state;
481 static char *yy_last_accepting_cpos;
483 extern int gras_ddt_parse__flex_debug;
484 int gras_ddt_parse__flex_debug = 0;
486 /* The intent behind this definition is that it'll catch
487 * any uses of REJECT which flex missed.
489 #define REJECT reject_used_but_not_detected
490 #define yymore() yymore_used_but_not_detected
491 #define YY_MORE_ADJ 0
492 #define YY_RESTORE_YY_MORE_OFFSET
493 char *gras_ddt_parse_text;
495 /* DataDesc/ddt_parse -- automatic parsing of data structures */
496 /* Copyright (c) 2004 Arnaud Legrand, Martin Quinson. All rights reserved. */
497 /* This program is free software; you can redistribute it and/or modify it
498 * under the terms of the license (GNU LGPL) which comes with this package. */
499 #include "gras/DataDesc/datadesc_private.h"
500 #include "gras/DataDesc/ddt_parse.yy.h"
502 YY_BUFFER_STATE gras_ddt_input_buffer;
503 FILE *gras_ddt_file_to_parse;
505 int gras_ddt_parse_line_pos = 1;
506 int gras_ddt_parse_col_pos = 0;
507 int gras_ddt_parse_char_pos = 0;
508 int gras_ddt_parse_tok_num = 0;
509 const char *definition;
510 XBT_LOG_NEW_DEFAULT_SUBCATEGORY(gras_ddt_lexer,gras_ddt_parse,"The crude internals of the lexer used for type parsing");
511 #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)
518 #ifndef YY_NO_UNISTD_H
519 /* Special case for "unistd.h", since it is non-ANSI. We include it way
520 * down here because we want the user's section 1 to have been scanned first.
521 * The user has a chance to override it with an option.
526 #ifndef YY_EXTRA_TYPE
527 #define YY_EXTRA_TYPE void *
530 static int yy_init_globals (void );
532 /* Macros after this point can all be overridden by user definitions in
536 #ifndef YY_SKIP_YYWRAP
538 extern "C" int gras_ddt_parse_wrap (void );
540 extern int gras_ddt_parse_wrap (void );
544 static void yyunput (int c,char *buf_ptr );
547 static void yy_flex_strncpy (char *,yyconst char *,int );
550 #ifdef YY_NEED_STRLEN
551 static int yy_flex_strlen (yyconst char * );
557 static int yyinput (void );
559 static int input (void );
564 /* Amount of stuff to slurp up with each read. */
565 #ifndef YY_READ_BUF_SIZE
566 #define YY_READ_BUF_SIZE 8192
569 /* Copy whatever the last rule matched to the standard output. */
571 /* This used to be an fputs(), but since the string might contain NUL's,
572 * we now use fwrite().
574 #define ECHO (void) fwrite( gras_ddt_parse_text, gras_ddt_parse_leng, 1, gras_ddt_parse_out )
577 /* Gets input and stuffs it into "buf". number of characters read, or YY_NULL,
578 * is returned in "result".
581 #define YY_INPUT(buf,result,max_size) \
582 if ( YY_CURRENT_BUFFER_LVALUE->yy_is_interactive ) \
586 for ( n = 0; n < max_size && \
587 (c = getc( gras_ddt_parse_in )) != EOF && c != '\n'; ++n ) \
590 buf[n++] = (char) c; \
591 if ( c == EOF && ferror( gras_ddt_parse_in ) ) \
592 YY_FATAL_ERROR( "input in flex scanner failed" ); \
598 while ( (result = fread(buf, 1, max_size, gras_ddt_parse_in))==0 && ferror(gras_ddt_parse_in)) \
600 if( errno != EINTR) \
602 YY_FATAL_ERROR( "input in flex scanner failed" ); \
606 clearerr(gras_ddt_parse_in); \
613 /* No semi-colon after return; correct usage is to write "yyterminate();" -
614 * we don't want an extra ';' after the "return" because that will cause
615 * some compilers to complain about unreachable statements.
618 #define yyterminate() return YY_NULL
621 /* Number of entries by which start-condition stack grows. */
622 #ifndef YY_START_STACK_INCR
623 #define YY_START_STACK_INCR 25
626 /* Report a fatal error. */
627 #ifndef YY_FATAL_ERROR
628 #define YY_FATAL_ERROR(msg) yy_fatal_error( msg )
631 /* end tables serialization structures and prototypes */
633 /* Default declaration of generated scanner - a define so the user can
634 * easily add parameters.
637 #define YY_DECL_IS_OURS 1
639 extern int gras_ddt_parse_lex (void);
641 #define YY_DECL int gras_ddt_parse_lex (void)
642 #endif /* !YY_DECL */
644 /* Code executed at the beginning of each rule, after gras_ddt_parse_text and gras_ddt_parse_leng
647 #ifndef YY_USER_ACTION
648 #define YY_USER_ACTION
651 /* Code executed at the end of each rule. */
653 #define YY_BREAK break;
656 #define YY_RULE_SETUP \
659 /** The main scanner function which does all the work.
663 register yy_state_type yy_current_state;
664 register char *yy_cp, *yy_bp;
667 int comment_caller=0;
668 int annotate_caller=0;
679 (yy_start) = 1; /* first start state */
681 if ( ! gras_ddt_parse_in )
682 gras_ddt_parse_in = stdin;
684 if ( ! gras_ddt_parse_out )
685 gras_ddt_parse_out = stdout;
687 if ( ! YY_CURRENT_BUFFER ) {
688 gras_ddt_parse_ensure_buffer_stack ();
689 YY_CURRENT_BUFFER_LVALUE =
690 gras_ddt_parse__create_buffer(gras_ddt_parse_in,YY_BUF_SIZE );
693 gras_ddt_parse__load_buffer_state( );
696 while ( 1 ) /* loops until end-of-file is reached */
698 yy_cp = (yy_c_buf_p);
700 /* Support of gras_ddt_parse_text. */
701 *yy_cp = (yy_hold_char);
703 /* yy_bp points to the position in yy_ch_buf of the start of
708 yy_current_state = (yy_start);
712 register YY_CHAR yy_c = yy_ec[YY_SC_TO_UI(*yy_cp)];
713 if ( yy_accept[yy_current_state] )
715 (yy_last_accepting_state) = yy_current_state;
716 (yy_last_accepting_cpos) = yy_cp;
718 while ( yy_chk[yy_base[yy_current_state] + yy_c] != yy_current_state )
720 yy_current_state = (int) yy_def[yy_current_state];
721 if ( yy_current_state >= 61 )
722 yy_c = yy_meta[(unsigned int) yy_c];
724 yy_current_state = yy_nxt[yy_base[yy_current_state] + (unsigned int) yy_c];
727 while ( yy_base[yy_current_state] != 88 );
730 yy_act = yy_accept[yy_current_state];
732 { /* have to back up */
733 yy_cp = (yy_last_accepting_cpos);
734 yy_current_state = (yy_last_accepting_state);
735 yy_act = yy_accept[yy_current_state];
740 do_action: /* This label is used only to access EOF actions. */
743 { /* beginning of action switch */
744 case 0: /* must back up */
745 /* undo the effects of YY_DO_BEFORE_ACTION */
746 *yy_cp = (yy_hold_char);
747 yy_cp = (yy_last_accepting_cpos);
748 yy_current_state = (yy_last_accepting_state);
757 { /****************** ANNOTATION ************************/
758 DEBUG0("Begin annotation");
759 annotate_caller = INITIAL;
760 gras_ddt_parse_char_pos+= strlen(gras_ddt_parse_text);
761 gras_ddt_parse_col_pos+= strlen(gras_ddt_parse_text);
767 { /* trim annotation */
768 DEBUG0("Begin annotation");
769 annotate_caller = foo;
770 gras_ddt_parse_char_pos+= strlen(gras_ddt_parse_text);
771 gras_ddt_parse_col_pos+= strlen(gras_ddt_parse_text);
778 DEBUG0("End annotation");
779 gras_ddt_parse_char_pos+= strlen(gras_ddt_parse_text);
780 gras_ddt_parse_col_pos+= strlen(gras_ddt_parse_text);
781 BEGIN(annotate_caller);
787 PARSE_ERROR0("``/*g'' construct closed by a regular ``*/''");
791 /* rule 6 can match eol */
794 PARSE_ERROR0("Type annotation cannot spread over several lines");
800 gras_ddt_parse_char_pos+= strlen(gras_ddt_parse_text);
801 gras_ddt_parse_col_pos+= strlen(gras_ddt_parse_text);
802 return GRAS_DDT_PARSE_TOKEN_ANNOTATE;
807 { /****************** COMMENTS ************************/
808 /* constructs like : */
810 /* are not comments but size annotations */
811 comment_caller = INITIAL;
818 comment_caller = foo;
824 { /* eat anything that's not a '*' */
829 { /* eat up '*'s not followed by '/'s */
833 /* rule 12 can match eol */
836 ++gras_ddt_parse_line_pos;
837 gras_ddt_parse_col_pos=0;
838 gras_ddt_parse_char_pos++;
844 gras_ddt_parse_char_pos+= strlen(gras_ddt_parse_text);
845 gras_ddt_parse_col_pos+= strlen(gras_ddt_parse_text);
846 BEGIN(comment_caller);
851 { /****************** STATEMENTS ************************/
852 gras_ddt_parse_char_pos += strlen(gras_ddt_parse_text);
853 gras_ddt_parse_col_pos += strlen(gras_ddt_parse_text);
855 return(GRAS_DDT_PARSE_TOKEN_WORD);
861 gras_ddt_parse_char_pos++;
862 gras_ddt_parse_col_pos++;
864 return(GRAS_DDT_PARSE_TOKEN_LA);
870 gras_ddt_parse_char_pos++;
871 gras_ddt_parse_col_pos++;
873 return(GRAS_DDT_PARSE_TOKEN_RA);
879 gras_ddt_parse_char_pos++;
880 gras_ddt_parse_col_pos++;
882 return(GRAS_DDT_PARSE_TOKEN_LB);
888 gras_ddt_parse_char_pos++;
889 gras_ddt_parse_col_pos++;
891 return(GRAS_DDT_PARSE_TOKEN_RB);
897 gras_ddt_parse_char_pos++;
898 gras_ddt_parse_col_pos++;
900 return(GRAS_DDT_PARSE_TOKEN_LP);
906 gras_ddt_parse_char_pos++;
907 gras_ddt_parse_col_pos++;
909 return(GRAS_DDT_PARSE_TOKEN_RP);
915 gras_ddt_parse_char_pos++;
916 gras_ddt_parse_col_pos++;
918 return(GRAS_DDT_PARSE_TOKEN_STAR);
924 gras_ddt_parse_char_pos++;
925 gras_ddt_parse_col_pos++;
927 return(GRAS_DDT_PARSE_TOKEN_SEMI_COLON);
933 gras_ddt_parse_char_pos++;
934 gras_ddt_parse_col_pos++;
936 return(GRAS_DDT_PARSE_TOKEN_COLON);
940 /* rule 24 can match eol */
943 gras_ddt_parse_line_pos++;
944 gras_ddt_parse_char_pos++;
945 gras_ddt_parse_col_pos=0;
952 gras_ddt_parse_char_pos++;
953 gras_ddt_parse_col_pos++;
961 case YY_STATE_EOF(INITIAL):
962 case YY_STATE_EOF(annotate):
963 case YY_STATE_EOF(comment):
964 case YY_STATE_EOF(foo):
967 case YY_END_OF_BUFFER:
969 /* Amount of text matched not including the EOB char. */
970 int yy_amount_of_matched_text = (int) (yy_cp - (yytext_ptr)) - 1;
972 /* Undo the effects of YY_DO_BEFORE_ACTION. */
973 *yy_cp = (yy_hold_char);
974 YY_RESTORE_YY_MORE_OFFSET
976 if ( YY_CURRENT_BUFFER_LVALUE->yy_buffer_status == YY_BUFFER_NEW )
978 /* We're scanning a new file or input source. It's
979 * possible that this happened because the user
980 * just pointed gras_ddt_parse_in at a new source and called
981 * gras_ddt_parse_lex(). If so, then we have to assure
982 * consistency between YY_CURRENT_BUFFER and our
983 * globals. Here is the right place to do so, because
984 * this is the first action (other than possibly a
985 * back-up) that will match for the new input source.
987 (yy_n_chars) = YY_CURRENT_BUFFER_LVALUE->yy_n_chars;
988 YY_CURRENT_BUFFER_LVALUE->yy_input_file = gras_ddt_parse_in;
989 YY_CURRENT_BUFFER_LVALUE->yy_buffer_status = YY_BUFFER_NORMAL;
992 /* Note that here we test for yy_c_buf_p "<=" to the position
993 * of the first EOB in the buffer, since yy_c_buf_p will
994 * already have been incremented past the NUL character
995 * (since all states make transitions on EOB to the
996 * end-of-buffer state). Contrast this with the test
999 if ( (yy_c_buf_p) <= &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[(yy_n_chars)] )
1000 { /* This was really a NUL. */
1001 yy_state_type yy_next_state;
1003 (yy_c_buf_p) = (yytext_ptr) + yy_amount_of_matched_text;
1005 yy_current_state = yy_get_previous_state( );
1007 /* Okay, we're now positioned to make the NUL
1008 * transition. We couldn't have
1009 * yy_get_previous_state() go ahead and do it
1010 * for us because it doesn't know how to deal
1011 * with the possibility of jamming (and we don't
1012 * want to build jamming into it because then it
1013 * will run more slowly).
1016 yy_next_state = yy_try_NUL_trans( yy_current_state );
1018 yy_bp = (yytext_ptr) + YY_MORE_ADJ;
1020 if ( yy_next_state )
1022 /* Consume the NUL. */
1023 yy_cp = ++(yy_c_buf_p);
1024 yy_current_state = yy_next_state;
1030 yy_cp = (yy_c_buf_p);
1031 goto yy_find_action;
1035 else switch ( yy_get_next_buffer( ) )
1037 case EOB_ACT_END_OF_FILE:
1039 (yy_did_buffer_switch_on_eof) = 0;
1041 if ( gras_ddt_parse_wrap( ) )
1043 /* Note: because we've taken care in
1044 * yy_get_next_buffer() to have set up
1045 * gras_ddt_parse_text, we can now set up
1046 * yy_c_buf_p so that if some total
1047 * hoser (like flex itself) wants to
1048 * call the scanner after we return the
1049 * YY_NULL, it'll still work - another
1050 * YY_NULL will get returned.
1052 (yy_c_buf_p) = (yytext_ptr) + YY_MORE_ADJ;
1054 yy_act = YY_STATE_EOF(YY_START);
1060 if ( ! (yy_did_buffer_switch_on_eof) )
1066 case EOB_ACT_CONTINUE_SCAN:
1068 (yytext_ptr) + yy_amount_of_matched_text;
1070 yy_current_state = yy_get_previous_state( );
1072 yy_cp = (yy_c_buf_p);
1073 yy_bp = (yytext_ptr) + YY_MORE_ADJ;
1076 case EOB_ACT_LAST_MATCH:
1078 &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[(yy_n_chars)];
1080 yy_current_state = yy_get_previous_state( );
1082 yy_cp = (yy_c_buf_p);
1083 yy_bp = (yytext_ptr) + YY_MORE_ADJ;
1084 goto yy_find_action;
1091 "fatal flex scanner internal error--no action found" );
1092 } /* end of action switch */
1093 } /* end of scanning one token */
1094 } /* end of gras_ddt_parse_lex */
1096 /* yy_get_next_buffer - try to read in a new buffer
1098 * Returns a code representing an action:
1099 * EOB_ACT_LAST_MATCH -
1100 * EOB_ACT_CONTINUE_SCAN - continue scanning from current position
1101 * EOB_ACT_END_OF_FILE - end of file
1103 static int yy_get_next_buffer (void)
1105 register char *dest = YY_CURRENT_BUFFER_LVALUE->yy_ch_buf;
1106 register char *source = (yytext_ptr);
1107 register int number_to_move, i;
1110 if ( (yy_c_buf_p) > &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[(yy_n_chars) + 1] )
1112 "fatal flex scanner internal error--end of buffer missed" );
1114 if ( YY_CURRENT_BUFFER_LVALUE->yy_fill_buffer == 0 )
1115 { /* Don't try to fill the buffer, so this is an EOF. */
1116 if ( (yy_c_buf_p) - (yytext_ptr) - YY_MORE_ADJ == 1 )
1118 /* We matched a single character, the EOB, so
1119 * treat this as a final EOF.
1121 return EOB_ACT_END_OF_FILE;
1126 /* We matched some text prior to the EOB, first
1129 return EOB_ACT_LAST_MATCH;
1133 /* Try to read more data. */
1135 /* First move last chars to start of buffer. */
1136 number_to_move = (int) ((yy_c_buf_p) - (yytext_ptr)) - 1;
1138 for ( i = 0; i < number_to_move; ++i )
1139 *(dest++) = *(source++);
1141 if ( YY_CURRENT_BUFFER_LVALUE->yy_buffer_status == YY_BUFFER_EOF_PENDING )
1142 /* don't do the read, it's not guaranteed to return an EOF,
1145 YY_CURRENT_BUFFER_LVALUE->yy_n_chars = (yy_n_chars) = 0;
1150 YY_CURRENT_BUFFER_LVALUE->yy_buf_size - number_to_move - 1;
1152 while ( num_to_read <= 0 )
1153 { /* Not enough room in the buffer - grow it. */
1155 /* just a shorter name for the current buffer */
1156 YY_BUFFER_STATE b = YY_CURRENT_BUFFER;
1158 int yy_c_buf_p_offset =
1159 (int) ((yy_c_buf_p) - b->yy_ch_buf);
1161 if ( b->yy_is_our_buffer )
1163 int new_size = b->yy_buf_size * 2;
1165 if ( new_size <= 0 )
1166 b->yy_buf_size += b->yy_buf_size / 8;
1168 b->yy_buf_size *= 2;
1170 b->yy_ch_buf = (char *)
1171 /* Include room in for 2 EOB chars. */
1172 gras_ddt_parse_realloc((void *) b->yy_ch_buf,b->yy_buf_size + 2 );
1175 /* Can't grow it, we don't own it. */
1178 if ( ! b->yy_ch_buf )
1180 "fatal error - scanner input buffer overflow" );
1182 (yy_c_buf_p) = &b->yy_ch_buf[yy_c_buf_p_offset];
1184 num_to_read = YY_CURRENT_BUFFER_LVALUE->yy_buf_size -
1189 if ( num_to_read > YY_READ_BUF_SIZE )
1190 num_to_read = YY_READ_BUF_SIZE;
1192 /* Read in more data. */
1193 YY_INPUT( (&YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[number_to_move]),
1194 (yy_n_chars), (size_t) num_to_read );
1196 YY_CURRENT_BUFFER_LVALUE->yy_n_chars = (yy_n_chars);
1199 if ( (yy_n_chars) == 0 )
1201 if ( number_to_move == YY_MORE_ADJ )
1203 ret_val = EOB_ACT_END_OF_FILE;
1204 gras_ddt_parse_restart(gras_ddt_parse_in );
1209 ret_val = EOB_ACT_LAST_MATCH;
1210 YY_CURRENT_BUFFER_LVALUE->yy_buffer_status =
1211 YY_BUFFER_EOF_PENDING;
1216 ret_val = EOB_ACT_CONTINUE_SCAN;
1218 (yy_n_chars) += number_to_move;
1219 YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[(yy_n_chars)] = YY_END_OF_BUFFER_CHAR;
1220 YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[(yy_n_chars) + 1] = YY_END_OF_BUFFER_CHAR;
1222 (yytext_ptr) = &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[0];
1227 /* yy_get_previous_state - get the state just before the EOB char was reached */
1229 static yy_state_type yy_get_previous_state (void)
1231 register yy_state_type yy_current_state;
1232 register char *yy_cp;
1234 yy_current_state = (yy_start);
1236 for ( yy_cp = (yytext_ptr) + YY_MORE_ADJ; yy_cp < (yy_c_buf_p); ++yy_cp )
1238 register YY_CHAR yy_c = (*yy_cp ? yy_ec[YY_SC_TO_UI(*yy_cp)] : 1);
1239 if ( yy_accept[yy_current_state] )
1241 (yy_last_accepting_state) = yy_current_state;
1242 (yy_last_accepting_cpos) = yy_cp;
1244 while ( yy_chk[yy_base[yy_current_state] + yy_c] != yy_current_state )
1246 yy_current_state = (int) yy_def[yy_current_state];
1247 if ( yy_current_state >= 61 )
1248 yy_c = yy_meta[(unsigned int) yy_c];
1250 yy_current_state = yy_nxt[yy_base[yy_current_state] + (unsigned int) yy_c];
1253 return yy_current_state;
1256 /* yy_try_NUL_trans - try to make a transition on the NUL character
1259 * next_state = yy_try_NUL_trans( current_state );
1261 static yy_state_type yy_try_NUL_trans (yy_state_type yy_current_state )
1263 register int yy_is_jam;
1264 register char *yy_cp = (yy_c_buf_p);
1266 register YY_CHAR yy_c = 1;
1267 if ( yy_accept[yy_current_state] )
1269 (yy_last_accepting_state) = yy_current_state;
1270 (yy_last_accepting_cpos) = yy_cp;
1272 while ( yy_chk[yy_base[yy_current_state] + yy_c] != yy_current_state )
1274 yy_current_state = (int) yy_def[yy_current_state];
1275 if ( yy_current_state >= 61 )
1276 yy_c = yy_meta[(unsigned int) yy_c];
1278 yy_current_state = yy_nxt[yy_base[yy_current_state] + (unsigned int) yy_c];
1279 yy_is_jam = (yy_current_state == 60);
1281 return yy_is_jam ? 0 : yy_current_state;
1284 static void yyunput (int c, register char * yy_bp )
1286 register char *yy_cp;
1288 yy_cp = (yy_c_buf_p);
1290 /* undo effects of setting up gras_ddt_parse_text */
1291 *yy_cp = (yy_hold_char);
1293 if ( yy_cp < YY_CURRENT_BUFFER_LVALUE->yy_ch_buf + 2 )
1294 { /* need to shift things up to make room */
1295 /* +2 for EOB chars. */
1296 register int number_to_move = (yy_n_chars) + 2;
1297 register char *dest = &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[
1298 YY_CURRENT_BUFFER_LVALUE->yy_buf_size + 2];
1299 register char *source =
1300 &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[number_to_move];
1302 while ( source > YY_CURRENT_BUFFER_LVALUE->yy_ch_buf )
1303 *--dest = *--source;
1305 yy_cp += (int) (dest - source);
1306 yy_bp += (int) (dest - source);
1307 YY_CURRENT_BUFFER_LVALUE->yy_n_chars =
1308 (yy_n_chars) = YY_CURRENT_BUFFER_LVALUE->yy_buf_size;
1310 if ( yy_cp < YY_CURRENT_BUFFER_LVALUE->yy_ch_buf + 2 )
1311 YY_FATAL_ERROR( "flex scanner push-back overflow" );
1314 *--yy_cp = (char) c;
1316 (yytext_ptr) = yy_bp;
1317 (yy_hold_char) = *yy_cp;
1318 (yy_c_buf_p) = yy_cp;
1323 static int yyinput (void)
1325 static int input (void)
1331 *(yy_c_buf_p) = (yy_hold_char);
1333 if ( *(yy_c_buf_p) == YY_END_OF_BUFFER_CHAR )
1335 /* yy_c_buf_p now points to the character we want to return.
1336 * If this occurs *before* the EOB characters, then it's a
1337 * valid NUL; if not, then we've hit the end of the buffer.
1339 if ( (yy_c_buf_p) < &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[(yy_n_chars)] )
1340 /* This was really a NUL. */
1341 *(yy_c_buf_p) = '\0';
1344 { /* need more input */
1345 int offset = (yy_c_buf_p) - (yytext_ptr);
1348 switch ( yy_get_next_buffer( ) )
1350 case EOB_ACT_LAST_MATCH:
1351 /* This happens because yy_g_n_b()
1352 * sees that we've accumulated a
1353 * token and flags that we need to
1354 * try matching the token before
1355 * proceeding. But for input(),
1356 * there's no matching to consider.
1357 * So convert the EOB_ACT_LAST_MATCH
1358 * to EOB_ACT_END_OF_FILE.
1361 /* Reset buffer status. */
1362 gras_ddt_parse_restart(gras_ddt_parse_in );
1366 case EOB_ACT_END_OF_FILE:
1368 if ( gras_ddt_parse_wrap( ) )
1371 if ( ! (yy_did_buffer_switch_on_eof) )
1380 case EOB_ACT_CONTINUE_SCAN:
1381 (yy_c_buf_p) = (yytext_ptr) + offset;
1387 c = *(unsigned char *) (yy_c_buf_p); /* cast for 8-bit char's */
1388 *(yy_c_buf_p) = '\0'; /* preserve gras_ddt_parse_text */
1389 (yy_hold_char) = *++(yy_c_buf_p);
1393 #endif /* ifndef YY_NO_INPUT */
1395 /** Immediately switch to a different input stream.
1396 * @param input_file A readable stream.
1398 * @note This function does not reset the start condition to @c INITIAL .
1400 void gras_ddt_parse_restart (FILE * input_file )
1403 if ( ! YY_CURRENT_BUFFER ){
1404 gras_ddt_parse_ensure_buffer_stack ();
1405 YY_CURRENT_BUFFER_LVALUE =
1406 gras_ddt_parse__create_buffer(gras_ddt_parse_in,YY_BUF_SIZE );
1409 gras_ddt_parse__init_buffer(YY_CURRENT_BUFFER,input_file );
1410 gras_ddt_parse__load_buffer_state( );
1413 /** Switch to a different input buffer.
1414 * @param new_buffer The new input buffer.
1417 void gras_ddt_parse__switch_to_buffer (YY_BUFFER_STATE new_buffer )
1420 /* TODO. We should be able to replace this entire function body
1422 * gras_ddt_parse_pop_buffer_state();
1423 * gras_ddt_parse_push_buffer_state(new_buffer);
1425 gras_ddt_parse_ensure_buffer_stack ();
1426 if ( YY_CURRENT_BUFFER == new_buffer )
1429 if ( YY_CURRENT_BUFFER )
1431 /* Flush out information for old buffer. */
1432 *(yy_c_buf_p) = (yy_hold_char);
1433 YY_CURRENT_BUFFER_LVALUE->yy_buf_pos = (yy_c_buf_p);
1434 YY_CURRENT_BUFFER_LVALUE->yy_n_chars = (yy_n_chars);
1437 YY_CURRENT_BUFFER_LVALUE = new_buffer;
1438 gras_ddt_parse__load_buffer_state( );
1440 /* We don't actually know whether we did this switch during
1441 * EOF (gras_ddt_parse_wrap()) processing, but the only time this flag
1442 * is looked at is after gras_ddt_parse_wrap() is called, so it's safe
1443 * to go ahead and always set it.
1445 (yy_did_buffer_switch_on_eof) = 1;
1448 static void gras_ddt_parse__load_buffer_state (void)
1450 (yy_n_chars) = YY_CURRENT_BUFFER_LVALUE->yy_n_chars;
1451 (yytext_ptr) = (yy_c_buf_p) = YY_CURRENT_BUFFER_LVALUE->yy_buf_pos;
1452 gras_ddt_parse_in = YY_CURRENT_BUFFER_LVALUE->yy_input_file;
1453 (yy_hold_char) = *(yy_c_buf_p);
1456 /** Allocate and initialize an input buffer state.
1457 * @param file A readable stream.
1458 * @param size The character buffer size in bytes. When in doubt, use @c YY_BUF_SIZE.
1460 * @return the allocated buffer state.
1462 YY_BUFFER_STATE gras_ddt_parse__create_buffer (FILE * file, int size )
1466 b = (YY_BUFFER_STATE) gras_ddt_parse_alloc(sizeof( struct yy_buffer_state ) );
1468 YY_FATAL_ERROR( "out of dynamic memory in gras_ddt_parse__create_buffer()" );
1470 b->yy_buf_size = size;
1472 /* yy_ch_buf has to be 2 characters longer than the size given because
1473 * we need to put in 2 end-of-buffer characters.
1475 b->yy_ch_buf = (char *) gras_ddt_parse_alloc(b->yy_buf_size + 2 );
1476 if ( ! b->yy_ch_buf )
1477 YY_FATAL_ERROR( "out of dynamic memory in gras_ddt_parse__create_buffer()" );
1479 b->yy_is_our_buffer = 1;
1481 gras_ddt_parse__init_buffer(b,file );
1486 /** Destroy the buffer.
1487 * @param b a buffer created with gras_ddt_parse__create_buffer()
1490 void gras_ddt_parse__delete_buffer (YY_BUFFER_STATE b )
1496 if ( b == YY_CURRENT_BUFFER ) /* Not sure if we should pop here. */
1497 YY_CURRENT_BUFFER_LVALUE = (YY_BUFFER_STATE) 0;
1499 if ( b->yy_is_our_buffer )
1500 gras_ddt_parse_free((void *) b->yy_ch_buf );
1502 gras_ddt_parse_free((void *) b );
1505 #if !defined(__cplusplus) && !defined(WIN32)
1506 extern int isatty (int );
1507 #endif /* __cplusplus */
1509 /* Initializes or reinitializes a buffer.
1510 * This function is sometimes called more than once on the same buffer,
1511 * such as during a gras_ddt_parse_restart() or at EOF.
1513 static void gras_ddt_parse__init_buffer (YY_BUFFER_STATE b, FILE * file )
1518 gras_ddt_parse__flush_buffer(b );
1520 b->yy_input_file = file;
1521 b->yy_fill_buffer = 1;
1523 /* If b is the current buffer, then gras_ddt_parse__init_buffer was _probably_
1524 * called from gras_ddt_parse_restart() or through yy_get_next_buffer.
1525 * In that case, we don't want to reset the lineno or column.
1527 if (b != YY_CURRENT_BUFFER){
1528 b->yy_bs_lineno = 1;
1529 b->yy_bs_column = 0;
1532 b->yy_is_interactive = file ? (isatty( fileno(file) ) > 0) : 0;
1537 /** Discard all buffered characters. On the next scan, YY_INPUT will be called.
1538 * @param b the buffer state to be flushed, usually @c YY_CURRENT_BUFFER.
1541 void gras_ddt_parse__flush_buffer (YY_BUFFER_STATE b )
1548 /* We always need two end-of-buffer characters. The first causes
1549 * a transition to the end-of-buffer state. The second causes
1550 * a jam in that state.
1552 b->yy_ch_buf[0] = YY_END_OF_BUFFER_CHAR;
1553 b->yy_ch_buf[1] = YY_END_OF_BUFFER_CHAR;
1555 b->yy_buf_pos = &b->yy_ch_buf[0];
1558 b->yy_buffer_status = YY_BUFFER_NEW;
1560 if ( b == YY_CURRENT_BUFFER )
1561 gras_ddt_parse__load_buffer_state( );
1564 /** Pushes the new state onto the stack. The new state becomes
1565 * the current state. This function will allocate the stack
1567 * @param new_buffer The new state.
1570 void gras_ddt_parse_push_buffer_state (YY_BUFFER_STATE new_buffer )
1572 if (new_buffer == NULL)
1575 gras_ddt_parse_ensure_buffer_stack();
1577 /* This block is copied from gras_ddt_parse__switch_to_buffer. */
1578 if ( YY_CURRENT_BUFFER )
1580 /* Flush out information for old buffer. */
1581 *(yy_c_buf_p) = (yy_hold_char);
1582 YY_CURRENT_BUFFER_LVALUE->yy_buf_pos = (yy_c_buf_p);
1583 YY_CURRENT_BUFFER_LVALUE->yy_n_chars = (yy_n_chars);
1586 /* Only push if top exists. Otherwise, replace top. */
1587 if (YY_CURRENT_BUFFER)
1588 (yy_buffer_stack_top)++;
1589 YY_CURRENT_BUFFER_LVALUE = new_buffer;
1591 /* copied from gras_ddt_parse__switch_to_buffer. */
1592 gras_ddt_parse__load_buffer_state( );
1593 (yy_did_buffer_switch_on_eof) = 1;
1596 /** Removes and deletes the top of the stack, if present.
1597 * The next element becomes the new top.
1600 void gras_ddt_parse_pop_buffer_state (void)
1602 if (!YY_CURRENT_BUFFER)
1605 gras_ddt_parse__delete_buffer(YY_CURRENT_BUFFER );
1606 YY_CURRENT_BUFFER_LVALUE = NULL;
1607 if ((yy_buffer_stack_top) > 0)
1608 --(yy_buffer_stack_top);
1610 if (YY_CURRENT_BUFFER) {
1611 gras_ddt_parse__load_buffer_state( );
1612 (yy_did_buffer_switch_on_eof) = 1;
1616 /* Allocates the stack if it does not exist.
1617 * Guarantees space for at least one push.
1619 static void gras_ddt_parse_ensure_buffer_stack (void)
1623 if (!(yy_buffer_stack)) {
1625 /* First allocation is just for 2 elements, since we don't know if this
1626 * scanner will even need a stack. We use 2 instead of 1 to avoid an
1627 * immediate realloc on the next call.
1630 (yy_buffer_stack) = (struct yy_buffer_state**)gras_ddt_parse_alloc
1631 (num_to_alloc * sizeof(struct yy_buffer_state*)
1634 memset((yy_buffer_stack), 0, num_to_alloc * sizeof(struct yy_buffer_state*));
1636 (yy_buffer_stack_max) = num_to_alloc;
1637 (yy_buffer_stack_top) = 0;
1641 if ((yy_buffer_stack_top) >= ((yy_buffer_stack_max)) - 1){
1643 /* Increase the buffer to prepare for a possible push. */
1644 int grow_size = 8 /* arbitrary grow size */;
1646 num_to_alloc = (yy_buffer_stack_max) + grow_size;
1647 (yy_buffer_stack) = (struct yy_buffer_state**)gras_ddt_parse_realloc
1649 num_to_alloc * sizeof(struct yy_buffer_state*)
1652 /* zero only the new slots.*/
1653 memset((yy_buffer_stack) + (yy_buffer_stack_max), 0, grow_size * sizeof(struct yy_buffer_state*));
1654 (yy_buffer_stack_max) = num_to_alloc;
1658 /** Setup the input buffer state to scan directly from a user-specified character buffer.
1659 * @param base the character buffer
1660 * @param size the size in bytes of the character buffer
1662 * @return the newly allocated buffer state object.
1664 YY_BUFFER_STATE gras_ddt_parse__scan_buffer (char * base, yy_size_t size )
1669 base[size-2] != YY_END_OF_BUFFER_CHAR ||
1670 base[size-1] != YY_END_OF_BUFFER_CHAR )
1671 /* They forgot to leave room for the EOB's. */
1674 b = (YY_BUFFER_STATE) gras_ddt_parse_alloc(sizeof( struct yy_buffer_state ) );
1676 YY_FATAL_ERROR( "out of dynamic memory in gras_ddt_parse__scan_buffer()" );
1678 b->yy_buf_size = size - 2; /* "- 2" to take care of EOB's */
1679 b->yy_buf_pos = b->yy_ch_buf = base;
1680 b->yy_is_our_buffer = 0;
1681 b->yy_input_file = 0;
1682 b->yy_n_chars = b->yy_buf_size;
1683 b->yy_is_interactive = 0;
1685 b->yy_fill_buffer = 0;
1686 b->yy_buffer_status = YY_BUFFER_NEW;
1688 gras_ddt_parse__switch_to_buffer(b );
1693 /** Setup the input buffer state to scan a string. The next call to gras_ddt_parse_lex() will
1694 * scan from a @e copy of @a str.
1695 * @param yystr a NUL-terminated string to scan
1697 * @return the newly allocated buffer state object.
1698 * @note If you want to scan bytes that may contain NUL values, then use
1699 * gras_ddt_parse__scan_bytes() instead.
1701 YY_BUFFER_STATE gras_ddt_parse__scan_string (yyconst char * yystr )
1704 return gras_ddt_parse__scan_bytes(yystr,strlen(yystr) );
1707 /** Setup the input buffer state to scan the given bytes. The next call to gras_ddt_parse_lex() will
1708 * scan from a @e copy of @a bytes.
1709 * @param bytes the byte buffer to scan
1710 * @param len the number of bytes in the buffer pointed to by @a bytes.
1712 * @return the newly allocated buffer state object.
1714 YY_BUFFER_STATE gras_ddt_parse__scan_bytes (yyconst char * yybytes, int _yybytes_len )
1721 /* Get memory for full buffer, including space for trailing EOB's. */
1722 n = _yybytes_len + 2;
1723 buf = (char *) gras_ddt_parse_alloc(n );
1725 YY_FATAL_ERROR( "out of dynamic memory in gras_ddt_parse__scan_bytes()" );
1727 for ( i = 0; i < _yybytes_len; ++i )
1728 buf[i] = yybytes[i];
1730 buf[_yybytes_len] = buf[_yybytes_len+1] = YY_END_OF_BUFFER_CHAR;
1732 b = gras_ddt_parse__scan_buffer(buf,n );
1734 YY_FATAL_ERROR( "bad buffer in gras_ddt_parse__scan_bytes()" );
1736 /* It's okay to grow etc. this buffer, and we should throw it
1737 * away when we're done.
1739 b->yy_is_our_buffer = 1;
1744 #ifndef YY_EXIT_FAILURE
1745 #define YY_EXIT_FAILURE 2
1748 static void yy_fatal_error (yyconst char* msg )
1750 (void) fprintf( stderr, "%s\n", msg );
1751 exit( YY_EXIT_FAILURE );
1754 /* Redefine yyless() so it works in section 3 code. */
1760 /* Undo effects of setting up gras_ddt_parse_text. */ \
1761 int yyless_macro_arg = (n); \
1762 YY_LESS_LINENO(yyless_macro_arg);\
1763 gras_ddt_parse_text[gras_ddt_parse_leng] = (yy_hold_char); \
1764 (yy_c_buf_p) = gras_ddt_parse_text + yyless_macro_arg; \
1765 (yy_hold_char) = *(yy_c_buf_p); \
1766 *(yy_c_buf_p) = '\0'; \
1767 gras_ddt_parse_leng = yyless_macro_arg; \
1771 /* Accessor methods (get/set functions) to struct members. */
1773 /** Get the current line number.
1776 int gras_ddt_parse_get_lineno (void)
1779 return gras_ddt_parse_lineno;
1782 /** Get the input stream.
1785 FILE *gras_ddt_parse_get_in (void)
1787 return gras_ddt_parse_in;
1790 /** Get the output stream.
1793 FILE *gras_ddt_parse_get_out (void)
1795 return gras_ddt_parse_out;
1798 /** Get the length of the current token.
1801 int gras_ddt_parse_get_leng (void)
1803 return gras_ddt_parse_leng;
1806 /** Get the current token.
1810 char *gras_ddt_parse_get_text (void)
1812 return gras_ddt_parse_text;
1815 /** Set the current line number.
1816 * @param line_number
1819 void gras_ddt_parse_set_lineno (int line_number )
1822 gras_ddt_parse_lineno = line_number;
1825 /** Set the input stream. This does not discard the current
1827 * @param in_str A readable stream.
1829 * @see gras_ddt_parse__switch_to_buffer
1831 void gras_ddt_parse_set_in (FILE * in_str )
1833 gras_ddt_parse_in = in_str ;
1836 void gras_ddt_parse_set_out (FILE * out_str )
1838 gras_ddt_parse_out = out_str ;
1841 int gras_ddt_parse_get_debug (void)
1843 return gras_ddt_parse__flex_debug;
1846 void gras_ddt_parse_set_debug (int bdebug )
1848 gras_ddt_parse__flex_debug = bdebug ;
1851 static int yy_init_globals (void)
1853 /* Initialization is the same as for the non-reentrant scanner.
1854 * This function is called from gras_ddt_parse_lex_destroy(), so don't allocate here.
1857 (yy_buffer_stack) = 0;
1858 (yy_buffer_stack_top) = 0;
1859 (yy_buffer_stack_max) = 0;
1860 (yy_c_buf_p) = (char *) 0;
1864 /* Defined in main.c */
1866 gras_ddt_parse_in = stdin;
1867 gras_ddt_parse_out = stdout;
1869 gras_ddt_parse_in = (FILE *) 0;
1870 gras_ddt_parse_out = (FILE *) 0;
1873 /* For future reference: Set errno on error, since we are called by
1874 * gras_ddt_parse_lex_init()
1879 /* gras_ddt_parse_lex_destroy is for both reentrant and non-reentrant scanners. */
1880 int gras_ddt_parse_lex_destroy (void)
1883 /* Pop the buffer stack, destroying each element. */
1884 while(YY_CURRENT_BUFFER){
1885 gras_ddt_parse__delete_buffer(YY_CURRENT_BUFFER );
1886 YY_CURRENT_BUFFER_LVALUE = NULL;
1887 gras_ddt_parse_pop_buffer_state();
1890 /* Destroy the stack itself. */
1891 gras_ddt_parse_free((yy_buffer_stack) );
1892 (yy_buffer_stack) = NULL;
1894 /* Reset the globals. This is important in a non-reentrant scanner so the next time
1895 * gras_ddt_parse_lex() is called, initialization will occur. */
1902 * Internal utility routines.
1906 static void yy_flex_strncpy (char* s1, yyconst char * s2, int n )
1909 for ( i = 0; i < n; ++i )
1914 #ifdef YY_NEED_STRLEN
1915 static int yy_flex_strlen (yyconst char * s )
1918 for ( n = 0; s[n]; ++n )
1925 void *gras_ddt_parse_alloc (yy_size_t size )
1927 return (void *) malloc( size );
1930 void *gras_ddt_parse_realloc (void * ptr, yy_size_t size )
1932 /* The cast to (char *) in the following accommodates both
1933 * implementations that use char* generic pointers, and those
1934 * that use void* generic pointers. It works with the latter
1935 * because both ANSI C and C++ allow castless assignment from
1936 * any pointer type to void*, and deal with argument conversions
1937 * as though doing an assignment.
1939 return (void *) realloc( (char *) ptr, size );
1942 void gras_ddt_parse_free (void * ptr )
1944 free( (char *) ptr ); /* see gras_ddt_parse_realloc() for (char *) cast */
1947 #define YYTABLES_NAME "yytables"
1949 /* {space}+ { return(TOKEN_SPACE);} */
1951 void gras_ddt_parse_dump(void) {
1952 switch(gras_ddt_parse_tok_num) {
1953 case GRAS_DDT_PARSE_TOKEN_LA : {printf("TOKEN_LA ");break;}
1954 case GRAS_DDT_PARSE_TOKEN_RA : {printf("TOKEN_RA ");break;}
1955 case GRAS_DDT_PARSE_TOKEN_WORD : {printf("TOKEN_WORD ");break;}
1956 /* case GRAS_DDT_PARSE_TOKEN_SPACE : {printf("TOKEN_SPACE ");break;}*/
1957 /* case GRAS_DDT_PARSE_TOKEN_COMMENT : {printf("TOKEN_COMMENT ");break;}*/
1958 case GRAS_DDT_PARSE_TOKEN_NEWLINE : {printf("TOKEN_NEWLINE\n");return;}
1959 case GRAS_DDT_PARSE_TOKEN_EMPTY : {printf("TOKEN_EMPTY\n");return;}
1960 default : {printf("Unknown token %d\n", gras_ddt_parse_tok_num);return;}
1962 printf("-->%s<-- [line %d, pos %d]\n",gras_ddt_parse_text,gras_ddt_parse_line_pos,gras_ddt_parse_char_pos);
1966 int gras_ddt_parse_lex_n_dump(void) {
1967 gras_ddt_parse_tok_num = gras_ddt_parse_lex();
1968 /* gras_ddt_parse_char_pos += strlen(gras_ddt_parse_text);*/
1969 return(gras_ddt_parse_tok_num);
1972 void gras_ddt_parse_pointer_init(const char *file) {
1973 gras_ddt_file_to_parse = fopen(file,"r");
1974 gras_ddt_input_buffer = gras_ddt_parse__create_buffer(gras_ddt_file_to_parse,10 );
1975 gras_ddt_parse__switch_to_buffer(gras_ddt_input_buffer);
1977 gras_ddt_parse_line_pos = 1;
1978 gras_ddt_parse_char_pos = 0;
1979 gras_ddt_parse_col_pos = 0;
1980 gras_ddt_parse_tok_num = 0;
1983 void gras_ddt_parse_pointer_close(void) {
1984 gras_ddt_parse__delete_buffer(gras_ddt_input_buffer);
1985 fclose(gras_ddt_file_to_parse);
1987 gras_ddt_parse_line_pos = 1;
1988 gras_ddt_parse_char_pos = 0;
1989 gras_ddt_parse_tok_num = 0;
1992 void gras_ddt_parse_pointer_string_init(const char *string_to_parse) {
1993 gras_ddt_input_buffer = gras_ddt_parse__scan_string (string_to_parse);
1994 definition = string_to_parse;
1995 gras_ddt_parse__switch_to_buffer(gras_ddt_input_buffer);
1997 gras_ddt_parse_line_pos = 1;
1998 gras_ddt_parse_char_pos = 0;
1999 gras_ddt_parse_tok_num = 0;
2002 void gras_ddt_parse_pointer_string_close(void) {
2003 gras_ddt_parse__delete_buffer(gras_ddt_input_buffer);
2005 gras_ddt_parse_line_pos = 1;
2006 gras_ddt_parse_char_pos = 0;
2007 gras_ddt_parse_tok_num = 0;
2010 yyunput('\0',NULL); /* fake a use of this function to calm gcc down */
2013 /* Local variables:*/