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. */
164 /* On IA-64, the buffer size is 16k, not 8k.
165 * Moreover, YY_BUF_SIZE is 2*YY_READ_BUF_SIZE in the general case.
166 * Ditto for the __ia64__ case accordingly.
168 #define YY_BUF_SIZE 32768
170 #define YY_BUF_SIZE 16384
171 #endif /* __ia64__ */
174 /* The state buf must be large enough to hold one state per character in the main buffer.
176 #define YY_STATE_BUF_SIZE ((YY_BUF_SIZE + 2) * sizeof(yy_state_type))
178 #ifndef YY_TYPEDEF_YY_BUFFER_STATE
179 #define YY_TYPEDEF_YY_BUFFER_STATE
180 typedef struct yy_buffer_state *YY_BUFFER_STATE;
183 extern int gras_ddt_parse_leng;
185 extern FILE *gras_ddt_parse_in, *gras_ddt_parse_out;
187 #define EOB_ACT_CONTINUE_SCAN 0
188 #define EOB_ACT_END_OF_FILE 1
189 #define EOB_ACT_LAST_MATCH 2
191 #define YY_LESS_LINENO(n)
193 /* Return all but the first "n" matched characters back to the input stream. */
197 /* Undo effects of setting up gras_ddt_parse_text. */ \
198 int yyless_macro_arg = (n); \
199 YY_LESS_LINENO(yyless_macro_arg);\
200 *yy_cp = (yy_hold_char); \
201 YY_RESTORE_YY_MORE_OFFSET \
202 (yy_c_buf_p) = yy_cp = yy_bp + yyless_macro_arg - YY_MORE_ADJ; \
203 YY_DO_BEFORE_ACTION; /* set up gras_ddt_parse_text again */ \
207 #define unput(c) yyunput( c, (yytext_ptr) )
209 #ifndef YY_TYPEDEF_YY_SIZE_T
210 #define YY_TYPEDEF_YY_SIZE_T
211 typedef size_t yy_size_t;
214 #ifndef YY_STRUCT_YY_BUFFER_STATE
215 #define YY_STRUCT_YY_BUFFER_STATE
216 struct yy_buffer_state
220 char *yy_ch_buf; /* input buffer */
221 char *yy_buf_pos; /* current position in input buffer */
223 /* Size of input buffer in bytes, not including room for EOB
226 yy_size_t yy_buf_size;
228 /* Number of characters read into yy_ch_buf, not including EOB
233 /* Whether we "own" the buffer - i.e., we know we created it,
234 * and can realloc() it to grow it, and should free() it to
237 int yy_is_our_buffer;
239 /* Whether this is an "interactive" input source; if so, and
240 * if we're using stdio for input, then we want to use getc()
241 * instead of fread(), to make sure we stop fetching input after
244 int yy_is_interactive;
246 /* Whether we're considered to be at the beginning of a line.
247 * If so, '^' rules will be active on the next match, otherwise
252 int yy_bs_lineno; /**< The line count. */
253 int yy_bs_column; /**< The column count. */
255 /* Whether to try to fill the input buffer when we reach the
260 int yy_buffer_status;
262 #define YY_BUFFER_NEW 0
263 #define YY_BUFFER_NORMAL 1
264 /* When an EOF's been seen but there's still some text to process
265 * then we mark the buffer as YY_EOF_PENDING, to indicate that we
266 * shouldn't try reading from the input source any more. We might
267 * still have a bunch of tokens to match, though, because of
268 * possible backing-up.
270 * When we actually see the EOF, we change the status to "new"
271 * (via gras_ddt_parse_restart()), so that the user can continue scanning by
272 * just pointing gras_ddt_parse_in at a new input file.
274 #define YY_BUFFER_EOF_PENDING 2
277 #endif /* !YY_STRUCT_YY_BUFFER_STATE */
279 /* Stack of input buffers. */
280 static size_t yy_buffer_stack_top = 0; /**< index of top of stack. */
281 static size_t yy_buffer_stack_max = 0; /**< capacity of stack. */
282 static YY_BUFFER_STATE * yy_buffer_stack = 0; /**< Stack as an array. */
284 /* We provide macros for accessing buffer states in case in the
285 * future we want to put the buffer states in a more general
288 * Returns the top of the stack, or NULL.
290 #define YY_CURRENT_BUFFER ( (yy_buffer_stack) \
291 ? (yy_buffer_stack)[(yy_buffer_stack_top)] \
294 /* Same as previous macro, but useful when we know that the buffer stack is not
295 * NULL or when we need an lvalue. For internal use only.
297 #define YY_CURRENT_BUFFER_LVALUE (yy_buffer_stack)[(yy_buffer_stack_top)]
299 /* yy_hold_char holds the character lost when gras_ddt_parse_text is formed. */
300 static char yy_hold_char;
301 static int yy_n_chars; /* number of characters read into yy_ch_buf */
302 int gras_ddt_parse_leng;
304 /* Points to current character in buffer. */
305 static char *yy_c_buf_p = (char *) 0;
306 static int yy_init = 0; /* whether we need to initialize */
307 static int yy_start = 0; /* start state number */
309 /* Flag which is used to allow gras_ddt_parse_wrap()'s to do buffer switches
310 * instead of setting up a fresh gras_ddt_parse_in. A bit of a hack ...
312 static int yy_did_buffer_switch_on_eof;
314 void gras_ddt_parse_restart (FILE *input_file );
315 void gras_ddt_parse__switch_to_buffer (YY_BUFFER_STATE new_buffer );
316 YY_BUFFER_STATE gras_ddt_parse__create_buffer (FILE *file,int size );
317 void gras_ddt_parse__delete_buffer (YY_BUFFER_STATE b );
318 void gras_ddt_parse__flush_buffer (YY_BUFFER_STATE b );
319 void gras_ddt_parse_push_buffer_state (YY_BUFFER_STATE new_buffer );
320 void gras_ddt_parse_pop_buffer_state (void );
322 static void gras_ddt_parse_ensure_buffer_stack (void );
323 static void gras_ddt_parse__load_buffer_state (void );
324 static void gras_ddt_parse__init_buffer (YY_BUFFER_STATE b,FILE *file );
326 #define YY_FLUSH_BUFFER gras_ddt_parse__flush_buffer(YY_CURRENT_BUFFER )
328 YY_BUFFER_STATE gras_ddt_parse__scan_buffer (char *base,yy_size_t size );
329 YY_BUFFER_STATE gras_ddt_parse__scan_string (yyconst char *yy_str );
330 YY_BUFFER_STATE gras_ddt_parse__scan_bytes (yyconst char *bytes,int len );
332 void *gras_ddt_parse_alloc (yy_size_t );
333 void *gras_ddt_parse_realloc (void *,yy_size_t );
334 void gras_ddt_parse_free (void * );
336 #define yy_new_buffer gras_ddt_parse__create_buffer
338 #define yy_set_interactive(is_interactive) \
340 if ( ! YY_CURRENT_BUFFER ){ \
341 gras_ddt_parse_ensure_buffer_stack (); \
342 YY_CURRENT_BUFFER_LVALUE = \
343 gras_ddt_parse__create_buffer(gras_ddt_parse_in,YY_BUF_SIZE ); \
345 YY_CURRENT_BUFFER_LVALUE->yy_is_interactive = is_interactive; \
348 #define yy_set_bol(at_bol) \
350 if ( ! YY_CURRENT_BUFFER ){\
351 gras_ddt_parse_ensure_buffer_stack (); \
352 YY_CURRENT_BUFFER_LVALUE = \
353 gras_ddt_parse__create_buffer(gras_ddt_parse_in,YY_BUF_SIZE ); \
355 YY_CURRENT_BUFFER_LVALUE->yy_at_bol = at_bol; \
358 #define YY_AT_BOL() (YY_CURRENT_BUFFER_LVALUE->yy_at_bol)
360 /* Begin user sect3 */
362 #define gras_ddt_parse_wrap(n) 1
363 #define YY_SKIP_YYWRAP
365 typedef unsigned char YY_CHAR;
367 FILE *gras_ddt_parse_in = (FILE *) 0, *gras_ddt_parse_out = (FILE *) 0;
369 typedef int yy_state_type;
371 extern int gras_ddt_parse_lineno;
373 int gras_ddt_parse_lineno = 1;
375 extern char *gras_ddt_parse_text;
376 #define yytext_ptr gras_ddt_parse_text
378 static yy_state_type yy_get_previous_state (void );
379 static yy_state_type yy_try_NUL_trans (yy_state_type current_state );
380 static int yy_get_next_buffer (void );
381 static void yy_fatal_error (yyconst char msg[] );
383 /* Done after the current pattern has been matched and before the
384 * corresponding action - sets up gras_ddt_parse_text.
386 #define YY_DO_BEFORE_ACTION \
387 (yytext_ptr) = yy_bp; \
388 gras_ddt_parse_leng = (size_t) (yy_cp - yy_bp); \
389 (yy_hold_char) = *yy_cp; \
391 (yy_c_buf_p) = yy_cp;
393 #define YY_NUM_RULES 26
394 #define YY_END_OF_BUFFER 27
395 /* This struct is not used in this scanner,
396 but its presence is necessary. */
399 flex_int32_t yy_verify;
402 static yyconst flex_int16_t yy_accept[61] =
404 14, 14, 7, 7, 10, 10, 0, 0, 27, 25,
405 24, 19, 20, 21, 23, 14, 25, 22, 17, 18,
406 15, 16, 7, 7, 6, 7, 7, 10, 12, 11,
407 26, 26, 14, 0, 1, 7, 7, 7, 5, 7,
408 10, 11, 11, 13, 0, 0, 2, 1, 4, 0,
409 3, 0, 2, 0, 3, 0, 0, 8, 9, 0
412 static yyconst flex_int32_t yy_ec[256] =
414 1, 1, 1, 1, 1, 1, 1, 1, 2, 3,
415 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
416 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
417 1, 2, 1, 1, 1, 1, 1, 1, 1, 4,
418 5, 6, 1, 7, 8, 8, 9, 10, 10, 10,
419 10, 10, 10, 10, 10, 10, 10, 1, 11, 1,
420 1, 1, 1, 1, 8, 8, 8, 8, 8, 8,
421 8, 8, 8, 8, 8, 8, 8, 8, 8, 8,
422 8, 8, 8, 8, 8, 8, 8, 8, 8, 8,
423 12, 1, 13, 14, 8, 1, 8, 8, 8, 8,
425 8, 8, 15, 8, 8, 8, 8, 8, 8, 8,
426 8, 8, 8, 8, 8, 8, 8, 8, 8, 8,
427 8, 8, 16, 1, 17, 1, 1, 1, 1, 1,
428 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
429 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
430 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
431 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
432 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
433 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
434 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
436 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
437 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
438 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
439 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
440 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
444 static yyconst flex_int32_t yy_meta[18] =
446 1, 1, 2, 1, 1, 3, 1, 4, 1, 4,
450 static yyconst flex_int16_t yy_base[69] =
452 0, 0, 16, 30, 17, 18, 78, 77, 85, 88,
453 88, 88, 88, 88, 88, 0, 19, 88, 88, 88,
454 88, 88, 0, 24, 88, 75, 77, 0, 88, 21,
455 88, 76, 0, 22, 0, 0, 27, 75, 0, 71,
456 0, 29, 34, 88, 29, 65, 76, 0, 0, 63,
457 74, 60, 72, 56, 65, 51, 50, 88, 88, 88,
458 45, 49, 53, 55, 57, 61, 65, 69
461 static yyconst flex_int16_t yy_def[69] =
463 60, 1, 61, 61, 62, 62, 63, 63, 60, 60,
464 60, 60, 60, 60, 60, 64, 60, 60, 60, 60,
465 60, 60, 65, 65, 60, 65, 65, 66, 60, 67,
466 60, 60, 64, 60, 68, 65, 65, 65, 65, 65,
467 66, 67, 67, 60, 60, 60, 60, 68, 65, 60,
468 60, 60, 60, 60, 60, 60, 60, 60, 60, 0,
469 60, 60, 60, 60, 60, 60, 60, 60
472 static yyconst flex_int16_t yy_nxt[106] =
474 10, 10, 11, 12, 13, 14, 15, 16, 17, 16,
475 18, 19, 20, 10, 16, 21, 22, 24, 25, 29,
476 29, 26, 30, 30, 34, 37, 43, 35, 37, 44,
477 27, 24, 25, 46, 60, 26, 47, 60, 38, 43,
478 50, 38, 44, 51, 27, 23, 23, 23, 23, 28,
479 28, 28, 28, 31, 31, 31, 31, 36, 33, 36,
480 36, 41, 59, 58, 41, 42, 55, 42, 42, 48,
481 57, 48, 48, 53, 56, 55, 54, 53, 52, 49,
482 40, 45, 40, 39, 60, 32, 32, 9, 60, 60,
483 60, 60, 60, 60, 60, 60, 60, 60, 60, 60,
488 static yyconst flex_int16_t yy_chk[106] =
490 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
491 1, 1, 1, 1, 1, 1, 1, 3, 3, 5,
492 6, 3, 5, 6, 17, 24, 30, 17, 37, 30,
493 3, 4, 4, 34, 42, 4, 34, 42, 24, 43,
494 45, 37, 43, 45, 4, 61, 61, 61, 61, 62,
495 62, 62, 62, 63, 63, 63, 63, 65, 64, 65,
496 65, 66, 57, 56, 66, 67, 55, 67, 67, 68,
497 54, 68, 68, 53, 52, 51, 50, 47, 46, 40,
498 38, 32, 27, 26, 9, 8, 7, 60, 60, 60,
499 60, 60, 60, 60, 60, 60, 60, 60, 60, 60,
504 static yy_state_type yy_last_accepting_state;
505 static char *yy_last_accepting_cpos;
507 extern int gras_ddt_parse__flex_debug;
508 int gras_ddt_parse__flex_debug = 0;
510 /* The intent behind this definition is that it'll catch
511 * any uses of REJECT which flex missed.
513 #define REJECT reject_used_but_not_detected
514 #define yymore() yymore_used_but_not_detected
515 #define YY_MORE_ADJ 0
516 #define YY_RESTORE_YY_MORE_OFFSET
517 char *gras_ddt_parse_text;
519 /* DataDesc/ddt_parse -- automatic parsing of data structures */
520 /* Copyright (c) 2004 Arnaud Legrand, Martin Quinson. All rights reserved. */
521 /* This program is free software; you can redistribute it and/or modify it
522 * under the terms of the license (GNU LGPL) which comes with this package. */
523 #include "gras/DataDesc/datadesc_private.h"
524 #include "gras/DataDesc/ddt_parse.yy.h"
526 YY_BUFFER_STATE gras_ddt_input_buffer;
527 FILE *gras_ddt_file_to_parse;
529 int gras_ddt_parse_line_pos = 1;
530 int gras_ddt_parse_col_pos = 0;
531 int gras_ddt_parse_char_pos = 0;
532 int gras_ddt_parse_tok_num = 0;
533 const char *definition;
534 XBT_LOG_NEW_DEFAULT_SUBCATEGORY(gras_ddt_lexer,gras_ddt_parse,"The crude internals of the lexer used for type parsing");
535 #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)
542 #ifndef YY_NO_UNISTD_H
543 /* Special case for "unistd.h", since it is non-ANSI. We include it way
544 * down here because we want the user's section 1 to have been scanned first.
545 * The user has a chance to override it with an option.
550 #ifndef YY_EXTRA_TYPE
551 #define YY_EXTRA_TYPE void *
554 static int yy_init_globals (void );
556 /* Accessor methods to globals.
557 These are made visible to non-reentrant scanners for convenience. */
559 int gras_ddt_parse_lex_destroy (void );
561 int gras_ddt_parse_get_debug (void );
563 void gras_ddt_parse_set_debug (int debug_flag );
565 YY_EXTRA_TYPE gras_ddt_parse_get_extra (void );
567 void gras_ddt_parse_set_extra (YY_EXTRA_TYPE user_defined );
569 FILE *gras_ddt_parse_get_in (void );
571 void gras_ddt_parse_set_in (FILE * in_str );
573 FILE *gras_ddt_parse_get_out (void );
575 void gras_ddt_parse_set_out (FILE * out_str );
577 int gras_ddt_parse_get_leng (void );
579 char *gras_ddt_parse_get_text (void );
581 int gras_ddt_parse_get_lineno (void );
583 void gras_ddt_parse_set_lineno (int line_number );
585 /* Macros after this point can all be overridden by user definitions in
589 #ifndef YY_SKIP_YYWRAP
591 extern "C" int gras_ddt_parse_wrap (void );
593 extern int gras_ddt_parse_wrap (void );
597 static void yyunput (int c,char *buf_ptr );
600 static void yy_flex_strncpy (char *,yyconst char *,int );
603 #ifdef YY_NEED_STRLEN
604 static int yy_flex_strlen (yyconst char * );
610 static int yyinput (void );
612 static int input (void );
617 /* Amount of stuff to slurp up with each read. */
618 #ifndef YY_READ_BUF_SIZE
620 /* On IA-64, the buffer size is 16k, not 8k */
621 #define YY_READ_BUF_SIZE 16384
623 #define YY_READ_BUF_SIZE 8192
624 #endif /* __ia64__ */
627 /* Copy whatever the last rule matched to the standard output. */
629 /* This used to be an fputs(), but since the string might contain NUL's,
630 * we now use fwrite().
632 #define ECHO do { if (fwrite( gras_ddt_parse_text, gras_ddt_parse_leng, 1, gras_ddt_parse_out )) {} } while (0)
635 /* Gets input and stuffs it into "buf". number of characters read, or YY_NULL,
636 * is returned in "result".
639 #define YY_INPUT(buf,result,max_size) \
640 if ( YY_CURRENT_BUFFER_LVALUE->yy_is_interactive ) \
644 for ( n = 0; n < max_size && \
645 (c = getc( gras_ddt_parse_in )) != EOF && c != '\n'; ++n ) \
648 buf[n++] = (char) c; \
649 if ( c == EOF && ferror( gras_ddt_parse_in ) ) \
650 YY_FATAL_ERROR( "input in flex scanner failed" ); \
656 while ( (result = fread(buf, 1, max_size, gras_ddt_parse_in))==0 && ferror(gras_ddt_parse_in)) \
658 if( errno != EINTR) \
660 YY_FATAL_ERROR( "input in flex scanner failed" ); \
664 clearerr(gras_ddt_parse_in); \
671 /* No semi-colon after return; correct usage is to write "yyterminate();" -
672 * we don't want an extra ';' after the "return" because that will cause
673 * some compilers to complain about unreachable statements.
676 #define yyterminate() return YY_NULL
679 /* Number of entries by which start-condition stack grows. */
680 #ifndef YY_START_STACK_INCR
681 #define YY_START_STACK_INCR 25
684 /* Report a fatal error. */
685 #ifndef YY_FATAL_ERROR
686 #define YY_FATAL_ERROR(msg) yy_fatal_error( msg )
689 /* end tables serialization structures and prototypes */
691 /* Default declaration of generated scanner - a define so the user can
692 * easily add parameters.
695 #define YY_DECL_IS_OURS 1
697 extern int gras_ddt_parse_lex (void);
699 #define YY_DECL int gras_ddt_parse_lex (void)
700 #endif /* !YY_DECL */
702 /* Code executed at the beginning of each rule, after gras_ddt_parse_text and gras_ddt_parse_leng
705 #ifndef YY_USER_ACTION
706 #define YY_USER_ACTION
709 /* Code executed at the end of each rule. */
711 #define YY_BREAK break;
714 #define YY_RULE_SETUP \
717 /** The main scanner function which does all the work.
721 register yy_state_type yy_current_state;
722 register char *yy_cp, *yy_bp;
725 int comment_caller=0;
726 int annotate_caller=0;
737 (yy_start) = 1; /* first start state */
739 if ( ! gras_ddt_parse_in )
740 gras_ddt_parse_in = stdin;
742 if ( ! gras_ddt_parse_out )
743 gras_ddt_parse_out = stdout;
745 if ( ! YY_CURRENT_BUFFER ) {
746 gras_ddt_parse_ensure_buffer_stack ();
747 YY_CURRENT_BUFFER_LVALUE =
748 gras_ddt_parse__create_buffer(gras_ddt_parse_in,YY_BUF_SIZE );
751 gras_ddt_parse__load_buffer_state( );
754 while ( 1 ) /* loops until end-of-file is reached */
756 yy_cp = (yy_c_buf_p);
758 /* Support of gras_ddt_parse_text. */
759 *yy_cp = (yy_hold_char);
761 /* yy_bp points to the position in yy_ch_buf of the start of
766 yy_current_state = (yy_start);
770 register YY_CHAR yy_c = yy_ec[YY_SC_TO_UI(*yy_cp)];
771 if ( yy_accept[yy_current_state] )
773 (yy_last_accepting_state) = yy_current_state;
774 (yy_last_accepting_cpos) = yy_cp;
776 while ( yy_chk[yy_base[yy_current_state] + yy_c] != yy_current_state )
778 yy_current_state = (int) yy_def[yy_current_state];
779 if ( yy_current_state >= 61 )
780 yy_c = yy_meta[(unsigned int) yy_c];
782 yy_current_state = yy_nxt[yy_base[yy_current_state] + (unsigned int) yy_c];
785 while ( yy_base[yy_current_state] != 88 );
788 yy_act = yy_accept[yy_current_state];
790 { /* have to back up */
791 yy_cp = (yy_last_accepting_cpos);
792 yy_current_state = (yy_last_accepting_state);
793 yy_act = yy_accept[yy_current_state];
798 do_action: /* This label is used only to access EOF actions. */
801 { /* beginning of action switch */
802 case 0: /* must back up */
803 /* undo the effects of YY_DO_BEFORE_ACTION */
804 *yy_cp = (yy_hold_char);
805 yy_cp = (yy_last_accepting_cpos);
806 yy_current_state = (yy_last_accepting_state);
815 { /****************** ANNOTATION ************************/
816 DEBUG0("Begin annotation");
817 annotate_caller = INITIAL;
818 gras_ddt_parse_char_pos+= strlen(gras_ddt_parse_text);
819 gras_ddt_parse_col_pos+= strlen(gras_ddt_parse_text);
825 { /* trim annotation */
826 DEBUG0("Begin annotation");
827 annotate_caller = foo;
828 gras_ddt_parse_char_pos+= strlen(gras_ddt_parse_text);
829 gras_ddt_parse_col_pos+= strlen(gras_ddt_parse_text);
836 DEBUG0("End annotation");
837 gras_ddt_parse_char_pos+= strlen(gras_ddt_parse_text);
838 gras_ddt_parse_col_pos+= strlen(gras_ddt_parse_text);
839 BEGIN(annotate_caller);
845 PARSE_ERROR0("``/*g'' construct closed by a regular ``*/''");
849 /* rule 6 can match eol */
852 PARSE_ERROR0("Type annotation cannot spread over several lines");
858 gras_ddt_parse_char_pos+= strlen(gras_ddt_parse_text);
859 gras_ddt_parse_col_pos+= strlen(gras_ddt_parse_text);
860 return GRAS_DDT_PARSE_TOKEN_ANNOTATE;
865 { /****************** COMMENTS ************************/
866 /* constructs like : */
868 /* are not comments but size annotations */
869 comment_caller = INITIAL;
876 comment_caller = foo;
882 { /* eat anything that's not a '*' */
887 { /* eat up '*'s not followed by '/'s */
891 /* rule 12 can match eol */
894 ++gras_ddt_parse_line_pos;
895 gras_ddt_parse_col_pos=0;
896 gras_ddt_parse_char_pos++;
902 gras_ddt_parse_char_pos+= strlen(gras_ddt_parse_text);
903 gras_ddt_parse_col_pos+= strlen(gras_ddt_parse_text);
904 BEGIN(comment_caller);
909 { /****************** STATEMENTS ************************/
910 gras_ddt_parse_char_pos += strlen(gras_ddt_parse_text);
911 gras_ddt_parse_col_pos += strlen(gras_ddt_parse_text);
913 return(GRAS_DDT_PARSE_TOKEN_WORD);
919 gras_ddt_parse_char_pos++;
920 gras_ddt_parse_col_pos++;
922 return(GRAS_DDT_PARSE_TOKEN_LA);
928 gras_ddt_parse_char_pos++;
929 gras_ddt_parse_col_pos++;
931 return(GRAS_DDT_PARSE_TOKEN_RA);
937 gras_ddt_parse_char_pos++;
938 gras_ddt_parse_col_pos++;
940 return(GRAS_DDT_PARSE_TOKEN_LB);
946 gras_ddt_parse_char_pos++;
947 gras_ddt_parse_col_pos++;
949 return(GRAS_DDT_PARSE_TOKEN_RB);
955 gras_ddt_parse_char_pos++;
956 gras_ddt_parse_col_pos++;
958 return(GRAS_DDT_PARSE_TOKEN_LP);
964 gras_ddt_parse_char_pos++;
965 gras_ddt_parse_col_pos++;
967 return(GRAS_DDT_PARSE_TOKEN_RP);
973 gras_ddt_parse_char_pos++;
974 gras_ddt_parse_col_pos++;
976 return(GRAS_DDT_PARSE_TOKEN_STAR);
982 gras_ddt_parse_char_pos++;
983 gras_ddt_parse_col_pos++;
985 return(GRAS_DDT_PARSE_TOKEN_SEMI_COLON);
991 gras_ddt_parse_char_pos++;
992 gras_ddt_parse_col_pos++;
994 return(GRAS_DDT_PARSE_TOKEN_COLON);
998 /* rule 24 can match eol */
1001 gras_ddt_parse_line_pos++;
1002 gras_ddt_parse_char_pos++;
1003 gras_ddt_parse_col_pos=0;
1010 gras_ddt_parse_char_pos++;
1011 gras_ddt_parse_col_pos++;
1019 case YY_STATE_EOF(INITIAL):
1020 case YY_STATE_EOF(annotate):
1021 case YY_STATE_EOF(comment):
1022 case YY_STATE_EOF(foo):
1025 case YY_END_OF_BUFFER:
1027 /* Amount of text matched not including the EOB char. */
1028 int yy_amount_of_matched_text = (int) (yy_cp - (yytext_ptr)) - 1;
1030 /* Undo the effects of YY_DO_BEFORE_ACTION. */
1031 *yy_cp = (yy_hold_char);
1032 YY_RESTORE_YY_MORE_OFFSET
1034 if ( YY_CURRENT_BUFFER_LVALUE->yy_buffer_status == YY_BUFFER_NEW )
1036 /* We're scanning a new file or input source. It's
1037 * possible that this happened because the user
1038 * just pointed gras_ddt_parse_in at a new source and called
1039 * gras_ddt_parse_lex(). If so, then we have to assure
1040 * consistency between YY_CURRENT_BUFFER and our
1041 * globals. Here is the right place to do so, because
1042 * this is the first action (other than possibly a
1043 * back-up) that will match for the new input source.
1045 (yy_n_chars) = YY_CURRENT_BUFFER_LVALUE->yy_n_chars;
1046 YY_CURRENT_BUFFER_LVALUE->yy_input_file = gras_ddt_parse_in;
1047 YY_CURRENT_BUFFER_LVALUE->yy_buffer_status = YY_BUFFER_NORMAL;
1050 /* Note that here we test for yy_c_buf_p "<=" to the position
1051 * of the first EOB in the buffer, since yy_c_buf_p will
1052 * already have been incremented past the NUL character
1053 * (since all states make transitions on EOB to the
1054 * end-of-buffer state). Contrast this with the test
1057 if ( (yy_c_buf_p) <= &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[(yy_n_chars)] )
1058 { /* This was really a NUL. */
1059 yy_state_type yy_next_state;
1061 (yy_c_buf_p) = (yytext_ptr) + yy_amount_of_matched_text;
1063 yy_current_state = yy_get_previous_state( );
1065 /* Okay, we're now positioned to make the NUL
1066 * transition. We couldn't have
1067 * yy_get_previous_state() go ahead and do it
1068 * for us because it doesn't know how to deal
1069 * with the possibility of jamming (and we don't
1070 * want to build jamming into it because then it
1071 * will run more slowly).
1074 yy_next_state = yy_try_NUL_trans( yy_current_state );
1076 yy_bp = (yytext_ptr) + YY_MORE_ADJ;
1078 if ( yy_next_state )
1080 /* Consume the NUL. */
1081 yy_cp = ++(yy_c_buf_p);
1082 yy_current_state = yy_next_state;
1088 yy_cp = (yy_c_buf_p);
1089 goto yy_find_action;
1093 else switch ( yy_get_next_buffer( ) )
1095 case EOB_ACT_END_OF_FILE:
1097 (yy_did_buffer_switch_on_eof) = 0;
1099 if ( gras_ddt_parse_wrap( ) )
1101 /* Note: because we've taken care in
1102 * yy_get_next_buffer() to have set up
1103 * gras_ddt_parse_text, we can now set up
1104 * yy_c_buf_p so that if some total
1105 * hoser (like flex itself) wants to
1106 * call the scanner after we return the
1107 * YY_NULL, it'll still work - another
1108 * YY_NULL will get returned.
1110 (yy_c_buf_p) = (yytext_ptr) + YY_MORE_ADJ;
1112 yy_act = YY_STATE_EOF(YY_START);
1118 if ( ! (yy_did_buffer_switch_on_eof) )
1124 case EOB_ACT_CONTINUE_SCAN:
1126 (yytext_ptr) + yy_amount_of_matched_text;
1128 yy_current_state = yy_get_previous_state( );
1130 yy_cp = (yy_c_buf_p);
1131 yy_bp = (yytext_ptr) + YY_MORE_ADJ;
1134 case EOB_ACT_LAST_MATCH:
1136 &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[(yy_n_chars)];
1138 yy_current_state = yy_get_previous_state( );
1140 yy_cp = (yy_c_buf_p);
1141 yy_bp = (yytext_ptr) + YY_MORE_ADJ;
1142 goto yy_find_action;
1149 "fatal flex scanner internal error--no action found" );
1150 } /* end of action switch */
1151 } /* end of scanning one token */
1152 } /* end of gras_ddt_parse_lex */
1154 /* yy_get_next_buffer - try to read in a new buffer
1156 * Returns a code representing an action:
1157 * EOB_ACT_LAST_MATCH -
1158 * EOB_ACT_CONTINUE_SCAN - continue scanning from current position
1159 * EOB_ACT_END_OF_FILE - end of file
1161 static int yy_get_next_buffer (void)
1163 register char *dest = YY_CURRENT_BUFFER_LVALUE->yy_ch_buf;
1164 register char *source = (yytext_ptr);
1165 register int number_to_move, i;
1168 if ( (yy_c_buf_p) > &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[(yy_n_chars) + 1] )
1170 "fatal flex scanner internal error--end of buffer missed" );
1172 if ( YY_CURRENT_BUFFER_LVALUE->yy_fill_buffer == 0 )
1173 { /* Don't try to fill the buffer, so this is an EOF. */
1174 if ( (yy_c_buf_p) - (yytext_ptr) - YY_MORE_ADJ == 1 )
1176 /* We matched a single character, the EOB, so
1177 * treat this as a final EOF.
1179 return EOB_ACT_END_OF_FILE;
1184 /* We matched some text prior to the EOB, first
1187 return EOB_ACT_LAST_MATCH;
1191 /* Try to read more data. */
1193 /* First move last chars to start of buffer. */
1194 number_to_move = (int) ((yy_c_buf_p) - (yytext_ptr)) - 1;
1196 for ( i = 0; i < number_to_move; ++i )
1197 *(dest++) = *(source++);
1199 if ( YY_CURRENT_BUFFER_LVALUE->yy_buffer_status == YY_BUFFER_EOF_PENDING )
1200 /* don't do the read, it's not guaranteed to return an EOF,
1203 YY_CURRENT_BUFFER_LVALUE->yy_n_chars = (yy_n_chars) = 0;
1208 YY_CURRENT_BUFFER_LVALUE->yy_buf_size - number_to_move - 1;
1210 while ( num_to_read <= 0 )
1211 { /* Not enough room in the buffer - grow it. */
1213 /* just a shorter name for the current buffer */
1214 YY_BUFFER_STATE b = YY_CURRENT_BUFFER;
1216 int yy_c_buf_p_offset =
1217 (int) ((yy_c_buf_p) - b->yy_ch_buf);
1219 if ( b->yy_is_our_buffer )
1221 int new_size = b->yy_buf_size * 2;
1223 if ( new_size <= 0 )
1224 b->yy_buf_size += b->yy_buf_size / 8;
1226 b->yy_buf_size *= 2;
1228 b->yy_ch_buf = (char *)
1229 /* Include room in for 2 EOB chars. */
1230 gras_ddt_parse_realloc((void *) b->yy_ch_buf,b->yy_buf_size + 2 );
1233 /* Can't grow it, we don't own it. */
1236 if ( ! b->yy_ch_buf )
1238 "fatal error - scanner input buffer overflow" );
1240 (yy_c_buf_p) = &b->yy_ch_buf[yy_c_buf_p_offset];
1242 num_to_read = YY_CURRENT_BUFFER_LVALUE->yy_buf_size -
1247 if ( num_to_read > YY_READ_BUF_SIZE )
1248 num_to_read = YY_READ_BUF_SIZE;
1250 /* Read in more data. */
1251 YY_INPUT( (&YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[number_to_move]),
1252 (yy_n_chars), (size_t) num_to_read );
1254 YY_CURRENT_BUFFER_LVALUE->yy_n_chars = (yy_n_chars);
1257 if ( (yy_n_chars) == 0 )
1259 if ( number_to_move == YY_MORE_ADJ )
1261 ret_val = EOB_ACT_END_OF_FILE;
1262 gras_ddt_parse_restart(gras_ddt_parse_in );
1267 ret_val = EOB_ACT_LAST_MATCH;
1268 YY_CURRENT_BUFFER_LVALUE->yy_buffer_status =
1269 YY_BUFFER_EOF_PENDING;
1274 ret_val = EOB_ACT_CONTINUE_SCAN;
1276 if ((yy_size_t) ((yy_n_chars) + number_to_move) > YY_CURRENT_BUFFER_LVALUE->yy_buf_size) {
1277 /* Extend the array by 50%, plus the number we really need. */
1278 yy_size_t new_size = (yy_n_chars) + number_to_move + ((yy_n_chars) >> 1);
1279 YY_CURRENT_BUFFER_LVALUE->yy_ch_buf = (char *) gras_ddt_parse_realloc((void *) YY_CURRENT_BUFFER_LVALUE->yy_ch_buf,new_size );
1280 if ( ! YY_CURRENT_BUFFER_LVALUE->yy_ch_buf )
1281 YY_FATAL_ERROR( "out of dynamic memory in yy_get_next_buffer()" );
1284 (yy_n_chars) += number_to_move;
1285 YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[(yy_n_chars)] = YY_END_OF_BUFFER_CHAR;
1286 YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[(yy_n_chars) + 1] = YY_END_OF_BUFFER_CHAR;
1288 (yytext_ptr) = &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[0];
1293 /* yy_get_previous_state - get the state just before the EOB char was reached */
1295 static yy_state_type yy_get_previous_state (void)
1297 register yy_state_type yy_current_state;
1298 register char *yy_cp;
1300 yy_current_state = (yy_start);
1302 for ( yy_cp = (yytext_ptr) + YY_MORE_ADJ; yy_cp < (yy_c_buf_p); ++yy_cp )
1304 register YY_CHAR yy_c = (*yy_cp ? yy_ec[YY_SC_TO_UI(*yy_cp)] : 1);
1305 if ( yy_accept[yy_current_state] )
1307 (yy_last_accepting_state) = yy_current_state;
1308 (yy_last_accepting_cpos) = yy_cp;
1310 while ( yy_chk[yy_base[yy_current_state] + yy_c] != yy_current_state )
1312 yy_current_state = (int) yy_def[yy_current_state];
1313 if ( yy_current_state >= 61 )
1314 yy_c = yy_meta[(unsigned int) yy_c];
1316 yy_current_state = yy_nxt[yy_base[yy_current_state] + (unsigned int) yy_c];
1319 return yy_current_state;
1322 /* yy_try_NUL_trans - try to make a transition on the NUL character
1325 * next_state = yy_try_NUL_trans( current_state );
1327 static yy_state_type yy_try_NUL_trans (yy_state_type yy_current_state )
1329 register int yy_is_jam;
1330 register char *yy_cp = (yy_c_buf_p);
1332 register YY_CHAR yy_c = 1;
1333 if ( yy_accept[yy_current_state] )
1335 (yy_last_accepting_state) = yy_current_state;
1336 (yy_last_accepting_cpos) = yy_cp;
1338 while ( yy_chk[yy_base[yy_current_state] + yy_c] != yy_current_state )
1340 yy_current_state = (int) yy_def[yy_current_state];
1341 if ( yy_current_state >= 61 )
1342 yy_c = yy_meta[(unsigned int) yy_c];
1344 yy_current_state = yy_nxt[yy_base[yy_current_state] + (unsigned int) yy_c];
1345 yy_is_jam = (yy_current_state == 60);
1347 return yy_is_jam ? 0 : yy_current_state;
1350 static void yyunput (int c, register char * yy_bp )
1352 register char *yy_cp;
1354 yy_cp = (yy_c_buf_p);
1356 /* undo effects of setting up gras_ddt_parse_text */
1357 *yy_cp = (yy_hold_char);
1359 if ( yy_cp < YY_CURRENT_BUFFER_LVALUE->yy_ch_buf + 2 )
1360 { /* need to shift things up to make room */
1361 /* +2 for EOB chars. */
1362 register int number_to_move = (yy_n_chars) + 2;
1363 register char *dest = &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[
1364 YY_CURRENT_BUFFER_LVALUE->yy_buf_size + 2];
1365 register char *source =
1366 &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[number_to_move];
1368 while ( source > YY_CURRENT_BUFFER_LVALUE->yy_ch_buf )
1369 *--dest = *--source;
1371 yy_cp += (int) (dest - source);
1372 yy_bp += (int) (dest - source);
1373 YY_CURRENT_BUFFER_LVALUE->yy_n_chars =
1374 (yy_n_chars) = YY_CURRENT_BUFFER_LVALUE->yy_buf_size;
1376 if ( yy_cp < YY_CURRENT_BUFFER_LVALUE->yy_ch_buf + 2 )
1377 YY_FATAL_ERROR( "flex scanner push-back overflow" );
1380 *--yy_cp = (char) c;
1382 (yytext_ptr) = yy_bp;
1383 (yy_hold_char) = *yy_cp;
1384 (yy_c_buf_p) = yy_cp;
1389 static int yyinput (void)
1391 static int input (void)
1397 *(yy_c_buf_p) = (yy_hold_char);
1399 if ( *(yy_c_buf_p) == YY_END_OF_BUFFER_CHAR )
1401 /* yy_c_buf_p now points to the character we want to return.
1402 * If this occurs *before* the EOB characters, then it's a
1403 * valid NUL; if not, then we've hit the end of the buffer.
1405 if ( (yy_c_buf_p) < &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[(yy_n_chars)] )
1406 /* This was really a NUL. */
1407 *(yy_c_buf_p) = '\0';
1410 { /* need more input */
1411 int offset = (yy_c_buf_p) - (yytext_ptr);
1414 switch ( yy_get_next_buffer( ) )
1416 case EOB_ACT_LAST_MATCH:
1417 /* This happens because yy_g_n_b()
1418 * sees that we've accumulated a
1419 * token and flags that we need to
1420 * try matching the token before
1421 * proceeding. But for input(),
1422 * there's no matching to consider.
1423 * So convert the EOB_ACT_LAST_MATCH
1424 * to EOB_ACT_END_OF_FILE.
1427 /* Reset buffer status. */
1428 gras_ddt_parse_restart(gras_ddt_parse_in );
1432 case EOB_ACT_END_OF_FILE:
1434 if ( gras_ddt_parse_wrap( ) )
1437 if ( ! (yy_did_buffer_switch_on_eof) )
1446 case EOB_ACT_CONTINUE_SCAN:
1447 (yy_c_buf_p) = (yytext_ptr) + offset;
1453 c = *(unsigned char *) (yy_c_buf_p); /* cast for 8-bit char's */
1454 *(yy_c_buf_p) = '\0'; /* preserve gras_ddt_parse_text */
1455 (yy_hold_char) = *++(yy_c_buf_p);
1459 #endif /* ifndef YY_NO_INPUT */
1461 /** Immediately switch to a different input stream.
1462 * @param input_file A readable stream.
1464 * @note This function does not reset the start condition to @c INITIAL .
1466 void gras_ddt_parse_restart (FILE * input_file )
1469 if ( ! YY_CURRENT_BUFFER ){
1470 gras_ddt_parse_ensure_buffer_stack ();
1471 YY_CURRENT_BUFFER_LVALUE =
1472 gras_ddt_parse__create_buffer(gras_ddt_parse_in,YY_BUF_SIZE );
1475 gras_ddt_parse__init_buffer(YY_CURRENT_BUFFER,input_file );
1476 gras_ddt_parse__load_buffer_state( );
1479 /** Switch to a different input buffer.
1480 * @param new_buffer The new input buffer.
1483 void gras_ddt_parse__switch_to_buffer (YY_BUFFER_STATE new_buffer )
1486 /* TODO. We should be able to replace this entire function body
1488 * gras_ddt_parse_pop_buffer_state();
1489 * gras_ddt_parse_push_buffer_state(new_buffer);
1491 gras_ddt_parse_ensure_buffer_stack ();
1492 if ( YY_CURRENT_BUFFER == new_buffer )
1495 if ( YY_CURRENT_BUFFER )
1497 /* Flush out information for old buffer. */
1498 *(yy_c_buf_p) = (yy_hold_char);
1499 YY_CURRENT_BUFFER_LVALUE->yy_buf_pos = (yy_c_buf_p);
1500 YY_CURRENT_BUFFER_LVALUE->yy_n_chars = (yy_n_chars);
1503 YY_CURRENT_BUFFER_LVALUE = new_buffer;
1504 gras_ddt_parse__load_buffer_state( );
1506 /* We don't actually know whether we did this switch during
1507 * EOF (gras_ddt_parse_wrap()) processing, but the only time this flag
1508 * is looked at is after gras_ddt_parse_wrap() is called, so it's safe
1509 * to go ahead and always set it.
1511 (yy_did_buffer_switch_on_eof) = 1;
1514 static void gras_ddt_parse__load_buffer_state (void)
1516 (yy_n_chars) = YY_CURRENT_BUFFER_LVALUE->yy_n_chars;
1517 (yytext_ptr) = (yy_c_buf_p) = YY_CURRENT_BUFFER_LVALUE->yy_buf_pos;
1518 gras_ddt_parse_in = YY_CURRENT_BUFFER_LVALUE->yy_input_file;
1519 (yy_hold_char) = *(yy_c_buf_p);
1522 /** Allocate and initialize an input buffer state.
1523 * @param file A readable stream.
1524 * @param size The character buffer size in bytes. When in doubt, use @c YY_BUF_SIZE.
1526 * @return the allocated buffer state.
1528 YY_BUFFER_STATE gras_ddt_parse__create_buffer (FILE * file, int size )
1532 b = (YY_BUFFER_STATE) gras_ddt_parse_alloc(sizeof( struct yy_buffer_state ) );
1534 YY_FATAL_ERROR( "out of dynamic memory in gras_ddt_parse__create_buffer()" );
1536 b->yy_buf_size = size;
1538 /* yy_ch_buf has to be 2 characters longer than the size given because
1539 * we need to put in 2 end-of-buffer characters.
1541 b->yy_ch_buf = (char *) gras_ddt_parse_alloc(b->yy_buf_size + 2 );
1542 if ( ! b->yy_ch_buf )
1543 YY_FATAL_ERROR( "out of dynamic memory in gras_ddt_parse__create_buffer()" );
1545 b->yy_is_our_buffer = 1;
1547 gras_ddt_parse__init_buffer(b,file );
1552 /** Destroy the buffer.
1553 * @param b a buffer created with gras_ddt_parse__create_buffer()
1556 void gras_ddt_parse__delete_buffer (YY_BUFFER_STATE b )
1562 if ( b == YY_CURRENT_BUFFER ) /* Not sure if we should pop here. */
1563 YY_CURRENT_BUFFER_LVALUE = (YY_BUFFER_STATE) 0;
1565 if ( b->yy_is_our_buffer )
1566 gras_ddt_parse_free((void *) b->yy_ch_buf );
1568 gras_ddt_parse_free((void *) b );
1572 extern int isatty (int );
1573 #endif /* __cplusplus */
1575 /* Initializes or reinitializes a buffer.
1576 * This function is sometimes called more than once on the same buffer,
1577 * such as during a gras_ddt_parse_restart() or at EOF.
1579 static void gras_ddt_parse__init_buffer (YY_BUFFER_STATE b, FILE * file )
1584 gras_ddt_parse__flush_buffer(b );
1586 b->yy_input_file = file;
1587 b->yy_fill_buffer = 1;
1589 /* If b is the current buffer, then gras_ddt_parse__init_buffer was _probably_
1590 * called from gras_ddt_parse_restart() or through yy_get_next_buffer.
1591 * In that case, we don't want to reset the lineno or column.
1593 if (b != YY_CURRENT_BUFFER){
1594 b->yy_bs_lineno = 1;
1595 b->yy_bs_column = 0;
1598 b->yy_is_interactive = file ? (isatty( fileno(file) ) > 0) : 0;
1603 /** Discard all buffered characters. On the next scan, YY_INPUT will be called.
1604 * @param b the buffer state to be flushed, usually @c YY_CURRENT_BUFFER.
1607 void gras_ddt_parse__flush_buffer (YY_BUFFER_STATE b )
1614 /* We always need two end-of-buffer characters. The first causes
1615 * a transition to the end-of-buffer state. The second causes
1616 * a jam in that state.
1618 b->yy_ch_buf[0] = YY_END_OF_BUFFER_CHAR;
1619 b->yy_ch_buf[1] = YY_END_OF_BUFFER_CHAR;
1621 b->yy_buf_pos = &b->yy_ch_buf[0];
1624 b->yy_buffer_status = YY_BUFFER_NEW;
1626 if ( b == YY_CURRENT_BUFFER )
1627 gras_ddt_parse__load_buffer_state( );
1630 /** Pushes the new state onto the stack. The new state becomes
1631 * the current state. This function will allocate the stack
1633 * @param new_buffer The new state.
1636 void gras_ddt_parse_push_buffer_state (YY_BUFFER_STATE new_buffer )
1638 if (new_buffer == NULL)
1641 gras_ddt_parse_ensure_buffer_stack();
1643 /* This block is copied from gras_ddt_parse__switch_to_buffer. */
1644 if ( YY_CURRENT_BUFFER )
1646 /* Flush out information for old buffer. */
1647 *(yy_c_buf_p) = (yy_hold_char);
1648 YY_CURRENT_BUFFER_LVALUE->yy_buf_pos = (yy_c_buf_p);
1649 YY_CURRENT_BUFFER_LVALUE->yy_n_chars = (yy_n_chars);
1652 /* Only push if top exists. Otherwise, replace top. */
1653 if (YY_CURRENT_BUFFER)
1654 (yy_buffer_stack_top)++;
1655 YY_CURRENT_BUFFER_LVALUE = new_buffer;
1657 /* copied from gras_ddt_parse__switch_to_buffer. */
1658 gras_ddt_parse__load_buffer_state( );
1659 (yy_did_buffer_switch_on_eof) = 1;
1662 /** Removes and deletes the top of the stack, if present.
1663 * The next element becomes the new top.
1666 void gras_ddt_parse_pop_buffer_state (void)
1668 if (!YY_CURRENT_BUFFER)
1671 gras_ddt_parse__delete_buffer(YY_CURRENT_BUFFER );
1672 YY_CURRENT_BUFFER_LVALUE = NULL;
1673 if ((yy_buffer_stack_top) > 0)
1674 --(yy_buffer_stack_top);
1676 if (YY_CURRENT_BUFFER) {
1677 gras_ddt_parse__load_buffer_state( );
1678 (yy_did_buffer_switch_on_eof) = 1;
1682 /* Allocates the stack if it does not exist.
1683 * Guarantees space for at least one push.
1685 static void gras_ddt_parse_ensure_buffer_stack (void)
1689 if (!(yy_buffer_stack)) {
1691 /* First allocation is just for 2 elements, since we don't know if this
1692 * scanner will even need a stack. We use 2 instead of 1 to avoid an
1693 * immediate realloc on the next call.
1696 (yy_buffer_stack) = (struct yy_buffer_state**)gras_ddt_parse_alloc
1697 (num_to_alloc * sizeof(struct yy_buffer_state*)
1699 if ( ! (yy_buffer_stack) )
1700 YY_FATAL_ERROR( "out of dynamic memory in gras_ddt_parse_ensure_buffer_stack()" );
1702 memset((yy_buffer_stack), 0, num_to_alloc * sizeof(struct yy_buffer_state*));
1704 (yy_buffer_stack_max) = num_to_alloc;
1705 (yy_buffer_stack_top) = 0;
1709 if ((yy_buffer_stack_top) >= ((yy_buffer_stack_max)) - 1){
1711 /* Increase the buffer to prepare for a possible push. */
1712 int grow_size = 8 /* arbitrary grow size */;
1714 num_to_alloc = (yy_buffer_stack_max) + grow_size;
1715 (yy_buffer_stack) = (struct yy_buffer_state**)gras_ddt_parse_realloc
1717 num_to_alloc * sizeof(struct yy_buffer_state*)
1719 if ( ! (yy_buffer_stack) )
1720 YY_FATAL_ERROR( "out of dynamic memory in gras_ddt_parse_ensure_buffer_stack()" );
1722 /* zero only the new slots.*/
1723 memset((yy_buffer_stack) + (yy_buffer_stack_max), 0, grow_size * sizeof(struct yy_buffer_state*));
1724 (yy_buffer_stack_max) = num_to_alloc;
1728 /** Setup the input buffer state to scan directly from a user-specified character buffer.
1729 * @param base the character buffer
1730 * @param size the size in bytes of the character buffer
1732 * @return the newly allocated buffer state object.
1734 YY_BUFFER_STATE gras_ddt_parse__scan_buffer (char * base, yy_size_t size )
1739 base[size-2] != YY_END_OF_BUFFER_CHAR ||
1740 base[size-1] != YY_END_OF_BUFFER_CHAR )
1741 /* They forgot to leave room for the EOB's. */
1744 b = (YY_BUFFER_STATE) gras_ddt_parse_alloc(sizeof( struct yy_buffer_state ) );
1746 YY_FATAL_ERROR( "out of dynamic memory in gras_ddt_parse__scan_buffer()" );
1748 b->yy_buf_size = size - 2; /* "- 2" to take care of EOB's */
1749 b->yy_buf_pos = b->yy_ch_buf = base;
1750 b->yy_is_our_buffer = 0;
1751 b->yy_input_file = 0;
1752 b->yy_n_chars = b->yy_buf_size;
1753 b->yy_is_interactive = 0;
1755 b->yy_fill_buffer = 0;
1756 b->yy_buffer_status = YY_BUFFER_NEW;
1758 gras_ddt_parse__switch_to_buffer(b );
1763 /** Setup the input buffer state to scan a string. The next call to gras_ddt_parse_lex() will
1764 * scan from a @e copy of @a str.
1765 * @param yystr a NUL-terminated string to scan
1767 * @return the newly allocated buffer state object.
1768 * @note If you want to scan bytes that may contain NUL values, then use
1769 * gras_ddt_parse__scan_bytes() instead.
1771 YY_BUFFER_STATE gras_ddt_parse__scan_string (yyconst char * yystr )
1774 return gras_ddt_parse__scan_bytes(yystr,strlen(yystr) );
1777 /** Setup the input buffer state to scan the given bytes. The next call to gras_ddt_parse_lex() will
1778 * scan from a @e copy of @a bytes.
1779 * @param yybytes the byte buffer to scan
1780 * @param _yybytes_len the number of bytes in the buffer pointed to by @a bytes.
1782 * @return the newly allocated buffer state object.
1784 YY_BUFFER_STATE gras_ddt_parse__scan_bytes (yyconst char * yybytes, int _yybytes_len )
1791 /* Get memory for full buffer, including space for trailing EOB's. */
1792 n = _yybytes_len + 2;
1793 buf = (char *) gras_ddt_parse_alloc(n );
1795 YY_FATAL_ERROR( "out of dynamic memory in gras_ddt_parse__scan_bytes()" );
1797 for ( i = 0; i < _yybytes_len; ++i )
1798 buf[i] = yybytes[i];
1800 buf[_yybytes_len] = buf[_yybytes_len+1] = YY_END_OF_BUFFER_CHAR;
1802 b = gras_ddt_parse__scan_buffer(buf,n );
1804 YY_FATAL_ERROR( "bad buffer in gras_ddt_parse__scan_bytes()" );
1806 /* It's okay to grow etc. this buffer, and we should throw it
1807 * away when we're done.
1809 b->yy_is_our_buffer = 1;
1814 #ifndef YY_EXIT_FAILURE
1815 #define YY_EXIT_FAILURE 2
1818 static void yy_fatal_error (yyconst char* msg )
1820 (void) fprintf( stderr, "%s\n", msg );
1821 exit( YY_EXIT_FAILURE );
1824 /* Redefine yyless() so it works in section 3 code. */
1830 /* Undo effects of setting up gras_ddt_parse_text. */ \
1831 int yyless_macro_arg = (n); \
1832 YY_LESS_LINENO(yyless_macro_arg);\
1833 gras_ddt_parse_text[gras_ddt_parse_leng] = (yy_hold_char); \
1834 (yy_c_buf_p) = gras_ddt_parse_text + yyless_macro_arg; \
1835 (yy_hold_char) = *(yy_c_buf_p); \
1836 *(yy_c_buf_p) = '\0'; \
1837 gras_ddt_parse_leng = yyless_macro_arg; \
1841 /* Accessor methods (get/set functions) to struct members. */
1843 /** Get the current line number.
1846 int gras_ddt_parse_get_lineno (void)
1849 return gras_ddt_parse_lineno;
1852 /** Get the input stream.
1855 FILE *gras_ddt_parse_get_in (void)
1857 return gras_ddt_parse_in;
1860 /** Get the output stream.
1863 FILE *gras_ddt_parse_get_out (void)
1865 return gras_ddt_parse_out;
1868 /** Get the length of the current token.
1871 int gras_ddt_parse_get_leng (void)
1873 return gras_ddt_parse_leng;
1876 /** Get the current token.
1880 char *gras_ddt_parse_get_text (void)
1882 return gras_ddt_parse_text;
1885 /** Set the current line number.
1886 * @param line_number
1889 void gras_ddt_parse_set_lineno (int line_number )
1892 gras_ddt_parse_lineno = line_number;
1895 /** Set the input stream. This does not discard the current
1897 * @param in_str A readable stream.
1899 * @see gras_ddt_parse__switch_to_buffer
1901 void gras_ddt_parse_set_in (FILE * in_str )
1903 gras_ddt_parse_in = in_str ;
1906 void gras_ddt_parse_set_out (FILE * out_str )
1908 gras_ddt_parse_out = out_str ;
1911 int gras_ddt_parse_get_debug (void)
1913 return gras_ddt_parse__flex_debug;
1916 void gras_ddt_parse_set_debug (int bdebug )
1918 gras_ddt_parse__flex_debug = bdebug ;
1921 static int yy_init_globals (void)
1923 /* Initialization is the same as for the non-reentrant scanner.
1924 * This function is called from gras_ddt_parse_lex_destroy(), so don't allocate here.
1927 (yy_buffer_stack) = 0;
1928 (yy_buffer_stack_top) = 0;
1929 (yy_buffer_stack_max) = 0;
1930 (yy_c_buf_p) = (char *) 0;
1934 /* Defined in main.c */
1936 gras_ddt_parse_in = stdin;
1937 gras_ddt_parse_out = stdout;
1939 gras_ddt_parse_in = (FILE *) 0;
1940 gras_ddt_parse_out = (FILE *) 0;
1943 /* For future reference: Set errno on error, since we are called by
1944 * gras_ddt_parse_lex_init()
1949 /* gras_ddt_parse_lex_destroy is for both reentrant and non-reentrant scanners. */
1950 int gras_ddt_parse_lex_destroy (void)
1953 /* Pop the buffer stack, destroying each element. */
1954 while(YY_CURRENT_BUFFER){
1955 gras_ddt_parse__delete_buffer(YY_CURRENT_BUFFER );
1956 YY_CURRENT_BUFFER_LVALUE = NULL;
1957 gras_ddt_parse_pop_buffer_state();
1960 /* Destroy the stack itself. */
1961 gras_ddt_parse_free((yy_buffer_stack) );
1962 (yy_buffer_stack) = NULL;
1964 /* Reset the globals. This is important in a non-reentrant scanner so the next time
1965 * gras_ddt_parse_lex() is called, initialization will occur. */
1972 * Internal utility routines.
1976 static void yy_flex_strncpy (char* s1, yyconst char * s2, int n )
1979 for ( i = 0; i < n; ++i )
1984 #ifdef YY_NEED_STRLEN
1985 static int yy_flex_strlen (yyconst char * s )
1988 for ( n = 0; s[n]; ++n )
1995 void *gras_ddt_parse_alloc (yy_size_t size )
1997 return (void *) malloc( size );
2000 void *gras_ddt_parse_realloc (void * ptr, yy_size_t size )
2002 /* The cast to (char *) in the following accommodates both
2003 * implementations that use char* generic pointers, and those
2004 * that use void* generic pointers. It works with the latter
2005 * because both ANSI C and C++ allow castless assignment from
2006 * any pointer type to void*, and deal with argument conversions
2007 * as though doing an assignment.
2009 return (void *) realloc( (char *) ptr, size );
2012 void gras_ddt_parse_free (void * ptr )
2014 free( (char *) ptr ); /* see gras_ddt_parse_realloc() for (char *) cast */
2017 #define YYTABLES_NAME "yytables"
2019 /* {space}+ { return(TOKEN_SPACE);} */
2021 void gras_ddt_parse_dump(void) {
2022 switch(gras_ddt_parse_tok_num) {
2023 case GRAS_DDT_PARSE_TOKEN_LA : {printf("TOKEN_LA ");break;}
2024 case GRAS_DDT_PARSE_TOKEN_RA : {printf("TOKEN_RA ");break;}
2025 case GRAS_DDT_PARSE_TOKEN_WORD : {printf("TOKEN_WORD ");break;}
2026 /* case GRAS_DDT_PARSE_TOKEN_SPACE : {printf("TOKEN_SPACE ");break;}*/
2027 /* case GRAS_DDT_PARSE_TOKEN_COMMENT : {printf("TOKEN_COMMENT ");break;}*/
2028 case GRAS_DDT_PARSE_TOKEN_NEWLINE : {printf("TOKEN_NEWLINE\n");return;}
2029 case GRAS_DDT_PARSE_TOKEN_EMPTY : {printf("TOKEN_EMPTY\n");return;}
2030 default : {printf("Unknown token %d\n", gras_ddt_parse_tok_num);return;}
2032 printf("-->%s<-- [line %d, pos %d]\n",gras_ddt_parse_text,gras_ddt_parse_line_pos,gras_ddt_parse_char_pos);
2036 int gras_ddt_parse_lex_n_dump(void) {
2037 gras_ddt_parse_tok_num = gras_ddt_parse_lex();
2038 /* gras_ddt_parse_char_pos += strlen(gras_ddt_parse_text);*/
2039 return(gras_ddt_parse_tok_num);
2042 void gras_ddt_parse_pointer_init(const char *file) {
2043 gras_ddt_file_to_parse = fopen(file,"r");
2044 gras_ddt_input_buffer = gras_ddt_parse__create_buffer(gras_ddt_file_to_parse,10 );
2045 gras_ddt_parse__switch_to_buffer(gras_ddt_input_buffer);
2047 gras_ddt_parse_line_pos = 1;
2048 gras_ddt_parse_char_pos = 0;
2049 gras_ddt_parse_col_pos = 0;
2050 gras_ddt_parse_tok_num = 0;
2053 void gras_ddt_parse_pointer_close(void) {
2054 gras_ddt_parse__delete_buffer(gras_ddt_input_buffer);
2055 fclose(gras_ddt_file_to_parse);
2057 gras_ddt_parse_line_pos = 1;
2058 gras_ddt_parse_char_pos = 0;
2059 gras_ddt_parse_tok_num = 0;
2062 void gras_ddt_parse_pointer_string_init(const char *string_to_parse) {
2063 gras_ddt_input_buffer = gras_ddt_parse__scan_string (string_to_parse);
2064 definition = string_to_parse;
2065 gras_ddt_parse__switch_to_buffer(gras_ddt_input_buffer);
2067 gras_ddt_parse_line_pos = 1;
2068 gras_ddt_parse_char_pos = 0;
2069 gras_ddt_parse_tok_num = 0;
2072 void gras_ddt_parse_pointer_string_close(void) {
2073 gras_ddt_parse__delete_buffer(gras_ddt_input_buffer);
2075 gras_ddt_parse_line_pos = 1;
2076 gras_ddt_parse_char_pos = 0;
2077 gras_ddt_parse_tok_num = 0;
2080 yyunput('\0',NULL); /* fake a use of this function to calm gcc down */
2083 /* Local variables:*/