- /* Handle annotation */
- s_identifier_t array;
- char *keyname = NULL;
- char *keyval = NULL;
- memset(&array,0,sizeof(array));
- if (strcmp(gras_ddt_parse_text,"GRAS_ANNOTE"))
- PARSE_ERROR1("Unparsable symbol: Expected 'GRAS_ANNOTE', got '%s'",gras_ddt_parse_text);
-
- gras_ddt_parse_tok_num = gras_ddt_parse_lex_n_dump();
- if (gras_ddt_parse_tok_num != GRAS_DDT_PARSE_TOKEN_LP)
- PARSE_ERROR1("Unparsable annotation: Expected parenthesis, got '%s'",gras_ddt_parse_text);
-
- while ( (gras_ddt_parse_tok_num = gras_ddt_parse_lex_n_dump()) == GRAS_DDT_PARSE_TOKEN_EMPTY );
-
- if (gras_ddt_parse_tok_num != GRAS_DDT_PARSE_TOKEN_WORD)
- PARSE_ERROR1("Unparsable annotation: Expected key name, got '%s'",gras_ddt_parse_text);
- keyname = (char*)strdup(gras_ddt_parse_text);
-
- while ( (gras_ddt_parse_tok_num = gras_ddt_parse_lex_n_dump()) == GRAS_DDT_PARSE_TOKEN_EMPTY );
-
- if (gras_ddt_parse_tok_num != GRAS_DDT_PARSE_TOKEN_COLON)
- PARSE_ERROR1("Unparsable annotation: expected ',' after the key name, got '%s'",gras_ddt_parse_text);
-
- while ( (gras_ddt_parse_tok_num = gras_ddt_parse_lex_n_dump()) == GRAS_DDT_PARSE_TOKEN_EMPTY );
-
- if (gras_ddt_parse_tok_num != GRAS_DDT_PARSE_TOKEN_WORD)
- PARSE_ERROR1("Unparsable annotation: Expected key value, got '%s'",gras_ddt_parse_text);
- keyval = (char*)strdup(gras_ddt_parse_text);
-
- while ( (gras_ddt_parse_tok_num = gras_ddt_parse_lex_n_dump()) == GRAS_DDT_PARSE_TOKEN_EMPTY );
-
- if (gras_ddt_parse_tok_num != GRAS_DDT_PARSE_TOKEN_RP)
- PARSE_ERROR1("Unparsable annotation: Expected parenthesis, got '%s'",gras_ddt_parse_text);
-
- /* Done with parsing the annotation. Now deal with it by replacing previously pushed type with the right one */
-
- DEBUG2("Anotation: %s=%s",keyname,keyval);
- if (!strcmp(keyname,"size")) {
- gras_free(keyname);
- if (!identifier.tm.is_ref)
- PARSE_ERROR0("Size annotation for a field not being a reference");
- identifier.tm.is_ref--;
-
- if (!strcmp(keyval,"1")) {
- change_to_ref(identifiers);
- gras_free(keyval);
- continue;
- } else {
- char *p;
- int fixed = 1;
- for (p = keyval; *p != '\0'; p++)
- if (! isdigit(*p) )
- fixed = 0;
- if (fixed) {
- change_to_fixed_array(identifiers,atoi(keyval));
- change_to_ref(identifiers);
- gras_free(keyval);
- continue;
-
- } else {
- change_to_ref_pop_array(identifiers);
- gras_dynar_push(fields_to_push,&keyval);
- continue;
- }
- }
- RAISE_IMPOSSIBLE;
-
- } else {
- PARSE_ERROR1("Unknown annotation type: '%s'",keyname);
- }
- continue;
-
- /* End of annotation handling */
+ /* Handle annotation */
+ s_identifier_t array;
+ char *keyname = NULL;
+ char *keyval = NULL;
+ memset(&array, 0, sizeof(array));
+ if (strcmp(gras_ddt_parse_text, "GRAS_ANNOTE"))
+ PARSE_ERROR1("Unparsable symbol: Expected 'GRAS_ANNOTE', got '%s'",
+ gras_ddt_parse_text);
+
+ gras_ddt_parse_tok_num = gras_ddt_parse_lex_n_dump();
+ if (gras_ddt_parse_tok_num != GRAS_DDT_PARSE_TOKEN_LP)
+ PARSE_ERROR1
+ ("Unparsable annotation: Expected parenthesis, got '%s'",
+ gras_ddt_parse_text);
+
+ while ((gras_ddt_parse_tok_num =
+ gras_ddt_parse_lex_n_dump()) == GRAS_DDT_PARSE_TOKEN_EMPTY);
+
+ if (gras_ddt_parse_tok_num != GRAS_DDT_PARSE_TOKEN_WORD)
+ PARSE_ERROR1("Unparsable annotation: Expected key name, got '%s'",
+ gras_ddt_parse_text);
+ keyname = (char *) strdup(gras_ddt_parse_text);
+
+ while ((gras_ddt_parse_tok_num =
+ gras_ddt_parse_lex_n_dump()) == GRAS_DDT_PARSE_TOKEN_EMPTY);
+
+ if (gras_ddt_parse_tok_num != GRAS_DDT_PARSE_TOKEN_COLON)
+ PARSE_ERROR1
+ ("Unparsable annotation: expected ',' after the key name, got '%s'",
+ gras_ddt_parse_text);
+
+ while ((gras_ddt_parse_tok_num =
+ gras_ddt_parse_lex_n_dump()) == GRAS_DDT_PARSE_TOKEN_EMPTY);
+
+ /* get the value */
+
+ if (gras_ddt_parse_tok_num != GRAS_DDT_PARSE_TOKEN_WORD)
+ PARSE_ERROR1("Unparsable annotation: Expected key value, got '%s'",
+ gras_ddt_parse_text);
+ keyval = (char *) strdup(gras_ddt_parse_text);
+
+ while ((gras_ddt_parse_tok_num =
+ gras_ddt_parse_lex_n_dump()) == GRAS_DDT_PARSE_TOKEN_EMPTY);
+
+ /* Done with parsing the annotation. Now deal with it by replacing previously pushed type with the right one */
+
+ DEBUG2("Anotation: %s=%s", keyname, keyval);
+ if (!strcmp(keyname, "size")) {
+ free(keyname);
+ if (!identifier.tm.is_ref)
+ PARSE_ERROR0("Size annotation for a field not being a reference");
+ identifier.tm.is_ref--;
+
+ if (!strcmp(keyval, "1")) {
+ change_to_ref(identifiers);
+ free(keyval);
+ } else {
+ char *p;
+ int fixed = 1;
+ for (p = keyval; *p != '\0'; p++)
+ if (!isdigit(*p))
+ fixed = 0;
+ if (fixed) {
+ change_to_fixed_array(identifiers, atoi(keyval));
+ change_to_ref(identifiers);
+ free(keyval);
+
+ } else {
+ change_to_ref_pop_array(identifiers);
+ xbt_dynar_push(fields_to_push, &keyval);
+ }
+ }
+ } else if (!strcmp(keyname, "subtype")) {
+ gras_datadesc_type_t subtype = gras_datadesc_by_name(keyval);
+ if (identifier.tm.is_matrix) {
+ change_to_matrix_of(identifiers, subtype);
+ identifier.tm.is_matrix = -1;
+ } else if (identifier.tm.is_dynar) {
+ change_to_dynar_of(identifiers, subtype);
+ identifier.tm.is_dynar = -1;
+ } else {
+ PARSE_ERROR1
+ ("subtype annotation only accepted for dynars and matrices, but passed to '%s'",
+ identifier.type_name);
+ }
+ free(keyval);
+ } else if (!strcmp(keyname, "free_f")) {
+ int *storage = xbt_dict_get_or_null(gras_dd_constants, keyval);
+ if (!storage)
+ PARSE_ERROR1
+ ("value for free_f annotation of field %s is not a known constant",
+ identifier.name);
+ if (identifier.tm.is_matrix == -1) {
+ add_free_f(identifiers, *(void_f_pvoid_t *) storage);
+ identifier.tm.is_matrix = 0;
+ } else if (identifier.tm.is_dynar == -1) {
+ add_free_f(identifiers, *(void_f_pvoid_t *) storage);
+ identifier.tm.is_dynar = 0;
+ } else {
+ PARSE_ERROR1
+ ("free_f annotation only accepted for dynars and matrices which subtype is already declared (field %s)",
+ identifier.name);
+ }
+ free(keyval);
+ } else {
+ free(keyval);
+ PARSE_ERROR1("Unknown annotation type: '%s'", keyname);
+ }
+
+ /* Get all the multipliers */
+ while (gras_ddt_parse_tok_num == GRAS_DDT_PARSE_TOKEN_STAR) {
+
+ gras_ddt_parse_tok_num = gras_ddt_parse_lex_n_dump();
+
+ if (gras_ddt_parse_tok_num != GRAS_DDT_PARSE_TOKEN_WORD)
+ PARSE_ERROR1
+ ("Unparsable annotation: Expected field name after '*', got '%s'",
+ gras_ddt_parse_text);
+
+ keyval = xbt_malloc(strlen(gras_ddt_parse_text) + 2);
+ sprintf(keyval, "*%s", gras_ddt_parse_text);
+
+ /* ask caller to push field as a multiplier */
+ xbt_dynar_push(fields_to_push, &keyval);
+
+ /* skip blanks after this block */
+ while ((gras_ddt_parse_tok_num = gras_ddt_parse_lex_n_dump())
+ == GRAS_DDT_PARSE_TOKEN_EMPTY);
+ }
+
+ if (gras_ddt_parse_tok_num != GRAS_DDT_PARSE_TOKEN_RP)
+ PARSE_ERROR1
+ ("Unparsable annotation: Expected parenthesis, got '%s'",
+ gras_ddt_parse_text);
+
+ continue;
+
+ /* End of annotation handling */