2 #line 3 "gras/DataDesc/ddt_parse.yy.c"
4 #define YY_INT_ALIGNED short int
6 /* A lexical scanner generated by flex */
8 #define yy_create_buffer gras_ddt_parse__create_buffer
9 #define yy_delete_buffer gras_ddt_parse__delete_buffer
10 #define yy_flex_debug gras_ddt_parse__flex_debug
11 #define yy_init_buffer gras_ddt_parse__init_buffer
12 #define yy_flush_buffer gras_ddt_parse__flush_buffer
13 #define yy_load_buffer_state gras_ddt_parse__load_buffer_state
14 #define yy_switch_to_buffer gras_ddt_parse__switch_to_buffer
15 #define yyin gras_ddt_parse_in
16 #define yyleng gras_ddt_parse_leng
17 #define yylex gras_ddt_parse_lex
18 #define yylineno gras_ddt_parse_lineno
19 #define yyout gras_ddt_parse_out
20 #define yyrestart gras_ddt_parse_restart
21 #define yytext gras_ddt_parse_text
22 #define yywrap gras_ddt_parse_wrap
23 #define yyalloc gras_ddt_parse_alloc
24 #define yyrealloc gras_ddt_parse_realloc
25 #define yyfree gras_ddt_parse_free
28 #define YY_FLEX_MAJOR_VERSION 2
29 #define YY_FLEX_MINOR_VERSION 5
30 #define YY_FLEX_SUBMINOR_VERSION 35
31 #if YY_FLEX_SUBMINOR_VERSION > 0
35 /* First, we deal with platform-specific or compiler-specific issues. */
37 /* begin standard C headers. */
43 /* end standard C headers. */
45 /* flex integer type definitions */
50 /* C99 systems have <inttypes.h>. Non-C99 systems may or may not. */
52 #if defined (__STDC_VERSION__) && __STDC_VERSION__ >= 199901L
54 /* C99 says to define __STDC_LIMIT_MACROS before including stdint.h,
55 * if you want the limit (max/min) macros for int types.
57 #ifndef __STDC_LIMIT_MACROS
58 #define __STDC_LIMIT_MACROS 1
62 typedef int8_t flex_int8_t;
63 typedef uint8_t flex_uint8_t;
64 typedef int16_t flex_int16_t;
65 typedef uint16_t flex_uint16_t;
66 typedef int32_t flex_int32_t;
67 typedef uint32_t flex_uint32_t;
69 typedef signed char flex_int8_t;
70 typedef short int flex_int16_t;
71 typedef int flex_int32_t;
72 typedef unsigned char flex_uint8_t;
73 typedef unsigned short int flex_uint16_t;
74 typedef unsigned int flex_uint32_t;
76 /* Limits of integral types. */
78 #define INT8_MIN (-128)
81 #define INT16_MIN (-32767-1)
84 #define INT32_MIN (-2147483647-1)
87 #define INT8_MAX (127)
90 #define INT16_MAX (32767)
93 #define INT32_MAX (2147483647)
96 #define UINT8_MAX (255U)
99 #define UINT16_MAX (65535U)
102 #define UINT32_MAX (4294967295U)
107 #endif /* ! FLEXINT_H */
111 /* The "const" storage-class-modifier is valid. */
114 #else /* ! __cplusplus */
116 /* C99 requires __STDC__ to be defined as 1. */
117 #if defined (__STDC__)
121 #endif /* defined (__STDC__) */
122 #endif /* ! __cplusplus */
125 #define yyconst const
130 /* Returned upon end-of-file. */
133 /* Promotes a possibly negative, possibly signed char to an unsigned
134 * integer for use as an array index. If the signed char is negative,
135 * we want to instead treat it as an 8-bit unsigned char, hence the
138 #define YY_SC_TO_UI(c) ((unsigned int) (unsigned char) c)
140 /* Enter a start condition. This macro really ought to take a parameter,
141 * but we do it the disgusting crufty way forced on us by the ()-less
142 * definition of BEGIN.
144 #define BEGIN (yy_start) = 1 + 2 *
146 /* Translate the current start state into a value that can be later handed
147 * to BEGIN to return to the state. The YYSTATE alias is for lex
150 #define YY_START (((yy_start) - 1) / 2)
151 #define YYSTATE YY_START
153 /* Action number for EOF rule of a given start state. */
154 #define YY_STATE_EOF(state) (YY_END_OF_BUFFER + state + 1)
156 /* Special action meaning "start processing a new file". */
157 #define YY_NEW_FILE gras_ddt_parse_restart(gras_ddt_parse_in )
159 #define YY_END_OF_BUFFER_CHAR 0
161 /* Size of default input buffer. */
163 #define YY_BUF_SIZE 16384
166 /* The state buf must be large enough to hold one state per character in the main buffer.
168 #define YY_STATE_BUF_SIZE ((YY_BUF_SIZE + 2) * sizeof(yy_state_type))
170 #ifndef YY_TYPEDEF_YY_BUFFER_STATE
171 #define YY_TYPEDEF_YY_BUFFER_STATE
172 typedef struct yy_buffer_state *YY_BUFFER_STATE;
175 extern int gras_ddt_parse_leng;
177 extern FILE *gras_ddt_parse_in, *gras_ddt_parse_out;
179 #define EOB_ACT_CONTINUE_SCAN 0
180 #define EOB_ACT_END_OF_FILE 1
181 #define EOB_ACT_LAST_MATCH 2
183 #define YY_LESS_LINENO(n)
185 /* Return all but the first "n" matched characters back to the input stream. */
189 /* Undo effects of setting up gras_ddt_parse_text. */ \
190 int yyless_macro_arg = (n); \
191 YY_LESS_LINENO(yyless_macro_arg);\
192 *yy_cp = (yy_hold_char); \
193 YY_RESTORE_YY_MORE_OFFSET \
194 (yy_c_buf_p) = yy_cp = yy_bp + yyless_macro_arg - YY_MORE_ADJ; \
195 YY_DO_BEFORE_ACTION; /* set up gras_ddt_parse_text again */ \
199 #define unput(c) yyunput( c, (yytext_ptr) )
201 #ifndef YY_TYPEDEF_YY_SIZE_T
202 #define YY_TYPEDEF_YY_SIZE_T
203 typedef size_t yy_size_t;
206 #ifndef YY_STRUCT_YY_BUFFER_STATE
207 #define YY_STRUCT_YY_BUFFER_STATE
208 struct yy_buffer_state
212 char *yy_ch_buf; /* input buffer */
213 char *yy_buf_pos; /* current position in input buffer */
215 /* Size of input buffer in bytes, not including room for EOB
218 yy_size_t yy_buf_size;
220 /* Number of characters read into yy_ch_buf, not including EOB
225 /* Whether we "own" the buffer - i.e., we know we created it,
226 * and can realloc() it to grow it, and should free() it to
229 int yy_is_our_buffer;
231 /* Whether this is an "interactive" input source; if so, and
232 * if we're using stdio for input, then we want to use getc()
233 * instead of fread(), to make sure we stop fetching input after
236 int yy_is_interactive;
238 /* Whether we're considered to be at the beginning of a line.
239 * If so, '^' rules will be active on the next match, otherwise
244 int yy_bs_lineno; /**< The line count. */
245 int yy_bs_column; /**< The column count. */
247 /* Whether to try to fill the input buffer when we reach the
252 int yy_buffer_status;
254 #define YY_BUFFER_NEW 0
255 #define YY_BUFFER_NORMAL 1
256 /* When an EOF's been seen but there's still some text to process
257 * then we mark the buffer as YY_EOF_PENDING, to indicate that we
258 * shouldn't try reading from the input source any more. We might
259 * still have a bunch of tokens to match, though, because of
260 * possible backing-up.
262 * When we actually see the EOF, we change the status to "new"
263 * (via gras_ddt_parse_restart()), so that the user can continue scanning by
264 * just pointing gras_ddt_parse_in at a new input file.
266 #define YY_BUFFER_EOF_PENDING 2
269 #endif /* !YY_STRUCT_YY_BUFFER_STATE */
271 /* Stack of input buffers. */
272 static size_t yy_buffer_stack_top = 0; /**< index of top of stack. */
273 static size_t yy_buffer_stack_max = 0; /**< capacity of stack. */
274 static YY_BUFFER_STATE * yy_buffer_stack = 0; /**< Stack as an array. */
276 /* We provide macros for accessing buffer states in case in the
277 * future we want to put the buffer states in a more general
280 * Returns the top of the stack, or NULL.
282 #define YY_CURRENT_BUFFER ( (yy_buffer_stack) \
283 ? (yy_buffer_stack)[(yy_buffer_stack_top)] \
286 /* Same as previous macro, but useful when we know that the buffer stack is not
287 * NULL or when we need an lvalue. For internal use only.
289 #define YY_CURRENT_BUFFER_LVALUE (yy_buffer_stack)[(yy_buffer_stack_top)]
291 /* yy_hold_char holds the character lost when gras_ddt_parse_text is formed. */
292 static char yy_hold_char;
293 static int yy_n_chars; /* number of characters read into yy_ch_buf */
294 int gras_ddt_parse_leng;
296 /* Points to current character in buffer. */
297 static char *yy_c_buf_p = (char *) 0;
298 static int yy_init = 0; /* whether we need to initialize */
299 static int yy_start = 0; /* start state number */
301 /* Flag which is used to allow gras_ddt_parse_wrap()'s to do buffer switches
302 * instead of setting up a fresh gras_ddt_parse_in. A bit of a hack ...
304 static int yy_did_buffer_switch_on_eof;
306 void gras_ddt_parse_restart (FILE *input_file );
307 void gras_ddt_parse__switch_to_buffer (YY_BUFFER_STATE new_buffer );
308 YY_BUFFER_STATE gras_ddt_parse__create_buffer (FILE *file,int size );
309 void gras_ddt_parse__delete_buffer (YY_BUFFER_STATE b );
310 void gras_ddt_parse__flush_buffer (YY_BUFFER_STATE b );
311 void gras_ddt_parse_push_buffer_state (YY_BUFFER_STATE new_buffer );
312 void gras_ddt_parse_pop_buffer_state (void );
314 static void gras_ddt_parse_ensure_buffer_stack (void );
315 static void gras_ddt_parse__load_buffer_state (void );
316 static void gras_ddt_parse__init_buffer (YY_BUFFER_STATE b,FILE *file );
318 #define YY_FLUSH_BUFFER gras_ddt_parse__flush_buffer(YY_CURRENT_BUFFER )
320 YY_BUFFER_STATE gras_ddt_parse__scan_buffer (char *base,yy_size_t size );
321 YY_BUFFER_STATE gras_ddt_parse__scan_string (yyconst char *yy_str );
322 YY_BUFFER_STATE gras_ddt_parse__scan_bytes (yyconst char *bytes,int len );
324 void *gras_ddt_parse_alloc (yy_size_t );
325 void *gras_ddt_parse_realloc (void *,yy_size_t );
326 void gras_ddt_parse_free (void * );
328 #define yy_new_buffer gras_ddt_parse__create_buffer
330 #define yy_set_interactive(is_interactive) \
332 if ( ! YY_CURRENT_BUFFER ){ \
333 gras_ddt_parse_ensure_buffer_stack (); \
334 YY_CURRENT_BUFFER_LVALUE = \
335 gras_ddt_parse__create_buffer(gras_ddt_parse_in,YY_BUF_SIZE ); \
337 YY_CURRENT_BUFFER_LVALUE->yy_is_interactive = is_interactive; \
340 #define yy_set_bol(at_bol) \
342 if ( ! YY_CURRENT_BUFFER ){\
343 gras_ddt_parse_ensure_buffer_stack (); \
344 YY_CURRENT_BUFFER_LVALUE = \
345 gras_ddt_parse__create_buffer(gras_ddt_parse_in,YY_BUF_SIZE ); \
347 YY_CURRENT_BUFFER_LVALUE->yy_at_bol = at_bol; \
350 #define YY_AT_BOL() (YY_CURRENT_BUFFER_LVALUE->yy_at_bol)
352 /* Begin user sect3 */
354 #define gras_ddt_parse_wrap(n) 1
355 #define YY_SKIP_YYWRAP
357 typedef unsigned char YY_CHAR;
359 FILE *gras_ddt_parse_in = (FILE *) 0, *gras_ddt_parse_out = (FILE *) 0;
361 typedef int yy_state_type;
363 extern int gras_ddt_parse_lineno;
365 int gras_ddt_parse_lineno = 1;
367 extern char *gras_ddt_parse_text;
368 #define yytext_ptr gras_ddt_parse_text
370 static yy_state_type yy_get_previous_state (void );
371 static yy_state_type yy_try_NUL_trans (yy_state_type current_state );
372 static int yy_get_next_buffer (void );
373 static void yy_fatal_error (yyconst char msg[] );
375 /* Done after the current pattern has been matched and before the
376 * corresponding action - sets up gras_ddt_parse_text.
378 #define YY_DO_BEFORE_ACTION \
379 (yytext_ptr) = yy_bp; \
380 gras_ddt_parse_leng = (size_t) (yy_cp - yy_bp); \
381 (yy_hold_char) = *yy_cp; \
383 (yy_c_buf_p) = yy_cp;
385 #define YY_NUM_RULES 26
386 #define YY_END_OF_BUFFER 27
387 /* This struct is not used in this scanner,
388 but its presence is necessary. */
391 flex_int32_t yy_verify;
394 static yyconst flex_int16_t yy_accept[61] =
396 14, 14, 7, 7, 10, 10, 0, 0, 27, 25,
397 24, 19, 20, 21, 23, 14, 25, 22, 17, 18,
398 15, 16, 7, 7, 6, 7, 7, 10, 12, 11,
399 26, 26, 14, 0, 1, 7, 7, 7, 5, 7,
400 10, 11, 11, 13, 0, 0, 2, 1, 4, 0,
401 3, 0, 2, 0, 3, 0, 0, 8, 9, 0
404 static yyconst flex_int32_t yy_ec[256] =
406 1, 1, 1, 1, 1, 1, 1, 1, 2, 3,
407 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
408 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
409 1, 2, 1, 1, 1, 1, 1, 1, 1, 4,
410 5, 6, 1, 7, 8, 8, 9, 10, 10, 10,
411 10, 10, 10, 10, 10, 10, 10, 1, 11, 1,
412 1, 1, 1, 1, 8, 8, 8, 8, 8, 8,
413 8, 8, 8, 8, 8, 8, 8, 8, 8, 8,
414 8, 8, 8, 8, 8, 8, 8, 8, 8, 8,
415 12, 1, 13, 14, 8, 1, 8, 8, 8, 8,
417 8, 8, 15, 8, 8, 8, 8, 8, 8, 8,
418 8, 8, 8, 8, 8, 8, 8, 8, 8, 8,
419 8, 8, 16, 1, 17, 1, 1, 1, 1, 1,
420 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
421 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
422 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
423 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
424 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
425 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
426 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
428 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
429 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
430 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
431 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
432 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
436 static yyconst flex_int32_t yy_meta[18] =
438 1, 1, 2, 1, 1, 3, 1, 4, 1, 4,
442 static yyconst flex_int16_t yy_base[69] =
444 0, 0, 16, 30, 17, 18, 78, 77, 85, 88,
445 88, 88, 88, 88, 88, 0, 19, 88, 88, 88,
446 88, 88, 0, 24, 88, 75, 77, 0, 88, 21,
447 88, 76, 0, 22, 0, 0, 27, 75, 0, 71,
448 0, 29, 34, 88, 29, 65, 76, 0, 0, 63,
449 74, 60, 72, 56, 65, 51, 50, 88, 88, 88,
450 45, 49, 53, 55, 57, 61, 65, 69
453 static yyconst flex_int16_t yy_def[69] =
455 60, 1, 61, 61, 62, 62, 63, 63, 60, 60,
456 60, 60, 60, 60, 60, 64, 60, 60, 60, 60,
457 60, 60, 65, 65, 60, 65, 65, 66, 60, 67,
458 60, 60, 64, 60, 68, 65, 65, 65, 65, 65,
459 66, 67, 67, 60, 60, 60, 60, 68, 65, 60,
460 60, 60, 60, 60, 60, 60, 60, 60, 60, 0,
461 60, 60, 60, 60, 60, 60, 60, 60
464 static yyconst flex_int16_t yy_nxt[106] =
466 10, 10, 11, 12, 13, 14, 15, 16, 17, 16,
467 18, 19, 20, 10, 16, 21, 22, 24, 25, 29,
468 29, 26, 30, 30, 34, 37, 43, 35, 37, 44,
469 27, 24, 25, 46, 60, 26, 47, 60, 38, 43,
470 50, 38, 44, 51, 27, 23, 23, 23, 23, 28,
471 28, 28, 28, 31, 31, 31, 31, 36, 33, 36,
472 36, 41, 59, 58, 41, 42, 55, 42, 42, 48,
473 57, 48, 48, 53, 56, 55, 54, 53, 52, 49,
474 40, 45, 40, 39, 60, 32, 32, 9, 60, 60,
475 60, 60, 60, 60, 60, 60, 60, 60, 60, 60,
480 static yyconst flex_int16_t yy_chk[106] =
482 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
483 1, 1, 1, 1, 1, 1, 1, 3, 3, 5,
484 6, 3, 5, 6, 17, 24, 30, 17, 37, 30,
485 3, 4, 4, 34, 42, 4, 34, 42, 24, 43,
486 45, 37, 43, 45, 4, 61, 61, 61, 61, 62,
487 62, 62, 62, 63, 63, 63, 63, 65, 64, 65,
488 65, 66, 57, 56, 66, 67, 55, 67, 67, 68,
489 54, 68, 68, 53, 52, 51, 50, 47, 46, 40,
490 38, 32, 27, 26, 9, 8, 7, 60, 60, 60,
491 60, 60, 60, 60, 60, 60, 60, 60, 60, 60,
496 static yy_state_type yy_last_accepting_state;
497 static char *yy_last_accepting_cpos;
499 extern int gras_ddt_parse__flex_debug;
500 int gras_ddt_parse__flex_debug = 0;
502 /* The intent behind this definition is that it'll catch
503 * any uses of REJECT which flex missed.
505 #define REJECT reject_used_but_not_detected
506 #define yymore() yymore_used_but_not_detected
507 #define YY_MORE_ADJ 0
508 #define YY_RESTORE_YY_MORE_OFFSET
509 char *gras_ddt_parse_text;
511 /* DataDesc/ddt_parse -- automatic parsing of data structures */
512 /* Copyright (c) 2004 Arnaud Legrand, Martin Quinson. All rights reserved. */
513 /* This program is free software; you can redistribute it and/or modify it
514 * under the terms of the license (GNU LGPL) which comes with this package. */
515 #include "gras/DataDesc/datadesc_private.h"
516 #include "gras/DataDesc/ddt_parse.yy.h"
518 YY_BUFFER_STATE gras_ddt_input_buffer;
519 FILE *gras_ddt_file_to_parse;
521 int gras_ddt_parse_line_pos = 1;
522 int gras_ddt_parse_col_pos = 0;
523 int gras_ddt_parse_char_pos = 0;
524 int gras_ddt_parse_tok_num = 0;
525 const char *definition;
526 XBT_LOG_NEW_DEFAULT_SUBCATEGORY(gras_ddt_lexer,gras_ddt_parse,"The crude internals of the lexer used for type parsing");
527 #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)
534 #ifndef YY_NO_UNISTD_H
535 /* Special case for "unistd.h", since it is non-ANSI. We include it way
536 * down here because we want the user's section 1 to have been scanned first.
537 * The user has a chance to override it with an option.
542 #ifndef YY_EXTRA_TYPE
543 #define YY_EXTRA_TYPE void *
546 static int yy_init_globals (void );
548 /* Accessor methods to globals.
549 These are made visible to non-reentrant scanners for convenience. */
551 int gras_ddt_parse_lex_destroy (void );
553 int gras_ddt_parse_get_debug (void );
555 void gras_ddt_parse_set_debug (int debug_flag );
557 YY_EXTRA_TYPE gras_ddt_parse_get_extra (void );
559 void gras_ddt_parse_set_extra (YY_EXTRA_TYPE user_defined );
561 FILE *gras_ddt_parse_get_in (void );
563 void gras_ddt_parse_set_in (FILE * in_str );
565 FILE *gras_ddt_parse_get_out (void );
567 void gras_ddt_parse_set_out (FILE * out_str );
569 int gras_ddt_parse_get_leng (void );
571 char *gras_ddt_parse_get_text (void );
573 int gras_ddt_parse_get_lineno (void );
575 void gras_ddt_parse_set_lineno (int line_number );
577 /* Macros after this point can all be overridden by user definitions in
581 #ifndef YY_SKIP_YYWRAP
583 extern "C" int gras_ddt_parse_wrap (void );
585 extern int gras_ddt_parse_wrap (void );
589 static void yyunput (int c,char *buf_ptr );
592 static void yy_flex_strncpy (char *,yyconst char *,int );
595 #ifdef YY_NEED_STRLEN
596 static int yy_flex_strlen (yyconst char * );
602 static int yyinput (void );
604 static int input (void );
609 /* Amount of stuff to slurp up with each read. */
610 #ifndef YY_READ_BUF_SIZE
611 #define YY_READ_BUF_SIZE 8192
614 /* Copy whatever the last rule matched to the standard output. */
616 /* This used to be an fputs(), but since the string might contain NUL's,
617 * we now use fwrite().
619 #define ECHO do { if (fwrite( gras_ddt_parse_text, gras_ddt_parse_leng, 1, gras_ddt_parse_out )) {} } while (0)
622 /* Gets input and stuffs it into "buf". number of characters read, or YY_NULL,
623 * is returned in "result".
626 #define YY_INPUT(buf,result,max_size) \
627 if ( YY_CURRENT_BUFFER_LVALUE->yy_is_interactive ) \
631 for ( n = 0; n < max_size && \
632 (c = getc( gras_ddt_parse_in )) != EOF && c != '\n'; ++n ) \
635 buf[n++] = (char) c; \
636 if ( c == EOF && ferror( gras_ddt_parse_in ) ) \
637 YY_FATAL_ERROR( "input in flex scanner failed" ); \
643 while ( (result = fread(buf, 1, max_size, gras_ddt_parse_in))==0 && ferror(gras_ddt_parse_in)) \
645 if( errno != EINTR) \
647 YY_FATAL_ERROR( "input in flex scanner failed" ); \
651 clearerr(gras_ddt_parse_in); \
658 /* No semi-colon after return; correct usage is to write "yyterminate();" -
659 * we don't want an extra ';' after the "return" because that will cause
660 * some compilers to complain about unreachable statements.
663 #define yyterminate() return YY_NULL
666 /* Number of entries by which start-condition stack grows. */
667 #ifndef YY_START_STACK_INCR
668 #define YY_START_STACK_INCR 25
671 /* Report a fatal error. */
672 #ifndef YY_FATAL_ERROR
673 #define YY_FATAL_ERROR(msg) yy_fatal_error( msg )
676 /* end tables serialization structures and prototypes */
678 /* Default declaration of generated scanner - a define so the user can
679 * easily add parameters.
682 #define YY_DECL_IS_OURS 1
684 extern int gras_ddt_parse_lex (void);
686 #define YY_DECL int gras_ddt_parse_lex (void)
687 #endif /* !YY_DECL */
689 /* Code executed at the beginning of each rule, after gras_ddt_parse_text and gras_ddt_parse_leng
692 #ifndef YY_USER_ACTION
693 #define YY_USER_ACTION
696 /* Code executed at the end of each rule. */
698 #define YY_BREAK break;
701 #define YY_RULE_SETUP \
704 /** The main scanner function which does all the work.
708 register yy_state_type yy_current_state;
709 register char *yy_cp, *yy_bp;
712 int comment_caller=0;
713 int annotate_caller=0;
724 (yy_start) = 1; /* first start state */
726 if ( ! gras_ddt_parse_in )
727 gras_ddt_parse_in = stdin;
729 if ( ! gras_ddt_parse_out )
730 gras_ddt_parse_out = stdout;
732 if ( ! YY_CURRENT_BUFFER ) {
733 gras_ddt_parse_ensure_buffer_stack ();
734 YY_CURRENT_BUFFER_LVALUE =
735 gras_ddt_parse__create_buffer(gras_ddt_parse_in,YY_BUF_SIZE );
738 gras_ddt_parse__load_buffer_state( );
741 while ( 1 ) /* loops until end-of-file is reached */
743 yy_cp = (yy_c_buf_p);
745 /* Support of gras_ddt_parse_text. */
746 *yy_cp = (yy_hold_char);
748 /* yy_bp points to the position in yy_ch_buf of the start of
753 yy_current_state = (yy_start);
757 register YY_CHAR yy_c = yy_ec[YY_SC_TO_UI(*yy_cp)];
758 if ( yy_accept[yy_current_state] )
760 (yy_last_accepting_state) = yy_current_state;
761 (yy_last_accepting_cpos) = yy_cp;
763 while ( yy_chk[yy_base[yy_current_state] + yy_c] != yy_current_state )
765 yy_current_state = (int) yy_def[yy_current_state];
766 if ( yy_current_state >= 61 )
767 yy_c = yy_meta[(unsigned int) yy_c];
769 yy_current_state = yy_nxt[yy_base[yy_current_state] + (unsigned int) yy_c];
772 while ( yy_base[yy_current_state] != 88 );
775 yy_act = yy_accept[yy_current_state];
777 { /* have to back up */
778 yy_cp = (yy_last_accepting_cpos);
779 yy_current_state = (yy_last_accepting_state);
780 yy_act = yy_accept[yy_current_state];
785 do_action: /* This label is used only to access EOF actions. */
788 { /* beginning of action switch */
789 case 0: /* must back up */
790 /* undo the effects of YY_DO_BEFORE_ACTION */
791 *yy_cp = (yy_hold_char);
792 yy_cp = (yy_last_accepting_cpos);
793 yy_current_state = (yy_last_accepting_state);
802 { /****************** ANNOTATION ************************/
803 DEBUG0("Begin annotation");
804 annotate_caller = INITIAL;
805 gras_ddt_parse_char_pos+= strlen(gras_ddt_parse_text);
806 gras_ddt_parse_col_pos+= strlen(gras_ddt_parse_text);
812 { /* trim annotation */
813 DEBUG0("Begin annotation");
814 annotate_caller = foo;
815 gras_ddt_parse_char_pos+= strlen(gras_ddt_parse_text);
816 gras_ddt_parse_col_pos+= strlen(gras_ddt_parse_text);
823 DEBUG0("End annotation");
824 gras_ddt_parse_char_pos+= strlen(gras_ddt_parse_text);
825 gras_ddt_parse_col_pos+= strlen(gras_ddt_parse_text);
826 BEGIN(annotate_caller);
832 PARSE_ERROR0("``/*g'' construct closed by a regular ``*/''");
836 /* rule 6 can match eol */
839 PARSE_ERROR0("Type annotation cannot spread over several lines");
845 gras_ddt_parse_char_pos+= strlen(gras_ddt_parse_text);
846 gras_ddt_parse_col_pos+= strlen(gras_ddt_parse_text);
847 return GRAS_DDT_PARSE_TOKEN_ANNOTATE;
852 { /****************** COMMENTS ************************/
853 /* constructs like : */
855 /* are not comments but size annotations */
856 comment_caller = INITIAL;
863 comment_caller = foo;
869 { /* eat anything that's not a '*' */
874 { /* eat up '*'s not followed by '/'s */
878 /* rule 12 can match eol */
881 ++gras_ddt_parse_line_pos;
882 gras_ddt_parse_col_pos=0;
883 gras_ddt_parse_char_pos++;
889 gras_ddt_parse_char_pos+= strlen(gras_ddt_parse_text);
890 gras_ddt_parse_col_pos+= strlen(gras_ddt_parse_text);
891 BEGIN(comment_caller);
896 { /****************** STATEMENTS ************************/
897 gras_ddt_parse_char_pos += strlen(gras_ddt_parse_text);
898 gras_ddt_parse_col_pos += strlen(gras_ddt_parse_text);
900 return(GRAS_DDT_PARSE_TOKEN_WORD);
906 gras_ddt_parse_char_pos++;
907 gras_ddt_parse_col_pos++;
909 return(GRAS_DDT_PARSE_TOKEN_LA);
915 gras_ddt_parse_char_pos++;
916 gras_ddt_parse_col_pos++;
918 return(GRAS_DDT_PARSE_TOKEN_RA);
924 gras_ddt_parse_char_pos++;
925 gras_ddt_parse_col_pos++;
927 return(GRAS_DDT_PARSE_TOKEN_LB);
933 gras_ddt_parse_char_pos++;
934 gras_ddt_parse_col_pos++;
936 return(GRAS_DDT_PARSE_TOKEN_RB);
942 gras_ddt_parse_char_pos++;
943 gras_ddt_parse_col_pos++;
945 return(GRAS_DDT_PARSE_TOKEN_LP);
951 gras_ddt_parse_char_pos++;
952 gras_ddt_parse_col_pos++;
954 return(GRAS_DDT_PARSE_TOKEN_RP);
960 gras_ddt_parse_char_pos++;
961 gras_ddt_parse_col_pos++;
963 return(GRAS_DDT_PARSE_TOKEN_STAR);
969 gras_ddt_parse_char_pos++;
970 gras_ddt_parse_col_pos++;
972 return(GRAS_DDT_PARSE_TOKEN_SEMI_COLON);
978 gras_ddt_parse_char_pos++;
979 gras_ddt_parse_col_pos++;
981 return(GRAS_DDT_PARSE_TOKEN_COLON);
985 /* rule 24 can match eol */
988 gras_ddt_parse_line_pos++;
989 gras_ddt_parse_char_pos++;
990 gras_ddt_parse_col_pos=0;
997 gras_ddt_parse_char_pos++;
998 gras_ddt_parse_col_pos++;
1006 case YY_STATE_EOF(INITIAL):
1007 case YY_STATE_EOF(annotate):
1008 case YY_STATE_EOF(comment):
1009 case YY_STATE_EOF(foo):
1012 case YY_END_OF_BUFFER:
1014 /* Amount of text matched not including the EOB char. */
1015 int yy_amount_of_matched_text = (int) (yy_cp - (yytext_ptr)) - 1;
1017 /* Undo the effects of YY_DO_BEFORE_ACTION. */
1018 *yy_cp = (yy_hold_char);
1019 YY_RESTORE_YY_MORE_OFFSET
1021 if ( YY_CURRENT_BUFFER_LVALUE->yy_buffer_status == YY_BUFFER_NEW )
1023 /* We're scanning a new file or input source. It's
1024 * possible that this happened because the user
1025 * just pointed gras_ddt_parse_in at a new source and called
1026 * gras_ddt_parse_lex(). If so, then we have to assure
1027 * consistency between YY_CURRENT_BUFFER and our
1028 * globals. Here is the right place to do so, because
1029 * this is the first action (other than possibly a
1030 * back-up) that will match for the new input source.
1032 (yy_n_chars) = YY_CURRENT_BUFFER_LVALUE->yy_n_chars;
1033 YY_CURRENT_BUFFER_LVALUE->yy_input_file = gras_ddt_parse_in;
1034 YY_CURRENT_BUFFER_LVALUE->yy_buffer_status = YY_BUFFER_NORMAL;
1037 /* Note that here we test for yy_c_buf_p "<=" to the position
1038 * of the first EOB in the buffer, since yy_c_buf_p will
1039 * already have been incremented past the NUL character
1040 * (since all states make transitions on EOB to the
1041 * end-of-buffer state). Contrast this with the test
1044 if ( (yy_c_buf_p) <= &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[(yy_n_chars)] )
1045 { /* This was really a NUL. */
1046 yy_state_type yy_next_state;
1048 (yy_c_buf_p) = (yytext_ptr) + yy_amount_of_matched_text;
1050 yy_current_state = yy_get_previous_state( );
1052 /* Okay, we're now positioned to make the NUL
1053 * transition. We couldn't have
1054 * yy_get_previous_state() go ahead and do it
1055 * for us because it doesn't know how to deal
1056 * with the possibility of jamming (and we don't
1057 * want to build jamming into it because then it
1058 * will run more slowly).
1061 yy_next_state = yy_try_NUL_trans( yy_current_state );
1063 yy_bp = (yytext_ptr) + YY_MORE_ADJ;
1065 if ( yy_next_state )
1067 /* Consume the NUL. */
1068 yy_cp = ++(yy_c_buf_p);
1069 yy_current_state = yy_next_state;
1075 yy_cp = (yy_c_buf_p);
1076 goto yy_find_action;
1080 else switch ( yy_get_next_buffer( ) )
1082 case EOB_ACT_END_OF_FILE:
1084 (yy_did_buffer_switch_on_eof) = 0;
1086 if ( gras_ddt_parse_wrap( ) )
1088 /* Note: because we've taken care in
1089 * yy_get_next_buffer() to have set up
1090 * gras_ddt_parse_text, we can now set up
1091 * yy_c_buf_p so that if some total
1092 * hoser (like flex itself) wants to
1093 * call the scanner after we return the
1094 * YY_NULL, it'll still work - another
1095 * YY_NULL will get returned.
1097 (yy_c_buf_p) = (yytext_ptr) + YY_MORE_ADJ;
1099 yy_act = YY_STATE_EOF(YY_START);
1105 if ( ! (yy_did_buffer_switch_on_eof) )
1111 case EOB_ACT_CONTINUE_SCAN:
1113 (yytext_ptr) + yy_amount_of_matched_text;
1115 yy_current_state = yy_get_previous_state( );
1117 yy_cp = (yy_c_buf_p);
1118 yy_bp = (yytext_ptr) + YY_MORE_ADJ;
1121 case EOB_ACT_LAST_MATCH:
1123 &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[(yy_n_chars)];
1125 yy_current_state = yy_get_previous_state( );
1127 yy_cp = (yy_c_buf_p);
1128 yy_bp = (yytext_ptr) + YY_MORE_ADJ;
1129 goto yy_find_action;
1136 "fatal flex scanner internal error--no action found" );
1137 } /* end of action switch */
1138 } /* end of scanning one token */
1139 } /* end of gras_ddt_parse_lex */
1141 /* yy_get_next_buffer - try to read in a new buffer
1143 * Returns a code representing an action:
1144 * EOB_ACT_LAST_MATCH -
1145 * EOB_ACT_CONTINUE_SCAN - continue scanning from current position
1146 * EOB_ACT_END_OF_FILE - end of file
1148 static int yy_get_next_buffer (void)
1150 register char *dest = YY_CURRENT_BUFFER_LVALUE->yy_ch_buf;
1151 register char *source = (yytext_ptr);
1152 register int number_to_move, i;
1155 if ( (yy_c_buf_p) > &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[(yy_n_chars) + 1] )
1157 "fatal flex scanner internal error--end of buffer missed" );
1159 if ( YY_CURRENT_BUFFER_LVALUE->yy_fill_buffer == 0 )
1160 { /* Don't try to fill the buffer, so this is an EOF. */
1161 if ( (yy_c_buf_p) - (yytext_ptr) - YY_MORE_ADJ == 1 )
1163 /* We matched a single character, the EOB, so
1164 * treat this as a final EOF.
1166 return EOB_ACT_END_OF_FILE;
1171 /* We matched some text prior to the EOB, first
1174 return EOB_ACT_LAST_MATCH;
1178 /* Try to read more data. */
1180 /* First move last chars to start of buffer. */
1181 number_to_move = (int) ((yy_c_buf_p) - (yytext_ptr)) - 1;
1183 for ( i = 0; i < number_to_move; ++i )
1184 *(dest++) = *(source++);
1186 if ( YY_CURRENT_BUFFER_LVALUE->yy_buffer_status == YY_BUFFER_EOF_PENDING )
1187 /* don't do the read, it's not guaranteed to return an EOF,
1190 YY_CURRENT_BUFFER_LVALUE->yy_n_chars = (yy_n_chars) = 0;
1195 YY_CURRENT_BUFFER_LVALUE->yy_buf_size - number_to_move - 1;
1197 while ( num_to_read <= 0 )
1198 { /* Not enough room in the buffer - grow it. */
1200 /* just a shorter name for the current buffer */
1201 YY_BUFFER_STATE b = YY_CURRENT_BUFFER;
1203 int yy_c_buf_p_offset =
1204 (int) ((yy_c_buf_p) - b->yy_ch_buf);
1206 if ( b->yy_is_our_buffer )
1208 int new_size = b->yy_buf_size * 2;
1210 if ( new_size <= 0 )
1211 b->yy_buf_size += b->yy_buf_size / 8;
1213 b->yy_buf_size *= 2;
1215 b->yy_ch_buf = (char *)
1216 /* Include room in for 2 EOB chars. */
1217 gras_ddt_parse_realloc((void *) b->yy_ch_buf,b->yy_buf_size + 2 );
1220 /* Can't grow it, we don't own it. */
1223 if ( ! b->yy_ch_buf )
1225 "fatal error - scanner input buffer overflow" );
1227 (yy_c_buf_p) = &b->yy_ch_buf[yy_c_buf_p_offset];
1229 num_to_read = YY_CURRENT_BUFFER_LVALUE->yy_buf_size -
1234 if ( num_to_read > YY_READ_BUF_SIZE )
1235 num_to_read = YY_READ_BUF_SIZE;
1237 /* Read in more data. */
1238 YY_INPUT( (&YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[number_to_move]),
1239 (yy_n_chars), (size_t) num_to_read );
1241 YY_CURRENT_BUFFER_LVALUE->yy_n_chars = (yy_n_chars);
1244 if ( (yy_n_chars) == 0 )
1246 if ( number_to_move == YY_MORE_ADJ )
1248 ret_val = EOB_ACT_END_OF_FILE;
1249 gras_ddt_parse_restart(gras_ddt_parse_in );
1254 ret_val = EOB_ACT_LAST_MATCH;
1255 YY_CURRENT_BUFFER_LVALUE->yy_buffer_status =
1256 YY_BUFFER_EOF_PENDING;
1261 ret_val = EOB_ACT_CONTINUE_SCAN;
1263 if ((yy_size_t) ((yy_n_chars) + number_to_move) > YY_CURRENT_BUFFER_LVALUE->yy_buf_size) {
1264 /* Extend the array by 50%, plus the number we really need. */
1265 yy_size_t new_size = (yy_n_chars) + number_to_move + ((yy_n_chars) >> 1);
1266 YY_CURRENT_BUFFER_LVALUE->yy_ch_buf = (char *) gras_ddt_parse_realloc((void *) YY_CURRENT_BUFFER_LVALUE->yy_ch_buf,new_size );
1267 if ( ! YY_CURRENT_BUFFER_LVALUE->yy_ch_buf )
1268 YY_FATAL_ERROR( "out of dynamic memory in yy_get_next_buffer()" );
1271 (yy_n_chars) += number_to_move;
1272 YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[(yy_n_chars)] = YY_END_OF_BUFFER_CHAR;
1273 YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[(yy_n_chars) + 1] = YY_END_OF_BUFFER_CHAR;
1275 (yytext_ptr) = &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[0];
1280 /* yy_get_previous_state - get the state just before the EOB char was reached */
1282 static yy_state_type yy_get_previous_state (void)
1284 register yy_state_type yy_current_state;
1285 register char *yy_cp;
1287 yy_current_state = (yy_start);
1289 for ( yy_cp = (yytext_ptr) + YY_MORE_ADJ; yy_cp < (yy_c_buf_p); ++yy_cp )
1291 register YY_CHAR yy_c = (*yy_cp ? yy_ec[YY_SC_TO_UI(*yy_cp)] : 1);
1292 if ( yy_accept[yy_current_state] )
1294 (yy_last_accepting_state) = yy_current_state;
1295 (yy_last_accepting_cpos) = yy_cp;
1297 while ( yy_chk[yy_base[yy_current_state] + yy_c] != yy_current_state )
1299 yy_current_state = (int) yy_def[yy_current_state];
1300 if ( yy_current_state >= 61 )
1301 yy_c = yy_meta[(unsigned int) yy_c];
1303 yy_current_state = yy_nxt[yy_base[yy_current_state] + (unsigned int) yy_c];
1306 return yy_current_state;
1309 /* yy_try_NUL_trans - try to make a transition on the NUL character
1312 * next_state = yy_try_NUL_trans( current_state );
1314 static yy_state_type yy_try_NUL_trans (yy_state_type yy_current_state )
1316 register int yy_is_jam;
1317 register char *yy_cp = (yy_c_buf_p);
1319 register YY_CHAR yy_c = 1;
1320 if ( yy_accept[yy_current_state] )
1322 (yy_last_accepting_state) = yy_current_state;
1323 (yy_last_accepting_cpos) = yy_cp;
1325 while ( yy_chk[yy_base[yy_current_state] + yy_c] != yy_current_state )
1327 yy_current_state = (int) yy_def[yy_current_state];
1328 if ( yy_current_state >= 61 )
1329 yy_c = yy_meta[(unsigned int) yy_c];
1331 yy_current_state = yy_nxt[yy_base[yy_current_state] + (unsigned int) yy_c];
1332 yy_is_jam = (yy_current_state == 60);
1334 return yy_is_jam ? 0 : yy_current_state;
1337 static void yyunput (int c, register char * yy_bp )
1339 register char *yy_cp;
1341 yy_cp = (yy_c_buf_p);
1343 /* undo effects of setting up gras_ddt_parse_text */
1344 *yy_cp = (yy_hold_char);
1346 if ( yy_cp < YY_CURRENT_BUFFER_LVALUE->yy_ch_buf + 2 )
1347 { /* need to shift things up to make room */
1348 /* +2 for EOB chars. */
1349 register int number_to_move = (yy_n_chars) + 2;
1350 register char *dest = &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[
1351 YY_CURRENT_BUFFER_LVALUE->yy_buf_size + 2];
1352 register char *source =
1353 &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[number_to_move];
1355 while ( source > YY_CURRENT_BUFFER_LVALUE->yy_ch_buf )
1356 *--dest = *--source;
1358 yy_cp += (int) (dest - source);
1359 yy_bp += (int) (dest - source);
1360 YY_CURRENT_BUFFER_LVALUE->yy_n_chars =
1361 (yy_n_chars) = YY_CURRENT_BUFFER_LVALUE->yy_buf_size;
1363 if ( yy_cp < YY_CURRENT_BUFFER_LVALUE->yy_ch_buf + 2 )
1364 YY_FATAL_ERROR( "flex scanner push-back overflow" );
1367 *--yy_cp = (char) c;
1369 (yytext_ptr) = yy_bp;
1370 (yy_hold_char) = *yy_cp;
1371 (yy_c_buf_p) = yy_cp;
1376 static int yyinput (void)
1378 static int input (void)
1384 *(yy_c_buf_p) = (yy_hold_char);
1386 if ( *(yy_c_buf_p) == YY_END_OF_BUFFER_CHAR )
1388 /* yy_c_buf_p now points to the character we want to return.
1389 * If this occurs *before* the EOB characters, then it's a
1390 * valid NUL; if not, then we've hit the end of the buffer.
1392 if ( (yy_c_buf_p) < &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[(yy_n_chars)] )
1393 /* This was really a NUL. */
1394 *(yy_c_buf_p) = '\0';
1397 { /* need more input */
1398 int offset = (yy_c_buf_p) - (yytext_ptr);
1401 switch ( yy_get_next_buffer( ) )
1403 case EOB_ACT_LAST_MATCH:
1404 /* This happens because yy_g_n_b()
1405 * sees that we've accumulated a
1406 * token and flags that we need to
1407 * try matching the token before
1408 * proceeding. But for input(),
1409 * there's no matching to consider.
1410 * So convert the EOB_ACT_LAST_MATCH
1411 * to EOB_ACT_END_OF_FILE.
1414 /* Reset buffer status. */
1415 gras_ddt_parse_restart(gras_ddt_parse_in );
1419 case EOB_ACT_END_OF_FILE:
1421 if ( gras_ddt_parse_wrap( ) )
1424 if ( ! (yy_did_buffer_switch_on_eof) )
1433 case EOB_ACT_CONTINUE_SCAN:
1434 (yy_c_buf_p) = (yytext_ptr) + offset;
1440 c = *(unsigned char *) (yy_c_buf_p); /* cast for 8-bit char's */
1441 *(yy_c_buf_p) = '\0'; /* preserve gras_ddt_parse_text */
1442 (yy_hold_char) = *++(yy_c_buf_p);
1446 #endif /* ifndef YY_NO_INPUT */
1448 /** Immediately switch to a different input stream.
1449 * @param input_file A readable stream.
1451 * @note This function does not reset the start condition to @c INITIAL .
1453 void gras_ddt_parse_restart (FILE * input_file )
1456 if ( ! YY_CURRENT_BUFFER ){
1457 gras_ddt_parse_ensure_buffer_stack ();
1458 YY_CURRENT_BUFFER_LVALUE =
1459 gras_ddt_parse__create_buffer(gras_ddt_parse_in,YY_BUF_SIZE );
1462 gras_ddt_parse__init_buffer(YY_CURRENT_BUFFER,input_file );
1463 gras_ddt_parse__load_buffer_state( );
1466 /** Switch to a different input buffer.
1467 * @param new_buffer The new input buffer.
1470 void gras_ddt_parse__switch_to_buffer (YY_BUFFER_STATE new_buffer )
1473 /* TODO. We should be able to replace this entire function body
1475 * gras_ddt_parse_pop_buffer_state();
1476 * gras_ddt_parse_push_buffer_state(new_buffer);
1478 gras_ddt_parse_ensure_buffer_stack ();
1479 if ( YY_CURRENT_BUFFER == new_buffer )
1482 if ( YY_CURRENT_BUFFER )
1484 /* Flush out information for old buffer. */
1485 *(yy_c_buf_p) = (yy_hold_char);
1486 YY_CURRENT_BUFFER_LVALUE->yy_buf_pos = (yy_c_buf_p);
1487 YY_CURRENT_BUFFER_LVALUE->yy_n_chars = (yy_n_chars);
1490 YY_CURRENT_BUFFER_LVALUE = new_buffer;
1491 gras_ddt_parse__load_buffer_state( );
1493 /* We don't actually know whether we did this switch during
1494 * EOF (gras_ddt_parse_wrap()) processing, but the only time this flag
1495 * is looked at is after gras_ddt_parse_wrap() is called, so it's safe
1496 * to go ahead and always set it.
1498 (yy_did_buffer_switch_on_eof) = 1;
1501 static void gras_ddt_parse__load_buffer_state (void)
1503 (yy_n_chars) = YY_CURRENT_BUFFER_LVALUE->yy_n_chars;
1504 (yytext_ptr) = (yy_c_buf_p) = YY_CURRENT_BUFFER_LVALUE->yy_buf_pos;
1505 gras_ddt_parse_in = YY_CURRENT_BUFFER_LVALUE->yy_input_file;
1506 (yy_hold_char) = *(yy_c_buf_p);
1509 /** Allocate and initialize an input buffer state.
1510 * @param file A readable stream.
1511 * @param size The character buffer size in bytes. When in doubt, use @c YY_BUF_SIZE.
1513 * @return the allocated buffer state.
1515 YY_BUFFER_STATE gras_ddt_parse__create_buffer (FILE * file, int size )
1519 b = (YY_BUFFER_STATE) gras_ddt_parse_alloc(sizeof( struct yy_buffer_state ) );
1521 YY_FATAL_ERROR( "out of dynamic memory in gras_ddt_parse__create_buffer()" );
1523 b->yy_buf_size = size;
1525 /* yy_ch_buf has to be 2 characters longer than the size given because
1526 * we need to put in 2 end-of-buffer characters.
1528 b->yy_ch_buf = (char *) gras_ddt_parse_alloc(b->yy_buf_size + 2 );
1529 if ( ! b->yy_ch_buf )
1530 YY_FATAL_ERROR( "out of dynamic memory in gras_ddt_parse__create_buffer()" );
1532 b->yy_is_our_buffer = 1;
1534 gras_ddt_parse__init_buffer(b,file );
1539 /** Destroy the buffer.
1540 * @param b a buffer created with gras_ddt_parse__create_buffer()
1543 void gras_ddt_parse__delete_buffer (YY_BUFFER_STATE b )
1549 if ( b == YY_CURRENT_BUFFER ) /* Not sure if we should pop here. */
1550 YY_CURRENT_BUFFER_LVALUE = (YY_BUFFER_STATE) 0;
1552 if ( b->yy_is_our_buffer )
1553 gras_ddt_parse_free((void *) b->yy_ch_buf );
1555 gras_ddt_parse_free((void *) b );
1558 #if !defined(__cplusplus) && !defined(WIN32)
1559 extern int isatty (int );
1560 #endif /* __cplusplus */
1562 /* Initializes or reinitializes a buffer.
1563 * This function is sometimes called more than once on the same buffer,
1564 * such as during a gras_ddt_parse_restart() or at EOF.
1566 static void gras_ddt_parse__init_buffer (YY_BUFFER_STATE b, FILE * file )
1571 gras_ddt_parse__flush_buffer(b );
1573 b->yy_input_file = file;
1574 b->yy_fill_buffer = 1;
1576 /* If b is the current buffer, then gras_ddt_parse__init_buffer was _probably_
1577 * called from gras_ddt_parse_restart() or through yy_get_next_buffer.
1578 * In that case, we don't want to reset the lineno or column.
1580 if (b != YY_CURRENT_BUFFER){
1581 b->yy_bs_lineno = 1;
1582 b->yy_bs_column = 0;
1585 b->yy_is_interactive = file ? (isatty( fileno(file) ) > 0) : 0;
1590 /** Discard all buffered characters. On the next scan, YY_INPUT will be called.
1591 * @param b the buffer state to be flushed, usually @c YY_CURRENT_BUFFER.
1594 void gras_ddt_parse__flush_buffer (YY_BUFFER_STATE b )
1601 /* We always need two end-of-buffer characters. The first causes
1602 * a transition to the end-of-buffer state. The second causes
1603 * a jam in that state.
1605 b->yy_ch_buf[0] = YY_END_OF_BUFFER_CHAR;
1606 b->yy_ch_buf[1] = YY_END_OF_BUFFER_CHAR;
1608 b->yy_buf_pos = &b->yy_ch_buf[0];
1611 b->yy_buffer_status = YY_BUFFER_NEW;
1613 if ( b == YY_CURRENT_BUFFER )
1614 gras_ddt_parse__load_buffer_state( );
1617 /** Pushes the new state onto the stack. The new state becomes
1618 * the current state. This function will allocate the stack
1620 * @param new_buffer The new state.
1623 void gras_ddt_parse_push_buffer_state (YY_BUFFER_STATE new_buffer )
1625 if (new_buffer == NULL)
1628 gras_ddt_parse_ensure_buffer_stack();
1630 /* This block is copied from gras_ddt_parse__switch_to_buffer. */
1631 if ( YY_CURRENT_BUFFER )
1633 /* Flush out information for old buffer. */
1634 *(yy_c_buf_p) = (yy_hold_char);
1635 YY_CURRENT_BUFFER_LVALUE->yy_buf_pos = (yy_c_buf_p);
1636 YY_CURRENT_BUFFER_LVALUE->yy_n_chars = (yy_n_chars);
1639 /* Only push if top exists. Otherwise, replace top. */
1640 if (YY_CURRENT_BUFFER)
1641 (yy_buffer_stack_top)++;
1642 YY_CURRENT_BUFFER_LVALUE = new_buffer;
1644 /* copied from gras_ddt_parse__switch_to_buffer. */
1645 gras_ddt_parse__load_buffer_state( );
1646 (yy_did_buffer_switch_on_eof) = 1;
1649 /** Removes and deletes the top of the stack, if present.
1650 * The next element becomes the new top.
1653 void gras_ddt_parse_pop_buffer_state (void)
1655 if (!YY_CURRENT_BUFFER)
1658 gras_ddt_parse__delete_buffer(YY_CURRENT_BUFFER );
1659 YY_CURRENT_BUFFER_LVALUE = NULL;
1660 if ((yy_buffer_stack_top) > 0)
1661 --(yy_buffer_stack_top);
1663 if (YY_CURRENT_BUFFER) {
1664 gras_ddt_parse__load_buffer_state( );
1665 (yy_did_buffer_switch_on_eof) = 1;
1669 /* Allocates the stack if it does not exist.
1670 * Guarantees space for at least one push.
1672 static void gras_ddt_parse_ensure_buffer_stack (void)
1676 if (!(yy_buffer_stack)) {
1678 /* First allocation is just for 2 elements, since we don't know if this
1679 * scanner will even need a stack. We use 2 instead of 1 to avoid an
1680 * immediate realloc on the next call.
1683 (yy_buffer_stack) = (struct yy_buffer_state**)gras_ddt_parse_alloc
1684 (num_to_alloc * sizeof(struct yy_buffer_state*)
1686 if ( ! (yy_buffer_stack) )
1687 YY_FATAL_ERROR( "out of dynamic memory in gras_ddt_parse_ensure_buffer_stack()" );
1689 memset((yy_buffer_stack), 0, num_to_alloc * sizeof(struct yy_buffer_state*));
1691 (yy_buffer_stack_max) = num_to_alloc;
1692 (yy_buffer_stack_top) = 0;
1696 if ((yy_buffer_stack_top) >= ((yy_buffer_stack_max)) - 1){
1698 /* Increase the buffer to prepare for a possible push. */
1699 int grow_size = 8 /* arbitrary grow size */;
1701 num_to_alloc = (yy_buffer_stack_max) + grow_size;
1702 (yy_buffer_stack) = (struct yy_buffer_state**)gras_ddt_parse_realloc
1704 num_to_alloc * sizeof(struct yy_buffer_state*)
1706 if ( ! (yy_buffer_stack) )
1707 YY_FATAL_ERROR( "out of dynamic memory in gras_ddt_parse_ensure_buffer_stack()" );
1709 /* zero only the new slots.*/
1710 memset((yy_buffer_stack) + (yy_buffer_stack_max), 0, grow_size * sizeof(struct yy_buffer_state*));
1711 (yy_buffer_stack_max) = num_to_alloc;
1715 /** Setup the input buffer state to scan directly from a user-specified character buffer.
1716 * @param base the character buffer
1717 * @param size the size in bytes of the character buffer
1719 * @return the newly allocated buffer state object.
1721 YY_BUFFER_STATE gras_ddt_parse__scan_buffer (char * base, yy_size_t size )
1726 base[size-2] != YY_END_OF_BUFFER_CHAR ||
1727 base[size-1] != YY_END_OF_BUFFER_CHAR )
1728 /* They forgot to leave room for the EOB's. */
1731 b = (YY_BUFFER_STATE) gras_ddt_parse_alloc(sizeof( struct yy_buffer_state ) );
1733 YY_FATAL_ERROR( "out of dynamic memory in gras_ddt_parse__scan_buffer()" );
1735 b->yy_buf_size = size - 2; /* "- 2" to take care of EOB's */
1736 b->yy_buf_pos = b->yy_ch_buf = base;
1737 b->yy_is_our_buffer = 0;
1738 b->yy_input_file = 0;
1739 b->yy_n_chars = b->yy_buf_size;
1740 b->yy_is_interactive = 0;
1742 b->yy_fill_buffer = 0;
1743 b->yy_buffer_status = YY_BUFFER_NEW;
1745 gras_ddt_parse__switch_to_buffer(b );
1750 /** Setup the input buffer state to scan a string. The next call to gras_ddt_parse_lex() will
1751 * scan from a @e copy of @a str.
1752 * @param yystr a NUL-terminated string to scan
1754 * @return the newly allocated buffer state object.
1755 * @note If you want to scan bytes that may contain NUL values, then use
1756 * gras_ddt_parse__scan_bytes() instead.
1758 YY_BUFFER_STATE gras_ddt_parse__scan_string (yyconst char * yystr )
1761 return gras_ddt_parse__scan_bytes(yystr,strlen(yystr) );
1764 /** Setup the input buffer state to scan the given bytes. The next call to gras_ddt_parse_lex() will
1765 * scan from a @e copy of @a bytes.
1766 * @param bytes the byte buffer to scan
1767 * @param len the number of bytes in the buffer pointed to by @a bytes.
1769 * @return the newly allocated buffer state object.
1771 YY_BUFFER_STATE gras_ddt_parse__scan_bytes (yyconst char * yybytes, int _yybytes_len )
1778 /* Get memory for full buffer, including space for trailing EOB's. */
1779 n = _yybytes_len + 2;
1780 buf = (char *) gras_ddt_parse_alloc(n );
1782 YY_FATAL_ERROR( "out of dynamic memory in gras_ddt_parse__scan_bytes()" );
1784 for ( i = 0; i < _yybytes_len; ++i )
1785 buf[i] = yybytes[i];
1787 buf[_yybytes_len] = buf[_yybytes_len+1] = YY_END_OF_BUFFER_CHAR;
1789 b = gras_ddt_parse__scan_buffer(buf,n );
1791 YY_FATAL_ERROR( "bad buffer in gras_ddt_parse__scan_bytes()" );
1793 /* It's okay to grow etc. this buffer, and we should throw it
1794 * away when we're done.
1796 b->yy_is_our_buffer = 1;
1801 #ifndef YY_EXIT_FAILURE
1802 #define YY_EXIT_FAILURE 2
1805 static void yy_fatal_error (yyconst char* msg )
1807 (void) fprintf( stderr, "%s\n", msg );
1808 exit( YY_EXIT_FAILURE );
1811 /* Redefine yyless() so it works in section 3 code. */
1817 /* Undo effects of setting up gras_ddt_parse_text. */ \
1818 int yyless_macro_arg = (n); \
1819 YY_LESS_LINENO(yyless_macro_arg);\
1820 gras_ddt_parse_text[gras_ddt_parse_leng] = (yy_hold_char); \
1821 (yy_c_buf_p) = gras_ddt_parse_text + yyless_macro_arg; \
1822 (yy_hold_char) = *(yy_c_buf_p); \
1823 *(yy_c_buf_p) = '\0'; \
1824 gras_ddt_parse_leng = yyless_macro_arg; \
1828 /* Accessor methods (get/set functions) to struct members. */
1830 /** Get the current line number.
1833 int gras_ddt_parse_get_lineno (void)
1836 return gras_ddt_parse_lineno;
1839 /** Get the input stream.
1842 FILE *gras_ddt_parse_get_in (void)
1844 return gras_ddt_parse_in;
1847 /** Get the output stream.
1850 FILE *gras_ddt_parse_get_out (void)
1852 return gras_ddt_parse_out;
1855 /** Get the length of the current token.
1858 int gras_ddt_parse_get_leng (void)
1860 return gras_ddt_parse_leng;
1863 /** Get the current token.
1867 char *gras_ddt_parse_get_text (void)
1869 return gras_ddt_parse_text;
1872 /** Set the current line number.
1873 * @param line_number
1876 void gras_ddt_parse_set_lineno (int line_number )
1879 gras_ddt_parse_lineno = line_number;
1882 /** Set the input stream. This does not discard the current
1884 * @param in_str A readable stream.
1886 * @see gras_ddt_parse__switch_to_buffer
1888 void gras_ddt_parse_set_in (FILE * in_str )
1890 gras_ddt_parse_in = in_str ;
1893 void gras_ddt_parse_set_out (FILE * out_str )
1895 gras_ddt_parse_out = out_str ;
1898 int gras_ddt_parse_get_debug (void)
1900 return gras_ddt_parse__flex_debug;
1903 void gras_ddt_parse_set_debug (int bdebug )
1905 gras_ddt_parse__flex_debug = bdebug ;
1908 static int yy_init_globals (void)
1910 /* Initialization is the same as for the non-reentrant scanner.
1911 * This function is called from gras_ddt_parse_lex_destroy(), so don't allocate here.
1914 (yy_buffer_stack) = 0;
1915 (yy_buffer_stack_top) = 0;
1916 (yy_buffer_stack_max) = 0;
1917 (yy_c_buf_p) = (char *) 0;
1921 /* Defined in main.c */
1923 gras_ddt_parse_in = stdin;
1924 gras_ddt_parse_out = stdout;
1926 gras_ddt_parse_in = (FILE *) 0;
1927 gras_ddt_parse_out = (FILE *) 0;
1930 /* For future reference: Set errno on error, since we are called by
1931 * gras_ddt_parse_lex_init()
1936 /* gras_ddt_parse_lex_destroy is for both reentrant and non-reentrant scanners. */
1937 int gras_ddt_parse_lex_destroy (void)
1940 /* Pop the buffer stack, destroying each element. */
1941 while(YY_CURRENT_BUFFER){
1942 gras_ddt_parse__delete_buffer(YY_CURRENT_BUFFER );
1943 YY_CURRENT_BUFFER_LVALUE = NULL;
1944 gras_ddt_parse_pop_buffer_state();
1947 /* Destroy the stack itself. */
1948 gras_ddt_parse_free((yy_buffer_stack) );
1949 (yy_buffer_stack) = NULL;
1951 /* Reset the globals. This is important in a non-reentrant scanner so the next time
1952 * gras_ddt_parse_lex() is called, initialization will occur. */
1959 * Internal utility routines.
1963 static void yy_flex_strncpy (char* s1, yyconst char * s2, int n )
1966 for ( i = 0; i < n; ++i )
1971 #ifdef YY_NEED_STRLEN
1972 static int yy_flex_strlen (yyconst char * s )
1975 for ( n = 0; s[n]; ++n )
1982 void *gras_ddt_parse_alloc (yy_size_t size )
1984 return (void *) malloc( size );
1987 void *gras_ddt_parse_realloc (void * ptr, yy_size_t size )
1989 /* The cast to (char *) in the following accommodates both
1990 * implementations that use char* generic pointers, and those
1991 * that use void* generic pointers. It works with the latter
1992 * because both ANSI C and C++ allow castless assignment from
1993 * any pointer type to void*, and deal with argument conversions
1994 * as though doing an assignment.
1996 return (void *) realloc( (char *) ptr, size );
1999 void gras_ddt_parse_free (void * ptr )
2001 free( (char *) ptr ); /* see gras_ddt_parse_realloc() for (char *) cast */
2004 #define YYTABLES_NAME "yytables"
2006 /* {space}+ { return(TOKEN_SPACE);} */
2008 void gras_ddt_parse_dump(void) {
2009 switch(gras_ddt_parse_tok_num) {
2010 case GRAS_DDT_PARSE_TOKEN_LA : {printf("TOKEN_LA ");break;}
2011 case GRAS_DDT_PARSE_TOKEN_RA : {printf("TOKEN_RA ");break;}
2012 case GRAS_DDT_PARSE_TOKEN_WORD : {printf("TOKEN_WORD ");break;}
2013 /* case GRAS_DDT_PARSE_TOKEN_SPACE : {printf("TOKEN_SPACE ");break;}*/
2014 /* case GRAS_DDT_PARSE_TOKEN_COMMENT : {printf("TOKEN_COMMENT ");break;}*/
2015 case GRAS_DDT_PARSE_TOKEN_NEWLINE : {printf("TOKEN_NEWLINE\n");return;}
2016 case GRAS_DDT_PARSE_TOKEN_EMPTY : {printf("TOKEN_EMPTY\n");return;}
2017 default : {printf("Unknown token %d\n", gras_ddt_parse_tok_num);return;}
2019 printf("-->%s<-- [line %d, pos %d]\n",gras_ddt_parse_text,gras_ddt_parse_line_pos,gras_ddt_parse_char_pos);
2023 int gras_ddt_parse_lex_n_dump(void) {
2024 gras_ddt_parse_tok_num = gras_ddt_parse_lex();
2025 /* gras_ddt_parse_char_pos += strlen(gras_ddt_parse_text);*/
2026 return(gras_ddt_parse_tok_num);
2029 void gras_ddt_parse_pointer_init(const char *file) {
2030 gras_ddt_file_to_parse = fopen(file,"r");
2031 gras_ddt_input_buffer = gras_ddt_parse__create_buffer(gras_ddt_file_to_parse,10 );
2032 gras_ddt_parse__switch_to_buffer(gras_ddt_input_buffer);
2034 gras_ddt_parse_line_pos = 1;
2035 gras_ddt_parse_char_pos = 0;
2036 gras_ddt_parse_col_pos = 0;
2037 gras_ddt_parse_tok_num = 0;
2040 void gras_ddt_parse_pointer_close(void) {
2041 gras_ddt_parse__delete_buffer(gras_ddt_input_buffer);
2042 fclose(gras_ddt_file_to_parse);
2044 gras_ddt_parse_line_pos = 1;
2045 gras_ddt_parse_char_pos = 0;
2046 gras_ddt_parse_tok_num = 0;
2049 void gras_ddt_parse_pointer_string_init(const char *string_to_parse) {
2050 gras_ddt_input_buffer = gras_ddt_parse__scan_string (string_to_parse);
2051 definition = string_to_parse;
2052 gras_ddt_parse__switch_to_buffer(gras_ddt_input_buffer);
2054 gras_ddt_parse_line_pos = 1;
2055 gras_ddt_parse_char_pos = 0;
2056 gras_ddt_parse_tok_num = 0;
2059 void gras_ddt_parse_pointer_string_close(void) {
2060 gras_ddt_parse__delete_buffer(gras_ddt_input_buffer);
2062 gras_ddt_parse_line_pos = 1;
2063 gras_ddt_parse_char_pos = 0;
2064 gras_ddt_parse_tok_num = 0;
2067 yyunput('\0',NULL); /* fake a use of this function to calm gcc down */
2070 /* Local variables:*/