1 /* ddt_parse.h -- automatic parsing of data structures */
3 /* Copyright (c) 2004, 2006, 2007, 2009, 2010. The SimGrid Team.
4 * All rights reserved. */
6 /* This program is free software; you can redistribute it and/or modify it
7 * under the terms of the license (GNU LGPL) which comes with this package. */
10 GRAS_DDT_PARSE_TOKEN_EMPTY = 0,
11 GRAS_DDT_PARSE_TOKEN_LA = 512, /* { 'A' for the french "accolade" since there is a name conflict in english (braket/brace) */
12 GRAS_DDT_PARSE_TOKEN_RA, /* } */
13 GRAS_DDT_PARSE_TOKEN_LB, /* [ */
14 GRAS_DDT_PARSE_TOKEN_RB, /* ] */
15 GRAS_DDT_PARSE_TOKEN_LP, /* ( */
16 GRAS_DDT_PARSE_TOKEN_RP, /* ) */
17 GRAS_DDT_PARSE_TOKEN_WORD,
18 GRAS_DDT_PARSE_TOKEN_SPACE,
19 GRAS_DDT_PARSE_TOKEN_COMMENT,
20 GRAS_DDT_PARSE_TOKEN_ANNOTATE,
21 GRAS_DDT_PARSE_TOKEN_NEWLINE,
22 GRAS_DDT_PARSE_TOKEN_STAR,
23 GRAS_DDT_PARSE_TOKEN_SEMI_COLON,
24 GRAS_DDT_PARSE_TOKEN_COLON, /* impossible since the macro think that it's a arg separator.
25 But handle anyway for the *vicious* calling gras_ddt_parse manually */
26 GRAS_DDT_PARSE_TOKEN_ERROR
27 } gras_ddt_parse_token_t;
29 #define GRAS_DDT_PARSE_MAX_STR_CONST 4048
31 extern int gras_ddt_parse_line_pos;
32 extern int gras_ddt_parse_col_pos;
33 extern int gras_ddt_parse_char_pos;
34 extern int gras_ddt_parse_tok_num;
36 void gras_ddt_parse_dump(void);
37 int gras_ddt_parse_lex_n_dump(void);
38 void gras_ddt_parse_pointer_init(const char *file);
39 void gras_ddt_parse_pointer_close(void);
40 void gras_ddt_parse_pointer_string_init(const char *string_to_parse);
41 void gras_ddt_parse_pointer_string_close(void);
43 /* prototypes of the functions offered by flex */
44 int gras_ddt_parse_lex(void);
45 int gras_ddt_parse_get_lineno(void);
46 FILE *gras_ddt_parse_get_in(void);
47 FILE *gras_ddt_parse_get_out(void);
48 int gras_ddt_parse_get_leng(void);
49 char *gras_ddt_parse_get_text(void);
50 void gras_ddt_parse_set_lineno(int line_number);
51 void gras_ddt_parse_set_in(FILE * in_str);
52 void gras_ddt_parse_set_out(FILE * out_str);
53 int gras_ddt_parse_get_debug(void);
54 void gras_ddt_parse_set_debug(int bdebug);
55 int gras_ddt_parse_lex_destroy(void);
57 #define PARSE_ERROR_PRE do {
58 #define PARSE_ERROR_POST xbt_abort();} while (0)
60 #define PARSE_ERROR0(fmt) PARSE_ERROR_PRE \
61 ERROR3(fmt " at %d:%d of :\n%s", gras_ddt_parse_line_pos,gras_ddt_parse_col_pos,definition);\
63 #define PARSE_ERROR1(fmt,a) PARSE_ERROR_PRE \
64 ERROR4(fmt " at %d:%d of :\n%s",a, gras_ddt_parse_line_pos,gras_ddt_parse_col_pos,definition);\
66 #define PARSE_ERROR2(fmt,a,b) PARSE_ERROR_PRE \
67 ERROR5(fmt " at %d:%d of :\n%s",a,b, gras_ddt_parse_line_pos,gras_ddt_parse_col_pos,definition);\