Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Make PARSE_ERROR a variadic macro too.
[simgrid.git] / src / gras / DataDesc / ddt_parse.yy.h
1 /* ddt_parse.h -- automatic parsing of data structures                      */
2
3 /* Copyright (c) 2004, 2006, 2007, 2009, 2010. The SimGrid Team.
4  * All rights reserved.                                                     */
5
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. */
8
9 typedef enum {
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;
28
29 #define GRAS_DDT_PARSE_MAX_STR_CONST 4048
30
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;
35
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);
42
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);
56
57 #define PARSE_ERROR(...)                                                \
58   PARSE_ERROR_(__VA_ARGS__,                                             \
59                gras_ddt_parse_line_pos, gras_ddt_parse_col_pos, definition)
60 #define PARSE_ERROR_(fmt, ...)                           \
61   do {                                                   \
62     XBT_ERROR(fmt " at %d:%d of :\n%s", __VA_ARGS__);   \
63     xbt_abort();                                         \
64   } while (0)