Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Move datadesc and TCP sockets from GRAS to XBT.
[simgrid.git] / src / xbt / 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   XBT_DDT_PARSE_TOKEN_EMPTY = 0,
11   XBT_DDT_PARSE_TOKEN_LA = 512,        /* { 'A' for the french "accolade" since there is a name conflict in english (braket/brace) */
12   XBT_DDT_PARSE_TOKEN_RA,      /* } */
13   XBT_DDT_PARSE_TOKEN_LB,      /* [ */
14   XBT_DDT_PARSE_TOKEN_RB,      /* ] */
15   XBT_DDT_PARSE_TOKEN_LP,      /* ( */
16   XBT_DDT_PARSE_TOKEN_RP,      /* ) */
17   XBT_DDT_PARSE_TOKEN_WORD,
18   XBT_DDT_PARSE_TOKEN_SPACE,
19   XBT_DDT_PARSE_TOKEN_COMMENT,
20   XBT_DDT_PARSE_TOKEN_ANNOTATE,
21   XBT_DDT_PARSE_TOKEN_NEWLINE,
22   XBT_DDT_PARSE_TOKEN_STAR,
23   XBT_DDT_PARSE_TOKEN_SEMI_COLON,
24   XBT_DDT_PARSE_TOKEN_COLON,   /* impossible since the macro think that it's a arg separator. 
25                                    But handle anyway for the *vicious* calling xbt_ddt_parse manually */
26   XBT_DDT_PARSE_TOKEN_ERROR
27 } xbt_ddt_parse_token_t;
28
29 #define XBT_DDT_PARSE_MAX_STR_CONST 4048
30
31 extern int xbt_ddt_parse_line_pos;
32 extern int xbt_ddt_parse_col_pos;
33 extern int xbt_ddt_parse_char_pos;
34 extern int xbt_ddt_parse_tok_num;
35
36 void xbt_ddt_parse_dump(void);
37 int xbt_ddt_parse_lex_n_dump(void);
38 void xbt_ddt_parse_pointer_init(const char *file);
39 void xbt_ddt_parse_pointer_close(void);
40 void xbt_ddt_parse_pointer_string_init(const char *string_to_parse);
41 void xbt_ddt_parse_pointer_string_close(void);
42
43 /* prototypes of the functions offered by flex */
44 int xbt_ddt_parse_lex(void);
45 int xbt_ddt_parse_get_lineno(void);
46 FILE *xbt_ddt_parse_get_in(void);
47 FILE *xbt_ddt_parse_get_out(void);
48 int xbt_ddt_parse_get_leng(void);
49 char *xbt_ddt_parse_get_text(void);
50 void xbt_ddt_parse_set_lineno(int line_number);
51 void xbt_ddt_parse_set_in(FILE * in_str);
52 void xbt_ddt_parse_set_out(FILE * out_str);
53 int xbt_ddt_parse_get_debug(void);
54 void xbt_ddt_parse_set_debug(int bdebug);
55 int xbt_ddt_parse_lex_destroy(void);
56
57 #define PARSE_ERROR(...)                                                \
58   PARSE_ERROR_(__VA_ARGS__,                                             \
59                xbt_ddt_parse_line_pos, xbt_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)