#include "gras/DataDesc/datadesc_private.h"
#include "gras/DataDesc/ddt_parse.yy.h"
-XBT_LOG_NEW_DEFAULT_SUBCATEGORY(ddt_parse,datadesc,
+XBT_LOG_NEW_DEFAULT_SUBCATEGORY(gras_ddt_parse,gras_ddt,
"Parsing C data structures to build GRAS data description");
typedef struct s_type_modifier{
THROW0(mismatch_error,0,"End of the englobing structure or union");
}
- if (XBT_LOG_ISENABLED(ddt_parse,xbt_log_priority_debug)) {
+ if (XBT_LOG_ISENABLED(gras_ddt_parse,xbt_log_priority_debug)) {
int colon_pos;
for (colon_pos = gras_ddt_parse_col_pos;
definition[colon_pos] != ';';
char *end;
long int size=strtol(gras_ddt_parse_text, &end, 10);
- if (end == gras_ddt_parse_text || *end != '\0')
- PARSE_ERROR1("Unparsable size of array (found '%c', expected number)",*end);
+ if (end == gras_ddt_parse_text || *end != '\0') {
+ /* Not a number. Get the constant value, if any */
+ int *storage=xbt_dict_get_or_null(gras_dd_constants,gras_ddt_parse_text);
+ if (storage) {
+ size = *storage;
+ } else {
+ PARSE_ERROR1("Unparsable size of array. Found '%s', expected number or known constant. Need to use gras_datadesc_set_const(), huh?",
+ gras_ddt_parse_text);
+ }
+ }
/* replace the previously pushed type to an array of it */
change_to_fixed_array(identifiers,size);
XBT_OUT;
return res;
}
+
+xbt_dict_t gras_dd_constants;
+/** \brief Declare a constant to the parsing mecanism. See the "\#define and fixed size array" section */
+void gras_datadesc_set_const(const char*name, int value) {
+ int *stored = xbt_new(int, 1);
+ *stored=value;
+
+ xbt_dict_set(gras_dd_constants,name, stored, free);
+}