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 {
211 char *yy_ch_buf; /* input buffer */
212 char *yy_buf_pos; /* current position in input buffer */
214 /* Size of input buffer in bytes, not including room for EOB
217 yy_size_t yy_buf_size;
219 /* Number of characters read into yy_ch_buf, not including EOB
224 /* Whether we "own" the buffer - i.e., we know we created it,
225 * and can realloc() it to grow it, and should free() it to
228 int yy_is_our_buffer;
230 /* Whether this is an "interactive" input source; if so, and
231 * if we're using stdio for input, then we want to use getc()
232 * instead of fread(), to make sure we stop fetching input after
235 int yy_is_interactive;
237 /* Whether we're considered to be at the beginning of a line.
238 * If so, '^' rules will be active on the next match, otherwise
243 int yy_bs_lineno; /**< The line count. */
244 int yy_bs_column; /**< The column count. */
246 /* Whether to try to fill the input buffer when we reach the
251 int yy_buffer_status;
253 #define YY_BUFFER_NEW 0
254 #define YY_BUFFER_NORMAL 1
255 /* When an EOF's been seen but there's still some text to process
256 * then we mark the buffer as YY_EOF_PENDING, to indicate that we
257 * shouldn't try reading from the input source any more. We might
258 * still have a bunch of tokens to match, though, because of
259 * possible backing-up.
261 * When we actually see the EOF, we change the status to "new"
262 * (via gras_ddt_parse_restart()), so that the user can continue scanning by
263 * just pointing gras_ddt_parse_in at a new input file.
265 #define YY_BUFFER_EOF_PENDING 2
268 #endif /* !YY_STRUCT_YY_BUFFER_STATE */
270 /* Stack of input buffers. */
271 static size_t yy_buffer_stack_top = 0; /**< index of top of stack. */
272 static size_t yy_buffer_stack_max = 0; /**< capacity of stack. */
273 static YY_BUFFER_STATE *yy_buffer_stack = 0; /**< Stack as an array. */
275 /* We provide macros for accessing buffer states in case in the
276 * future we want to put the buffer states in a more general
279 * Returns the top of the stack, or NULL.
281 #define YY_CURRENT_BUFFER ( (yy_buffer_stack) \
282 ? (yy_buffer_stack)[(yy_buffer_stack_top)] \
285 /* Same as previous macro, but useful when we know that the buffer stack is not
286 * NULL or when we need an lvalue. For internal use only.
288 #define YY_CURRENT_BUFFER_LVALUE (yy_buffer_stack)[(yy_buffer_stack_top)]
290 /* yy_hold_char holds the character lost when gras_ddt_parse_text is formed. */
291 static char yy_hold_char;
292 static int yy_n_chars; /* number of characters read into yy_ch_buf */
293 int gras_ddt_parse_leng;
295 /* Points to current character in buffer. */
296 static char *yy_c_buf_p = (char *) 0;
297 static int yy_init = 0; /* whether we need to initialize */
298 static int yy_start = 0; /* start state number */
300 /* Flag which is used to allow gras_ddt_parse_wrap()'s to do buffer switches
301 * instead of setting up a fresh gras_ddt_parse_in. A bit of a hack ...
303 static int yy_did_buffer_switch_on_eof;
305 void gras_ddt_parse_restart(FILE * input_file);
306 void gras_ddt_parse__switch_to_buffer(YY_BUFFER_STATE new_buffer);
307 YY_BUFFER_STATE gras_ddt_parse__create_buffer(FILE * file, int size);
308 void gras_ddt_parse__delete_buffer(YY_BUFFER_STATE b);
309 void gras_ddt_parse__flush_buffer(YY_BUFFER_STATE b);
310 void gras_ddt_parse_push_buffer_state(YY_BUFFER_STATE new_buffer);
311 void gras_ddt_parse_pop_buffer_state(void);
313 static void gras_ddt_parse_ensure_buffer_stack(void);
314 static void gras_ddt_parse__load_buffer_state(void);
315 static void gras_ddt_parse__init_buffer(YY_BUFFER_STATE b, FILE * file);
317 #define YY_FLUSH_BUFFER gras_ddt_parse__flush_buffer(YY_CURRENT_BUFFER )
319 YY_BUFFER_STATE gras_ddt_parse__scan_buffer(char *base, yy_size_t size);
320 YY_BUFFER_STATE gras_ddt_parse__scan_string(yyconst char *yy_str);
321 YY_BUFFER_STATE gras_ddt_parse__scan_bytes(yyconst char *bytes, int len);
323 void *gras_ddt_parse_alloc(yy_size_t);
324 void *gras_ddt_parse_realloc(void *, yy_size_t);
325 void gras_ddt_parse_free(void *);
327 #define yy_new_buffer gras_ddt_parse__create_buffer
329 #define yy_set_interactive(is_interactive) \
331 if ( ! YY_CURRENT_BUFFER ){ \
332 gras_ddt_parse_ensure_buffer_stack (); \
333 YY_CURRENT_BUFFER_LVALUE = \
334 gras_ddt_parse__create_buffer(gras_ddt_parse_in,YY_BUF_SIZE ); \
336 YY_CURRENT_BUFFER_LVALUE->yy_is_interactive = is_interactive; \
339 #define yy_set_bol(at_bol) \
341 if ( ! YY_CURRENT_BUFFER ){\
342 gras_ddt_parse_ensure_buffer_stack (); \
343 YY_CURRENT_BUFFER_LVALUE = \
344 gras_ddt_parse__create_buffer(gras_ddt_parse_in,YY_BUF_SIZE ); \
346 YY_CURRENT_BUFFER_LVALUE->yy_at_bol = at_bol; \
349 #define YY_AT_BOL() (YY_CURRENT_BUFFER_LVALUE->yy_at_bol)
351 /* Begin user sect3 */
353 #define gras_ddt_parse_wrap(n) 1
354 #define YY_SKIP_YYWRAP
356 typedef unsigned char YY_CHAR;
358 FILE *gras_ddt_parse_in = (FILE *) 0, *gras_ddt_parse_out = (FILE *) 0;
360 typedef int yy_state_type;
362 extern int gras_ddt_parse_lineno;
364 int gras_ddt_parse_lineno = 1;
366 extern char *gras_ddt_parse_text;
367 #define yytext_ptr gras_ddt_parse_text
369 static yy_state_type yy_get_previous_state(void);
370 static yy_state_type yy_try_NUL_trans(yy_state_type current_state);
371 static int yy_get_next_buffer(void);
372 static void yy_fatal_error(yyconst char msg[]);
374 /* Done after the current pattern has been matched and before the
375 * corresponding action - sets up gras_ddt_parse_text.
377 #define YY_DO_BEFORE_ACTION \
378 (yytext_ptr) = yy_bp; \
379 gras_ddt_parse_leng = (size_t) (yy_cp - yy_bp); \
380 (yy_hold_char) = *yy_cp; \
382 (yy_c_buf_p) = yy_cp;
384 #define YY_NUM_RULES 26
385 #define YY_END_OF_BUFFER 27
386 /* This struct is not used in this scanner,
387 but its presence is necessary. */
388 struct yy_trans_info {
389 flex_int32_t yy_verify;
392 static yyconst flex_int16_t yy_accept[61] = { 0,
393 14, 14, 7, 7, 10, 10, 0, 0, 27, 25,
394 24, 19, 20, 21, 23, 14, 25, 22, 17, 18,
395 15, 16, 7, 7, 6, 7, 7, 10, 12, 11,
396 26, 26, 14, 0, 1, 7, 7, 7, 5, 7,
397 10, 11, 11, 13, 0, 0, 2, 1, 4, 0,
398 3, 0, 2, 0, 3, 0, 0, 8, 9, 0
401 static yyconst flex_int32_t yy_ec[256] = { 0,
402 1, 1, 1, 1, 1, 1, 1, 1, 2, 3,
403 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
404 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
405 1, 2, 1, 1, 1, 1, 1, 1, 1, 4,
406 5, 6, 1, 7, 8, 8, 9, 10, 10, 10,
407 10, 10, 10, 10, 10, 10, 10, 1, 11, 1,
408 1, 1, 1, 1, 8, 8, 8, 8, 8, 8,
409 8, 8, 8, 8, 8, 8, 8, 8, 8, 8,
410 8, 8, 8, 8, 8, 8, 8, 8, 8, 8,
411 12, 1, 13, 14, 8, 1, 8, 8, 8, 8,
413 8, 8, 15, 8, 8, 8, 8, 8, 8, 8,
414 8, 8, 8, 8, 8, 8, 8, 8, 8, 8,
415 8, 8, 16, 1, 17, 1, 1, 1, 1, 1,
416 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
417 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
418 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
419 1, 1, 1, 1, 1, 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,
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,
427 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
428 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
432 static yyconst flex_int32_t yy_meta[18] = { 0,
433 1, 1, 2, 1, 1, 3, 1, 4, 1, 4,
437 static yyconst flex_int16_t yy_base[69] = { 0,
438 0, 0, 16, 30, 17, 18, 78, 77, 85, 88,
439 88, 88, 88, 88, 88, 0, 19, 88, 88, 88,
440 88, 88, 0, 24, 88, 75, 77, 0, 88, 21,
441 88, 76, 0, 22, 0, 0, 27, 75, 0, 71,
442 0, 29, 34, 88, 29, 65, 76, 0, 0, 63,
443 74, 60, 72, 56, 65, 51, 50, 88, 88, 88,
444 45, 49, 53, 55, 57, 61, 65, 69
447 static yyconst flex_int16_t yy_def[69] = { 0,
448 60, 1, 61, 61, 62, 62, 63, 63, 60, 60,
449 60, 60, 60, 60, 60, 64, 60, 60, 60, 60,
450 60, 60, 65, 65, 60, 65, 65, 66, 60, 67,
451 60, 60, 64, 60, 68, 65, 65, 65, 65, 65,
452 66, 67, 67, 60, 60, 60, 60, 68, 65, 60,
453 60, 60, 60, 60, 60, 60, 60, 60, 60, 0,
454 60, 60, 60, 60, 60, 60, 60, 60
457 static yyconst flex_int16_t yy_nxt[106] = { 0,
458 10, 10, 11, 12, 13, 14, 15, 16, 17, 16,
459 18, 19, 20, 10, 16, 21, 22, 24, 25, 29,
460 29, 26, 30, 30, 34, 37, 43, 35, 37, 44,
461 27, 24, 25, 46, 60, 26, 47, 60, 38, 43,
462 50, 38, 44, 51, 27, 23, 23, 23, 23, 28,
463 28, 28, 28, 31, 31, 31, 31, 36, 33, 36,
464 36, 41, 59, 58, 41, 42, 55, 42, 42, 48,
465 57, 48, 48, 53, 56, 55, 54, 53, 52, 49,
466 40, 45, 40, 39, 60, 32, 32, 9, 60, 60,
467 60, 60, 60, 60, 60, 60, 60, 60, 60, 60,
472 static yyconst flex_int16_t yy_chk[106] = { 0,
473 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
474 1, 1, 1, 1, 1, 1, 1, 3, 3, 5,
475 6, 3, 5, 6, 17, 24, 30, 17, 37, 30,
476 3, 4, 4, 34, 42, 4, 34, 42, 24, 43,
477 45, 37, 43, 45, 4, 61, 61, 61, 61, 62,
478 62, 62, 62, 63, 63, 63, 63, 65, 64, 65,
479 65, 66, 57, 56, 66, 67, 55, 67, 67, 68,
480 54, 68, 68, 53, 52, 51, 50, 47, 46, 40,
481 38, 32, 27, 26, 9, 8, 7, 60, 60, 60,
482 60, 60, 60, 60, 60, 60, 60, 60, 60, 60,
487 static yy_state_type yy_last_accepting_state;
488 static char *yy_last_accepting_cpos;
490 extern int gras_ddt_parse__flex_debug;
491 int gras_ddt_parse__flex_debug = 0;
493 /* The intent behind this definition is that it'll catch
494 * any uses of REJECT which flex missed.
496 #define REJECT reject_used_but_not_detected
497 #define yymore() yymore_used_but_not_detected
498 #define YY_MORE_ADJ 0
499 #define YY_RESTORE_YY_MORE_OFFSET
500 char *gras_ddt_parse_text;
502 /* DataDesc/ddt_parse -- automatic parsing of data structures */
503 /* Copyright (c) 2004 Arnaud Legrand, Martin Quinson. All rights reserved. */
504 /* This program is free software; you can redistribute it and/or modify it
505 * under the terms of the license (GNU LGPL) which comes with this package. */
506 #include "gras/DataDesc/datadesc_private.h"
507 #include "gras/DataDesc/ddt_parse.yy.h"
509 YY_BUFFER_STATE gras_ddt_input_buffer;
510 FILE *gras_ddt_file_to_parse;
512 int gras_ddt_parse_line_pos = 1;
513 int gras_ddt_parse_col_pos = 0;
514 int gras_ddt_parse_char_pos = 0;
515 int gras_ddt_parse_tok_num = 0;
516 const char *definition;
517 XBT_LOG_NEW_DEFAULT_SUBCATEGORY(gras_ddt_lexer, gras_ddt_parse,
518 "The crude internals of the lexer used for type parsing");
519 #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)
526 #ifndef YY_NO_UNISTD_H
527 /* Special case for "unistd.h", since it is non-ANSI. We include it way
528 * down here because we want the user's section 1 to have been scanned first.
529 * The user has a chance to override it with an option.
534 #ifndef YY_EXTRA_TYPE
535 #define YY_EXTRA_TYPE void *
538 static int yy_init_globals(void);
540 /* Accessor methods to globals.
541 These are made visible to non-reentrant scanners for convenience. */
543 int gras_ddt_parse_lex_destroy(void);
545 int gras_ddt_parse_get_debug(void);
547 void gras_ddt_parse_set_debug(int debug_flag);
549 YY_EXTRA_TYPE gras_ddt_parse_get_extra(void);
551 void gras_ddt_parse_set_extra(YY_EXTRA_TYPE user_defined);
553 FILE *gras_ddt_parse_get_in(void);
555 void gras_ddt_parse_set_in(FILE * in_str);
557 FILE *gras_ddt_parse_get_out(void);
559 void gras_ddt_parse_set_out(FILE * out_str);
561 int gras_ddt_parse_get_leng(void);
563 char *gras_ddt_parse_get_text(void);
565 int gras_ddt_parse_get_lineno(void);
567 void gras_ddt_parse_set_lineno(int line_number);
569 /* Macros after this point can all be overridden by user definitions in
573 #ifndef YY_SKIP_YYWRAP
575 extern "C" int gras_ddt_parse_wrap(void);
577 extern int gras_ddt_parse_wrap(void);
581 static void yyunput(int c, char *buf_ptr);
584 static void yy_flex_strncpy(char *, yyconst char *, int);
587 #ifdef YY_NEED_STRLEN
588 static int yy_flex_strlen(yyconst char *);
594 static int yyinput(void);
596 static int input(void);
601 /* Amount of stuff to slurp up with each read. */
602 #ifndef YY_READ_BUF_SIZE
603 #define YY_READ_BUF_SIZE 8192
606 /* Copy whatever the last rule matched to the standard output. */
608 /* This used to be an fputs(), but since the string might contain NUL's,
609 * we now use fwrite().
611 #define ECHO do { if (fwrite( gras_ddt_parse_text, gras_ddt_parse_leng, 1, gras_ddt_parse_out )) {} } while (0)
614 /* Gets input and stuffs it into "buf". number of characters read, or YY_NULL,
615 * is returned in "result".
618 #define YY_INPUT(buf,result,max_size) \
619 if ( YY_CURRENT_BUFFER_LVALUE->yy_is_interactive ) \
623 for ( n = 0; n < max_size && \
624 (c = getc( gras_ddt_parse_in )) != EOF && c != '\n'; ++n ) \
627 buf[n++] = (char) c; \
628 if ( c == EOF && ferror( gras_ddt_parse_in ) ) \
629 YY_FATAL_ERROR( "input in flex scanner failed" ); \
635 while ( (result = fread(buf, 1, max_size, gras_ddt_parse_in))==0 && ferror(gras_ddt_parse_in)) \
637 if( errno != EINTR) \
639 YY_FATAL_ERROR( "input in flex scanner failed" ); \
643 clearerr(gras_ddt_parse_in); \
650 /* No semi-colon after return; correct usage is to write "yyterminate();" -
651 * we don't want an extra ';' after the "return" because that will cause
652 * some compilers to complain about unreachable statements.
655 #define yyterminate() return YY_NULL
658 /* Number of entries by which start-condition stack grows. */
659 #ifndef YY_START_STACK_INCR
660 #define YY_START_STACK_INCR 25
663 /* Report a fatal error. */
664 #ifndef YY_FATAL_ERROR
665 #define YY_FATAL_ERROR(msg) yy_fatal_error( msg )
668 /* end tables serialization structures and prototypes */
670 /* Default declaration of generated scanner - a define so the user can
671 * easily add parameters.
674 #define YY_DECL_IS_OURS 1
676 extern int gras_ddt_parse_lex(void);
678 #define YY_DECL int gras_ddt_parse_lex (void)
679 #endif /* !YY_DECL */
681 /* Code executed at the beginning of each rule, after gras_ddt_parse_text and gras_ddt_parse_leng
684 #ifndef YY_USER_ACTION
685 #define YY_USER_ACTION
688 /* Code executed at the end of each rule. */
690 #define YY_BREAK break;
693 #define YY_RULE_SETUP \
696 /** The main scanner function which does all the work.
699 register yy_state_type yy_current_state;
700 register char *yy_cp, *yy_bp;
703 int comment_caller = 0;
704 int annotate_caller = 0;
714 (yy_start) = 1; /* first start state */
716 if (!gras_ddt_parse_in)
717 gras_ddt_parse_in = stdin;
719 if (!gras_ddt_parse_out)
720 gras_ddt_parse_out = stdout;
722 if (!YY_CURRENT_BUFFER) {
723 gras_ddt_parse_ensure_buffer_stack();
724 YY_CURRENT_BUFFER_LVALUE =
725 gras_ddt_parse__create_buffer(gras_ddt_parse_in, YY_BUF_SIZE);
728 gras_ddt_parse__load_buffer_state();
731 while (1) { /* loops until end-of-file is reached */
732 yy_cp = (yy_c_buf_p);
734 /* Support of gras_ddt_parse_text. */
735 *yy_cp = (yy_hold_char);
737 /* yy_bp points to the position in yy_ch_buf of the start of
742 yy_current_state = (yy_start);
745 register YY_CHAR yy_c = yy_ec[YY_SC_TO_UI(*yy_cp)];
746 if (yy_accept[yy_current_state]) {
747 (yy_last_accepting_state) = yy_current_state;
748 (yy_last_accepting_cpos) = yy_cp;
750 while (yy_chk[yy_base[yy_current_state] + yy_c] != yy_current_state) {
751 yy_current_state = (int) yy_def[yy_current_state];
752 if (yy_current_state >= 61)
753 yy_c = yy_meta[(unsigned int) yy_c];
756 yy_nxt[yy_base[yy_current_state] + (unsigned int) yy_c];
759 while (yy_base[yy_current_state] != 88);
762 yy_act = yy_accept[yy_current_state];
763 if (yy_act == 0) { /* have to back up */
764 yy_cp = (yy_last_accepting_cpos);
765 yy_current_state = (yy_last_accepting_state);
766 yy_act = yy_accept[yy_current_state];
771 do_action: /* This label is used only to access EOF actions. */
773 switch (yy_act) { /* beginning of action switch */
774 case 0: /* must back up */
775 /* undo the effects of YY_DO_BEFORE_ACTION */
776 *yy_cp = (yy_hold_char);
777 yy_cp = (yy_last_accepting_cpos);
778 yy_current_state = (yy_last_accepting_state);
782 YY_RULE_SETUP YY_BREAK case 2:
784 /****************** ANNOTATION ************************/
785 DEBUG0("Begin annotation");
786 annotate_caller = INITIAL;
787 gras_ddt_parse_char_pos += strlen(gras_ddt_parse_text);
788 gras_ddt_parse_col_pos += strlen(gras_ddt_parse_text);
791 YY_BREAK case 3:YY_RULE_SETUP { /* trim annotation */
792 DEBUG0("Begin annotation");
793 annotate_caller = foo;
794 gras_ddt_parse_char_pos += strlen(gras_ddt_parse_text);
795 gras_ddt_parse_col_pos += strlen(gras_ddt_parse_text);
797 } YY_BREAK case 4:YY_RULE_SETUP {
798 DEBUG0("End annotation");
799 gras_ddt_parse_char_pos += strlen(gras_ddt_parse_text);
800 gras_ddt_parse_col_pos += strlen(gras_ddt_parse_text);
801 BEGIN(annotate_caller);
802 } YY_BREAK case 5:YY_RULE_SETUP {
803 PARSE_ERROR0("``/*g'' construct closed by a regular ``*/''");
805 /* rule 6 can match eol */
807 PARSE_ERROR0("Type annotation cannot spread over several lines");
808 } YY_BREAK case 7:YY_RULE_SETUP { /* eat the rest */
809 gras_ddt_parse_char_pos += strlen(gras_ddt_parse_text);
810 gras_ddt_parse_col_pos += strlen(gras_ddt_parse_text);
811 return GRAS_DDT_PARSE_TOKEN_ANNOTATE;
812 } YY_BREAK case 8:YY_RULE_SETUP {
813 /****************** COMMENTS ************************/
814 /* constructs like : */
816 /* are not comments but size annotations */
817 comment_caller = INITIAL;
819 } YY_BREAK case 9:YY_RULE_SETUP {
820 comment_caller = foo;
822 } YY_BREAK case 10:YY_RULE_SETUP { /* eat anything that's not a '*' */
823 } YY_BREAK case 11:YY_RULE_SETUP { /* eat up '*'s not followed by '/'s */
825 /* rule 12 can match eol */
827 ++gras_ddt_parse_line_pos;
828 gras_ddt_parse_col_pos = 0;
829 gras_ddt_parse_char_pos++;
830 } YY_BREAK case 13:YY_RULE_SETUP {
831 gras_ddt_parse_char_pos += strlen(gras_ddt_parse_text);
832 gras_ddt_parse_col_pos += strlen(gras_ddt_parse_text);
833 BEGIN(comment_caller);
834 } YY_BREAK case 14:YY_RULE_SETUP {
835 /****************** STATEMENTS ************************/
836 gras_ddt_parse_char_pos += strlen(gras_ddt_parse_text);
837 gras_ddt_parse_col_pos += strlen(gras_ddt_parse_text);
839 return (GRAS_DDT_PARSE_TOKEN_WORD);
840 } YY_BREAK case 15:YY_RULE_SETUP {
841 gras_ddt_parse_char_pos++;
842 gras_ddt_parse_col_pos++;
844 return (GRAS_DDT_PARSE_TOKEN_LA);
845 } YY_BREAK case 16:YY_RULE_SETUP {
846 gras_ddt_parse_char_pos++;
847 gras_ddt_parse_col_pos++;
849 return (GRAS_DDT_PARSE_TOKEN_RA);
850 } YY_BREAK case 17:YY_RULE_SETUP {
851 gras_ddt_parse_char_pos++;
852 gras_ddt_parse_col_pos++;
854 return (GRAS_DDT_PARSE_TOKEN_LB);
855 } YY_BREAK case 18:YY_RULE_SETUP {
856 gras_ddt_parse_char_pos++;
857 gras_ddt_parse_col_pos++;
859 return (GRAS_DDT_PARSE_TOKEN_RB);
860 } YY_BREAK case 19:YY_RULE_SETUP {
861 gras_ddt_parse_char_pos++;
862 gras_ddt_parse_col_pos++;
864 return (GRAS_DDT_PARSE_TOKEN_LP);
865 } YY_BREAK case 20:YY_RULE_SETUP {
866 gras_ddt_parse_char_pos++;
867 gras_ddt_parse_col_pos++;
869 return (GRAS_DDT_PARSE_TOKEN_RP);
870 } YY_BREAK case 21:YY_RULE_SETUP {
871 gras_ddt_parse_char_pos++;
872 gras_ddt_parse_col_pos++;
874 return (GRAS_DDT_PARSE_TOKEN_STAR);
875 } YY_BREAK case 22:YY_RULE_SETUP {
876 gras_ddt_parse_char_pos++;
877 gras_ddt_parse_col_pos++;
879 return (GRAS_DDT_PARSE_TOKEN_SEMI_COLON);
880 } YY_BREAK case 23:YY_RULE_SETUP {
881 gras_ddt_parse_char_pos++;
882 gras_ddt_parse_col_pos++;
884 return (GRAS_DDT_PARSE_TOKEN_COLON);
886 /* rule 24 can match eol */
888 gras_ddt_parse_line_pos++;
889 gras_ddt_parse_char_pos++;
890 gras_ddt_parse_col_pos = 0;
892 } YY_BREAK case 25:YY_RULE_SETUP {
893 gras_ddt_parse_char_pos++;
894 gras_ddt_parse_col_pos++;
896 } YY_BREAK case 26:YY_RULE_SETUP ECHO;
897 YY_BREAK case YY_STATE_EOF(INITIAL):case YY_STATE_EOF(annotate):case
898 YY_STATE_EOF(comment):case YY_STATE_EOF(foo):yyterminate();
900 case YY_END_OF_BUFFER:
902 /* Amount of text matched not including the EOB char. */
903 int yy_amount_of_matched_text = (int) (yy_cp - (yytext_ptr)) - 1;
905 /* Undo the effects of YY_DO_BEFORE_ACTION. */
906 *yy_cp = (yy_hold_char);
907 YY_RESTORE_YY_MORE_OFFSET
908 if (YY_CURRENT_BUFFER_LVALUE->yy_buffer_status == YY_BUFFER_NEW) {
909 /* We're scanning a new file or input source. It's
910 * possible that this happened because the user
911 * just pointed gras_ddt_parse_in at a new source and called
912 * gras_ddt_parse_lex(). If so, then we have to assure
913 * consistency between YY_CURRENT_BUFFER and our
914 * globals. Here is the right place to do so, because
915 * this is the first action (other than possibly a
916 * back-up) that will match for the new input source.
918 (yy_n_chars) = YY_CURRENT_BUFFER_LVALUE->yy_n_chars;
919 YY_CURRENT_BUFFER_LVALUE->yy_input_file = gras_ddt_parse_in;
920 YY_CURRENT_BUFFER_LVALUE->yy_buffer_status = YY_BUFFER_NORMAL;
923 /* Note that here we test for yy_c_buf_p "<=" to the position
924 * of the first EOB in the buffer, since yy_c_buf_p will
925 * already have been incremented past the NUL character
926 * (since all states make transitions on EOB to the
927 * end-of-buffer state). Contrast this with the test
930 if ((yy_c_buf_p) <= &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[(yy_n_chars)]) { /* This was really a NUL. */
931 yy_state_type yy_next_state;
933 (yy_c_buf_p) = (yytext_ptr) + yy_amount_of_matched_text;
935 yy_current_state = yy_get_previous_state();
937 /* Okay, we're now positioned to make the NUL
938 * transition. We couldn't have
939 * yy_get_previous_state() go ahead and do it
940 * for us because it doesn't know how to deal
941 * with the possibility of jamming (and we don't
942 * want to build jamming into it because then it
943 * will run more slowly).
946 yy_next_state = yy_try_NUL_trans(yy_current_state);
948 yy_bp = (yytext_ptr) + YY_MORE_ADJ;
951 /* Consume the NUL. */
952 yy_cp = ++(yy_c_buf_p);
953 yy_current_state = yy_next_state;
958 yy_cp = (yy_c_buf_p);
964 switch (yy_get_next_buffer()) {
965 case EOB_ACT_END_OF_FILE:
967 (yy_did_buffer_switch_on_eof) = 0;
969 if (gras_ddt_parse_wrap()) {
970 /* Note: because we've taken care in
971 * yy_get_next_buffer() to have set up
972 * gras_ddt_parse_text, we can now set up
973 * yy_c_buf_p so that if some total
974 * hoser (like flex itself) wants to
975 * call the scanner after we return the
976 * YY_NULL, it'll still work - another
977 * YY_NULL will get returned.
979 (yy_c_buf_p) = (yytext_ptr) + YY_MORE_ADJ;
981 yy_act = YY_STATE_EOF(YY_START);
986 if (!(yy_did_buffer_switch_on_eof))
992 case EOB_ACT_CONTINUE_SCAN:
993 (yy_c_buf_p) = (yytext_ptr) + yy_amount_of_matched_text;
995 yy_current_state = yy_get_previous_state();
997 yy_cp = (yy_c_buf_p);
998 yy_bp = (yytext_ptr) + YY_MORE_ADJ;
1001 case EOB_ACT_LAST_MATCH:
1002 (yy_c_buf_p) = &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[(yy_n_chars)];
1004 yy_current_state = yy_get_previous_state();
1006 yy_cp = (yy_c_buf_p);
1007 yy_bp = (yytext_ptr) + YY_MORE_ADJ;
1008 goto yy_find_action;
1014 YY_FATAL_ERROR("fatal flex scanner internal error--no action found");
1015 } /* end of action switch */
1016 } /* end of scanning one token */
1017 } /* end of gras_ddt_parse_lex */
1019 /* yy_get_next_buffer - try to read in a new buffer
1021 * Returns a code representing an action:
1022 * EOB_ACT_LAST_MATCH -
1023 * EOB_ACT_CONTINUE_SCAN - continue scanning from current position
1024 * EOB_ACT_END_OF_FILE - end of file
1026 static int yy_get_next_buffer(void)
1028 register char *dest = YY_CURRENT_BUFFER_LVALUE->yy_ch_buf;
1029 register char *source = (yytext_ptr);
1030 register int number_to_move, i;
1033 if ((yy_c_buf_p) > &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[(yy_n_chars) + 1])
1034 YY_FATAL_ERROR("fatal flex scanner internal error--end of buffer missed");
1036 if (YY_CURRENT_BUFFER_LVALUE->yy_fill_buffer == 0) { /* Don't try to fill the buffer, so this is an EOF. */
1037 if ((yy_c_buf_p) - (yytext_ptr) - YY_MORE_ADJ == 1) {
1038 /* We matched a single character, the EOB, so
1039 * treat this as a final EOF.
1041 return EOB_ACT_END_OF_FILE;
1045 /* We matched some text prior to the EOB, first
1048 return EOB_ACT_LAST_MATCH;
1052 /* Try to read more data. */
1054 /* First move last chars to start of buffer. */
1055 number_to_move = (int) ((yy_c_buf_p) - (yytext_ptr)) - 1;
1057 for (i = 0; i < number_to_move; ++i)
1058 *(dest++) = *(source++);
1060 if (YY_CURRENT_BUFFER_LVALUE->yy_buffer_status == YY_BUFFER_EOF_PENDING)
1061 /* don't do the read, it's not guaranteed to return an EOF,
1064 YY_CURRENT_BUFFER_LVALUE->yy_n_chars = (yy_n_chars) = 0;
1068 YY_CURRENT_BUFFER_LVALUE->yy_buf_size - number_to_move - 1;
1070 while (num_to_read <= 0) { /* Not enough room in the buffer - grow it. */
1072 /* just a shorter name for the current buffer */
1073 YY_BUFFER_STATE b = YY_CURRENT_BUFFER;
1075 int yy_c_buf_p_offset = (int) ((yy_c_buf_p) - b->yy_ch_buf);
1077 if (b->yy_is_our_buffer) {
1078 int new_size = b->yy_buf_size * 2;
1081 b->yy_buf_size += b->yy_buf_size / 8;
1083 b->yy_buf_size *= 2;
1085 b->yy_ch_buf = (char *)
1086 /* Include room in for 2 EOB chars. */
1087 gras_ddt_parse_realloc((void *) b->yy_ch_buf, b->yy_buf_size + 2);
1089 /* Can't grow it, we don't own it. */
1093 YY_FATAL_ERROR("fatal error - scanner input buffer overflow");
1095 (yy_c_buf_p) = &b->yy_ch_buf[yy_c_buf_p_offset];
1097 num_to_read = YY_CURRENT_BUFFER_LVALUE->yy_buf_size -
1102 if (num_to_read > YY_READ_BUF_SIZE)
1103 num_to_read = YY_READ_BUF_SIZE;
1105 /* Read in more data. */
1106 YY_INPUT((&YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[number_to_move]),
1107 (yy_n_chars), (size_t) num_to_read);
1109 YY_CURRENT_BUFFER_LVALUE->yy_n_chars = (yy_n_chars);
1112 if ((yy_n_chars) == 0) {
1113 if (number_to_move == YY_MORE_ADJ) {
1114 ret_val = EOB_ACT_END_OF_FILE;
1115 gras_ddt_parse_restart(gras_ddt_parse_in);
1119 ret_val = EOB_ACT_LAST_MATCH;
1120 YY_CURRENT_BUFFER_LVALUE->yy_buffer_status = YY_BUFFER_EOF_PENDING;
1125 ret_val = EOB_ACT_CONTINUE_SCAN;
1127 if ((yy_size_t) ((yy_n_chars) + number_to_move) >
1128 YY_CURRENT_BUFFER_LVALUE->yy_buf_size) {
1129 /* Extend the array by 50%, plus the number we really need. */
1130 yy_size_t new_size = (yy_n_chars) + number_to_move + ((yy_n_chars) >> 1);
1131 YY_CURRENT_BUFFER_LVALUE->yy_ch_buf =
1132 (char *) gras_ddt_parse_realloc((void *)
1133 YY_CURRENT_BUFFER_LVALUE->yy_ch_buf,
1135 if (!YY_CURRENT_BUFFER_LVALUE->yy_ch_buf)
1136 YY_FATAL_ERROR("out of dynamic memory in yy_get_next_buffer()");
1139 (yy_n_chars) += number_to_move;
1140 YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[(yy_n_chars)] = YY_END_OF_BUFFER_CHAR;
1141 YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[(yy_n_chars) + 1] =
1142 YY_END_OF_BUFFER_CHAR;
1144 (yytext_ptr) = &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[0];
1149 /* yy_get_previous_state - get the state just before the EOB char was reached */
1151 static yy_state_type yy_get_previous_state(void)
1153 register yy_state_type yy_current_state;
1154 register char *yy_cp;
1156 yy_current_state = (yy_start);
1158 for (yy_cp = (yytext_ptr) + YY_MORE_ADJ; yy_cp < (yy_c_buf_p); ++yy_cp) {
1159 register YY_CHAR yy_c = (*yy_cp ? yy_ec[YY_SC_TO_UI(*yy_cp)] : 1);
1160 if (yy_accept[yy_current_state]) {
1161 (yy_last_accepting_state) = yy_current_state;
1162 (yy_last_accepting_cpos) = yy_cp;
1164 while (yy_chk[yy_base[yy_current_state] + yy_c] != yy_current_state) {
1165 yy_current_state = (int) yy_def[yy_current_state];
1166 if (yy_current_state >= 61)
1167 yy_c = yy_meta[(unsigned int) yy_c];
1170 yy_nxt[yy_base[yy_current_state] + (unsigned int) yy_c];
1173 return yy_current_state;
1176 /* yy_try_NUL_trans - try to make a transition on the NUL character
1179 * next_state = yy_try_NUL_trans( current_state );
1181 static yy_state_type yy_try_NUL_trans(yy_state_type yy_current_state)
1183 register int yy_is_jam;
1184 register char *yy_cp = (yy_c_buf_p);
1186 register YY_CHAR yy_c = 1;
1187 if (yy_accept[yy_current_state]) {
1188 (yy_last_accepting_state) = yy_current_state;
1189 (yy_last_accepting_cpos) = yy_cp;
1191 while (yy_chk[yy_base[yy_current_state] + yy_c] != yy_current_state) {
1192 yy_current_state = (int) yy_def[yy_current_state];
1193 if (yy_current_state >= 61)
1194 yy_c = yy_meta[(unsigned int) yy_c];
1196 yy_current_state = yy_nxt[yy_base[yy_current_state] + (unsigned int) yy_c];
1197 yy_is_jam = (yy_current_state == 60);
1199 return yy_is_jam ? 0 : yy_current_state;
1202 static void yyunput(int c, register char *yy_bp)
1204 register char *yy_cp;
1206 yy_cp = (yy_c_buf_p);
1208 /* undo effects of setting up gras_ddt_parse_text */
1209 *yy_cp = (yy_hold_char);
1211 if (yy_cp < YY_CURRENT_BUFFER_LVALUE->yy_ch_buf + 2) { /* need to shift things up to make room */
1212 /* +2 for EOB chars. */
1213 register int number_to_move = (yy_n_chars) + 2;
1214 register char *dest =
1215 &YY_CURRENT_BUFFER_LVALUE->
1216 yy_ch_buf[YY_CURRENT_BUFFER_LVALUE->yy_buf_size + 2];
1217 register char *source =
1218 &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[number_to_move];
1220 while (source > YY_CURRENT_BUFFER_LVALUE->yy_ch_buf)
1221 *--dest = *--source;
1223 yy_cp += (int) (dest - source);
1224 yy_bp += (int) (dest - source);
1225 YY_CURRENT_BUFFER_LVALUE->yy_n_chars =
1226 (yy_n_chars) = YY_CURRENT_BUFFER_LVALUE->yy_buf_size;
1228 if (yy_cp < YY_CURRENT_BUFFER_LVALUE->yy_ch_buf + 2)
1229 YY_FATAL_ERROR("flex scanner push-back overflow");
1232 *--yy_cp = (char) c;
1234 (yytext_ptr) = yy_bp;
1235 (yy_hold_char) = *yy_cp;
1236 (yy_c_buf_p) = yy_cp;
1241 static int yyinput(void)
1243 static int input(void)
1248 *(yy_c_buf_p) = (yy_hold_char);
1250 if (*(yy_c_buf_p) == YY_END_OF_BUFFER_CHAR) {
1251 /* yy_c_buf_p now points to the character we want to return.
1252 * If this occurs *before* the EOB characters, then it's a
1253 * valid NUL; if not, then we've hit the end of the buffer.
1255 if ((yy_c_buf_p) < &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[(yy_n_chars)])
1256 /* This was really a NUL. */
1257 *(yy_c_buf_p) = '\0';
1259 else { /* need more input */
1260 int offset = (yy_c_buf_p) - (yytext_ptr);
1263 switch (yy_get_next_buffer()) {
1264 case EOB_ACT_LAST_MATCH:
1265 /* This happens because yy_g_n_b()
1266 * sees that we've accumulated a
1267 * token and flags that we need to
1268 * try matching the token before
1269 * proceeding. But for input(),
1270 * there's no matching to consider.
1271 * So convert the EOB_ACT_LAST_MATCH
1272 * to EOB_ACT_END_OF_FILE.
1275 /* Reset buffer status. */
1276 gras_ddt_parse_restart(gras_ddt_parse_in);
1278 /*FALLTHROUGH*/ case EOB_ACT_END_OF_FILE:
1280 if (gras_ddt_parse_wrap())
1283 if (!(yy_did_buffer_switch_on_eof))
1292 case EOB_ACT_CONTINUE_SCAN:
1293 (yy_c_buf_p) = (yytext_ptr) + offset;
1299 c = *(unsigned char *) (yy_c_buf_p); /* cast for 8-bit char's */
1300 *(yy_c_buf_p) = '\0'; /* preserve gras_ddt_parse_text */
1301 (yy_hold_char) = *++(yy_c_buf_p);
1305 #endif /* ifndef YY_NO_INPUT */
1307 /** Immediately switch to a different input stream.
1308 * @param input_file A readable stream.
1310 * @note This function does not reset the start condition to @c INITIAL .
1312 void gras_ddt_parse_restart(FILE * input_file)
1315 if (!YY_CURRENT_BUFFER) {
1316 gras_ddt_parse_ensure_buffer_stack();
1317 YY_CURRENT_BUFFER_LVALUE =
1318 gras_ddt_parse__create_buffer(gras_ddt_parse_in, YY_BUF_SIZE);
1321 gras_ddt_parse__init_buffer(YY_CURRENT_BUFFER, input_file);
1322 gras_ddt_parse__load_buffer_state();
1325 /** Switch to a different input buffer.
1326 * @param new_buffer The new input buffer.
1329 void gras_ddt_parse__switch_to_buffer(YY_BUFFER_STATE new_buffer)
1332 /* TODO. We should be able to replace this entire function body
1334 * gras_ddt_parse_pop_buffer_state();
1335 * gras_ddt_parse_push_buffer_state(new_buffer);
1337 gras_ddt_parse_ensure_buffer_stack();
1338 if (YY_CURRENT_BUFFER == new_buffer)
1341 if (YY_CURRENT_BUFFER) {
1342 /* Flush out information for old buffer. */
1343 *(yy_c_buf_p) = (yy_hold_char);
1344 YY_CURRENT_BUFFER_LVALUE->yy_buf_pos = (yy_c_buf_p);
1345 YY_CURRENT_BUFFER_LVALUE->yy_n_chars = (yy_n_chars);
1348 YY_CURRENT_BUFFER_LVALUE = new_buffer;
1349 gras_ddt_parse__load_buffer_state();
1351 /* We don't actually know whether we did this switch during
1352 * EOF (gras_ddt_parse_wrap()) processing, but the only time this flag
1353 * is looked at is after gras_ddt_parse_wrap() is called, so it's safe
1354 * to go ahead and always set it.
1356 (yy_did_buffer_switch_on_eof) = 1;
1359 static void gras_ddt_parse__load_buffer_state(void)
1361 (yy_n_chars) = YY_CURRENT_BUFFER_LVALUE->yy_n_chars;
1362 (yytext_ptr) = (yy_c_buf_p) = YY_CURRENT_BUFFER_LVALUE->yy_buf_pos;
1363 gras_ddt_parse_in = YY_CURRENT_BUFFER_LVALUE->yy_input_file;
1364 (yy_hold_char) = *(yy_c_buf_p);
1367 /** Allocate and initialize an input buffer state.
1368 * @param file A readable stream.
1369 * @param size The character buffer size in bytes. When in doubt, use @c YY_BUF_SIZE.
1371 * @return the allocated buffer state.
1373 YY_BUFFER_STATE gras_ddt_parse__create_buffer(FILE * file, int size)
1377 b = (YY_BUFFER_STATE) gras_ddt_parse_alloc(sizeof(struct yy_buffer_state));
1380 ("out of dynamic memory in gras_ddt_parse__create_buffer()");
1382 b->yy_buf_size = size;
1384 /* yy_ch_buf has to be 2 characters longer than the size given because
1385 * we need to put in 2 end-of-buffer characters.
1387 b->yy_ch_buf = (char *) gras_ddt_parse_alloc(b->yy_buf_size + 2);
1390 ("out of dynamic memory in gras_ddt_parse__create_buffer()");
1392 b->yy_is_our_buffer = 1;
1394 gras_ddt_parse__init_buffer(b, file);
1399 /** Destroy the buffer.
1400 * @param b a buffer created with gras_ddt_parse__create_buffer()
1403 void gras_ddt_parse__delete_buffer(YY_BUFFER_STATE b)
1409 if (b == YY_CURRENT_BUFFER) /* Not sure if we should pop here. */
1410 YY_CURRENT_BUFFER_LVALUE = (YY_BUFFER_STATE) 0;
1412 if (b->yy_is_our_buffer)
1413 gras_ddt_parse_free((void *) b->yy_ch_buf);
1415 gras_ddt_parse_free((void *) b);
1418 #if !defined(__cplusplus) && !defined(WIN32)
1419 extern int isatty(int);
1420 #endif /* __cplusplus */
1422 /* Initializes or reinitializes a buffer.
1423 * This function is sometimes called more than once on the same buffer,
1424 * such as during a gras_ddt_parse_restart() or at EOF.
1426 static void gras_ddt_parse__init_buffer(YY_BUFFER_STATE b, FILE * file)
1430 gras_ddt_parse__flush_buffer(b);
1432 b->yy_input_file = file;
1433 b->yy_fill_buffer = 1;
1435 /* If b is the current buffer, then gras_ddt_parse__init_buffer was _probably_
1436 * called from gras_ddt_parse_restart() or through yy_get_next_buffer.
1437 * In that case, we don't want to reset the lineno or column.
1439 if (b != YY_CURRENT_BUFFER) {
1440 b->yy_bs_lineno = 1;
1441 b->yy_bs_column = 0;
1444 b->yy_is_interactive = file ? (isatty(fileno(file)) > 0) : 0;
1449 /** Discard all buffered characters. On the next scan, YY_INPUT will be called.
1450 * @param b the buffer state to be flushed, usually @c YY_CURRENT_BUFFER.
1453 void gras_ddt_parse__flush_buffer(YY_BUFFER_STATE b)
1460 /* We always need two end-of-buffer characters. The first causes
1461 * a transition to the end-of-buffer state. The second causes
1462 * a jam in that state.
1464 b->yy_ch_buf[0] = YY_END_OF_BUFFER_CHAR;
1465 b->yy_ch_buf[1] = YY_END_OF_BUFFER_CHAR;
1467 b->yy_buf_pos = &b->yy_ch_buf[0];
1470 b->yy_buffer_status = YY_BUFFER_NEW;
1472 if (b == YY_CURRENT_BUFFER)
1473 gras_ddt_parse__load_buffer_state();
1476 /** Pushes the new state onto the stack. The new state becomes
1477 * the current state. This function will allocate the stack
1479 * @param new_buffer The new state.
1482 void gras_ddt_parse_push_buffer_state(YY_BUFFER_STATE new_buffer)
1484 if (new_buffer == NULL)
1487 gras_ddt_parse_ensure_buffer_stack();
1489 /* This block is copied from gras_ddt_parse__switch_to_buffer. */
1490 if (YY_CURRENT_BUFFER) {
1491 /* Flush out information for old buffer. */
1492 *(yy_c_buf_p) = (yy_hold_char);
1493 YY_CURRENT_BUFFER_LVALUE->yy_buf_pos = (yy_c_buf_p);
1494 YY_CURRENT_BUFFER_LVALUE->yy_n_chars = (yy_n_chars);
1497 /* Only push if top exists. Otherwise, replace top. */
1498 if (YY_CURRENT_BUFFER)
1499 (yy_buffer_stack_top)++;
1500 YY_CURRENT_BUFFER_LVALUE = new_buffer;
1502 /* copied from gras_ddt_parse__switch_to_buffer. */
1503 gras_ddt_parse__load_buffer_state();
1504 (yy_did_buffer_switch_on_eof) = 1;
1507 /** Removes and deletes the top of the stack, if present.
1508 * The next element becomes the new top.
1511 void gras_ddt_parse_pop_buffer_state(void)
1513 if (!YY_CURRENT_BUFFER)
1516 gras_ddt_parse__delete_buffer(YY_CURRENT_BUFFER);
1517 YY_CURRENT_BUFFER_LVALUE = NULL;
1518 if ((yy_buffer_stack_top) > 0)
1519 --(yy_buffer_stack_top);
1521 if (YY_CURRENT_BUFFER) {
1522 gras_ddt_parse__load_buffer_state();
1523 (yy_did_buffer_switch_on_eof) = 1;
1527 /* Allocates the stack if it does not exist.
1528 * Guarantees space for at least one push.
1530 static void gras_ddt_parse_ensure_buffer_stack(void)
1534 if (!(yy_buffer_stack)) {
1536 /* First allocation is just for 2 elements, since we don't know if this
1537 * scanner will even need a stack. We use 2 instead of 1 to avoid an
1538 * immediate realloc on the next call.
1541 (yy_buffer_stack) = (struct yy_buffer_state **) gras_ddt_parse_alloc
1542 (num_to_alloc * sizeof(struct yy_buffer_state *)
1544 if (!(yy_buffer_stack))
1546 ("out of dynamic memory in gras_ddt_parse_ensure_buffer_stack()");
1548 memset((yy_buffer_stack), 0,
1549 num_to_alloc * sizeof(struct yy_buffer_state *));
1551 (yy_buffer_stack_max) = num_to_alloc;
1552 (yy_buffer_stack_top) = 0;
1556 if ((yy_buffer_stack_top) >= ((yy_buffer_stack_max)) - 1) {
1558 /* Increase the buffer to prepare for a possible push. */
1559 int grow_size = 8 /* arbitrary grow size */ ;
1561 num_to_alloc = (yy_buffer_stack_max) + grow_size;
1562 (yy_buffer_stack) = (struct yy_buffer_state **) gras_ddt_parse_realloc
1563 ((yy_buffer_stack), num_to_alloc * sizeof(struct yy_buffer_state *)
1565 if (!(yy_buffer_stack))
1567 ("out of dynamic memory in gras_ddt_parse_ensure_buffer_stack()");
1569 /* zero only the new slots. */
1570 memset((yy_buffer_stack) + (yy_buffer_stack_max), 0,
1571 grow_size * sizeof(struct yy_buffer_state *));
1572 (yy_buffer_stack_max) = num_to_alloc;
1576 /** Setup the input buffer state to scan directly from a user-specified character buffer.
1577 * @param base the character buffer
1578 * @param size the size in bytes of the character buffer
1580 * @return the newly allocated buffer state object.
1582 YY_BUFFER_STATE gras_ddt_parse__scan_buffer(char *base, yy_size_t size)
1587 base[size - 2] != YY_END_OF_BUFFER_CHAR ||
1588 base[size - 1] != YY_END_OF_BUFFER_CHAR)
1589 /* They forgot to leave room for the EOB's. */
1592 b = (YY_BUFFER_STATE) gras_ddt_parse_alloc(sizeof(struct yy_buffer_state));
1594 YY_FATAL_ERROR("out of dynamic memory in gras_ddt_parse__scan_buffer()");
1596 b->yy_buf_size = size - 2; /* "- 2" to take care of EOB's */
1597 b->yy_buf_pos = b->yy_ch_buf = base;
1598 b->yy_is_our_buffer = 0;
1599 b->yy_input_file = 0;
1600 b->yy_n_chars = b->yy_buf_size;
1601 b->yy_is_interactive = 0;
1603 b->yy_fill_buffer = 0;
1604 b->yy_buffer_status = YY_BUFFER_NEW;
1606 gras_ddt_parse__switch_to_buffer(b);
1611 /** Setup the input buffer state to scan a string. The next call to gras_ddt_parse_lex() will
1612 * scan from a @e copy of @a str.
1613 * @param yystr a NUL-terminated string to scan
1615 * @return the newly allocated buffer state object.
1616 * @note If you want to scan bytes that may contain NUL values, then use
1617 * gras_ddt_parse__scan_bytes() instead.
1619 YY_BUFFER_STATE gras_ddt_parse__scan_string(yyconst char *yystr)
1622 return gras_ddt_parse__scan_bytes(yystr, strlen(yystr));
1625 /** Setup the input buffer state to scan the given bytes. The next call to gras_ddt_parse_lex() will
1626 * scan from a @e copy of @a bytes.
1627 * @param bytes the byte buffer to scan
1628 * @param len the number of bytes in the buffer pointed to by @a bytes.
1630 * @return the newly allocated buffer state object.
1632 YY_BUFFER_STATE gras_ddt_parse__scan_bytes(yyconst char *yybytes,
1640 /* Get memory for full buffer, including space for trailing EOB's. */
1641 n = _yybytes_len + 2;
1642 buf = (char *) gras_ddt_parse_alloc(n);
1644 YY_FATAL_ERROR("out of dynamic memory in gras_ddt_parse__scan_bytes()");
1646 for (i = 0; i < _yybytes_len; ++i)
1647 buf[i] = yybytes[i];
1649 buf[_yybytes_len] = buf[_yybytes_len + 1] = YY_END_OF_BUFFER_CHAR;
1651 b = gras_ddt_parse__scan_buffer(buf, n);
1653 YY_FATAL_ERROR("bad buffer in gras_ddt_parse__scan_bytes()");
1655 /* It's okay to grow etc. this buffer, and we should throw it
1656 * away when we're done.
1658 b->yy_is_our_buffer = 1;
1663 #ifndef YY_EXIT_FAILURE
1664 #define YY_EXIT_FAILURE 2
1667 static void yy_fatal_error(yyconst char *msg)
1669 (void) fprintf(stderr, "%s\n", msg);
1670 exit(YY_EXIT_FAILURE);
1673 /* Redefine yyless() so it works in section 3 code. */
1679 /* Undo effects of setting up gras_ddt_parse_text. */ \
1680 int yyless_macro_arg = (n); \
1681 YY_LESS_LINENO(yyless_macro_arg);\
1682 gras_ddt_parse_text[gras_ddt_parse_leng] = (yy_hold_char); \
1683 (yy_c_buf_p) = gras_ddt_parse_text + yyless_macro_arg; \
1684 (yy_hold_char) = *(yy_c_buf_p); \
1685 *(yy_c_buf_p) = '\0'; \
1686 gras_ddt_parse_leng = yyless_macro_arg; \
1690 /* Accessor methods (get/set functions) to struct members. */
1692 /** Get the current line number.
1695 int gras_ddt_parse_get_lineno(void)
1698 return gras_ddt_parse_lineno;
1701 /** Get the input stream.
1704 FILE *gras_ddt_parse_get_in(void)
1706 return gras_ddt_parse_in;
1709 /** Get the output stream.
1712 FILE *gras_ddt_parse_get_out(void)
1714 return gras_ddt_parse_out;
1717 /** Get the length of the current token.
1720 int gras_ddt_parse_get_leng(void)
1722 return gras_ddt_parse_leng;
1725 /** Get the current token.
1729 char *gras_ddt_parse_get_text(void)
1731 return gras_ddt_parse_text;
1734 /** Set the current line number.
1735 * @param line_number
1738 void gras_ddt_parse_set_lineno(int line_number)
1741 gras_ddt_parse_lineno = line_number;
1744 /** Set the input stream. This does not discard the current
1746 * @param in_str A readable stream.
1748 * @see gras_ddt_parse__switch_to_buffer
1750 void gras_ddt_parse_set_in(FILE * in_str)
1752 gras_ddt_parse_in = in_str;
1755 void gras_ddt_parse_set_out(FILE * out_str)
1757 gras_ddt_parse_out = out_str;
1760 int gras_ddt_parse_get_debug(void)
1762 return gras_ddt_parse__flex_debug;
1765 void gras_ddt_parse_set_debug(int bdebug)
1767 gras_ddt_parse__flex_debug = bdebug;
1770 static int yy_init_globals(void)
1772 /* Initialization is the same as for the non-reentrant scanner.
1773 * This function is called from gras_ddt_parse_lex_destroy(), so don't allocate here.
1776 (yy_buffer_stack) = 0;
1777 (yy_buffer_stack_top) = 0;
1778 (yy_buffer_stack_max) = 0;
1779 (yy_c_buf_p) = (char *) 0;
1783 /* Defined in main.c */
1785 gras_ddt_parse_in = stdin;
1786 gras_ddt_parse_out = stdout;
1788 gras_ddt_parse_in = (FILE *) 0;
1789 gras_ddt_parse_out = (FILE *) 0;
1792 /* For future reference: Set errno on error, since we are called by
1793 * gras_ddt_parse_lex_init()
1798 /* gras_ddt_parse_lex_destroy is for both reentrant and non-reentrant scanners. */
1799 int gras_ddt_parse_lex_destroy(void)
1802 /* Pop the buffer stack, destroying each element. */
1803 while (YY_CURRENT_BUFFER) {
1804 gras_ddt_parse__delete_buffer(YY_CURRENT_BUFFER);
1805 YY_CURRENT_BUFFER_LVALUE = NULL;
1806 gras_ddt_parse_pop_buffer_state();
1809 /* Destroy the stack itself. */
1810 gras_ddt_parse_free((yy_buffer_stack));
1811 (yy_buffer_stack) = NULL;
1813 /* Reset the globals. This is important in a non-reentrant scanner so the next time
1814 * gras_ddt_parse_lex() is called, initialization will occur. */
1821 * Internal utility routines.
1825 static void yy_flex_strncpy(char *s1, yyconst char *s2, int n)
1828 for (i = 0; i < n; ++i)
1833 #ifdef YY_NEED_STRLEN
1834 static int yy_flex_strlen(yyconst char *s)
1837 for (n = 0; s[n]; ++n);
1843 void *gras_ddt_parse_alloc(yy_size_t size)
1845 return (void *) malloc(size);
1848 void *gras_ddt_parse_realloc(void *ptr, yy_size_t size)
1850 /* The cast to (char *) in the following accommodates both
1851 * implementations that use char* generic pointers, and those
1852 * that use void* generic pointers. It works with the latter
1853 * because both ANSI C and C++ allow castless assignment from
1854 * any pointer type to void*, and deal with argument conversions
1855 * as though doing an assignment.
1857 return (void *) realloc((char *) ptr, size);
1860 void gras_ddt_parse_free(void *ptr)
1862 free((char *) ptr); /* see gras_ddt_parse_realloc() for (char *) cast */
1865 #define YYTABLES_NAME "yytables"
1867 /* {space}+ { return(TOKEN_SPACE);} */
1869 void gras_ddt_parse_dump(void)
1871 switch (gras_ddt_parse_tok_num) {
1872 case GRAS_DDT_PARSE_TOKEN_LA:{
1873 printf("TOKEN_LA ");
1876 case GRAS_DDT_PARSE_TOKEN_RA:{
1877 printf("TOKEN_RA ");
1880 case GRAS_DDT_PARSE_TOKEN_WORD:{
1881 printf("TOKEN_WORD ");
1884 /* case GRAS_DDT_PARSE_TOKEN_SPACE : {printf("TOKEN_SPACE ");break;} */
1885 /* case GRAS_DDT_PARSE_TOKEN_COMMENT : {printf("TOKEN_COMMENT ");break;} */
1886 case GRAS_DDT_PARSE_TOKEN_NEWLINE:{
1887 printf("TOKEN_NEWLINE\n");
1890 case GRAS_DDT_PARSE_TOKEN_EMPTY:{
1891 printf("TOKEN_EMPTY\n");
1895 printf("Unknown token %d\n", gras_ddt_parse_tok_num);
1899 printf("-->%s<-- [line %d, pos %d]\n", gras_ddt_parse_text,
1900 gras_ddt_parse_line_pos, gras_ddt_parse_char_pos);
1904 int gras_ddt_parse_lex_n_dump(void)
1906 gras_ddt_parse_tok_num = gras_ddt_parse_lex();
1907 /* gras_ddt_parse_char_pos += strlen(gras_ddt_parse_text); */
1908 return (gras_ddt_parse_tok_num);
1911 void gras_ddt_parse_pointer_init(const char *file)
1913 gras_ddt_file_to_parse = fopen(file, "r");
1914 gras_ddt_input_buffer =
1915 gras_ddt_parse__create_buffer(gras_ddt_file_to_parse, 10);
1916 gras_ddt_parse__switch_to_buffer(gras_ddt_input_buffer);
1918 gras_ddt_parse_line_pos = 1;
1919 gras_ddt_parse_char_pos = 0;
1920 gras_ddt_parse_col_pos = 0;
1921 gras_ddt_parse_tok_num = 0;
1924 void gras_ddt_parse_pointer_close(void)
1926 gras_ddt_parse__delete_buffer(gras_ddt_input_buffer);
1927 fclose(gras_ddt_file_to_parse);
1929 gras_ddt_parse_line_pos = 1;
1930 gras_ddt_parse_char_pos = 0;
1931 gras_ddt_parse_tok_num = 0;
1934 void gras_ddt_parse_pointer_string_init(const char *string_to_parse)
1936 gras_ddt_input_buffer = gras_ddt_parse__scan_string(string_to_parse);
1937 definition = string_to_parse;
1938 gras_ddt_parse__switch_to_buffer(gras_ddt_input_buffer);
1940 gras_ddt_parse_line_pos = 1;
1941 gras_ddt_parse_char_pos = 0;
1942 gras_ddt_parse_tok_num = 0;
1945 void gras_ddt_parse_pointer_string_close(void)
1947 gras_ddt_parse__delete_buffer(gras_ddt_input_buffer);
1949 gras_ddt_parse_line_pos = 1;
1950 gras_ddt_parse_char_pos = 0;
1951 gras_ddt_parse_tok_num = 0;
1954 yyunput('\0', NULL); /* fake a use of this function to calm gcc down */
1957 /* Local variables:*/