aboutsummaryrefslogtreecommitdiffstats
path: root/src/mds-kbdc/validate-tree.c
diff options
context:
space:
mode:
authorMattias Andrée <maandree@kth.se>2017-11-05 14:50:38 +0100
committerMattias Andrée <maandree@kth.se>2017-11-05 14:50:38 +0100
commit9ed21175ac00f57f6abf3da84e82098e68fa3e94 (patch)
tree6235ac14c78fe0bbc074eb5146a641ba0e08fb5f /src/mds-kbdc/validate-tree.c
parentUpdate year and e-mail address (diff)
downloadmds-9ed21175ac00f57f6abf3da84e82098e68fa3e94.tar.gz
mds-9ed21175ac00f57f6abf3da84e82098e68fa3e94.tar.bz2
mds-9ed21175ac00f57f6abf3da84e82098e68fa3e94.tar.xz
Work on changing style
Signed-off-by: Mattias Andrée <maandree@kth.se>
Diffstat (limited to 'src/mds-kbdc/validate-tree.c')
-rw-r--r--src/mds-kbdc/validate-tree.c514
1 files changed, 252 insertions, 262 deletions
diff --git a/src/mds-kbdc/validate-tree.c b/src/mds-kbdc/validate-tree.c
index 632b9a8..80ef7d5 100644
--- a/src/mds-kbdc/validate-tree.c
+++ b/src/mds-kbdc/validate-tree.c
@@ -28,12 +28,12 @@
/**
* Tree type constant shortener
*/
-#define C(TYPE) MDS_KBDC_TREE_TYPE_##TYPE
+#define C(TYPE) MDS_KBDC_TREE_TYPE_##TYPE
/**
* Check the value of `innermost_visit`
*/
-#define VISITING(TYPE) (innermost_visit == MDS_KBDC_TREE_TYPE_##TYPE)
+#define VISITING(TYPE) (innermost_visit == MDS_KBDC_TREE_TYPE_##TYPE)
/**
* Add an error with “included from here”-notes to the error list
@@ -44,20 +44,20 @@
* @param ...:const char*, ... Error description format string and arguments
* @scope error:mds_kbdc_parse_error_t* Variable where the new error will be stored
*/
-#define NEW_ERROR(NODE, PTR, SEVERITY, ...) \
- NEW_ERROR_WITH_INCLUDES(NODE, PTR, SEVERITY, __VA_ARGS__)
+#define NEW_ERROR(NODE, PTR, SEVERITY, ...)\
+ NEW_ERROR_WITH_INCLUDES(NODE, PTR, SEVERITY, __VA_ARGS__)
/**
* Variable whether the latest created error is stored
*/
-static mds_kbdc_parse_error_t* error;
+static mds_kbdc_parse_error_t *error;
/**
* The parameter of `validate_tree`
*/
-static mds_kbdc_parsed_t* restrict result;
+static mds_kbdc_parsed_t *restrict result;
/**
* The number visited for-statements
@@ -67,22 +67,22 @@ static size_t fors = 0;
/**
* The function definition that is currently being visited
*/
-static mds_kbdc_tree_function_t* function = NULL;
+static mds_kbdc_tree_function_t *function = NULL;
/**
* The macro definition that is currently being visited
*/
-static mds_kbdc_tree_macro_t* macro = NULL;
+static mds_kbdc_tree_macro_t *macro = NULL;
/**
* The information clause that is currently being visited
*/
-static mds_kbdc_tree_information_t* information = NULL;
+static mds_kbdc_tree_information_t *information = NULL;
/**
* The assumption clause that is currently being visited
*/
-static mds_kbdc_tree_assumption_t* assumption = NULL;
+static mds_kbdc_tree_assumption_t *assumption = NULL;
/**
* The value `includes_ptr` had when `function`,
@@ -105,7 +105,7 @@ static int innermost_visit = -1;
* @param tree The tree to validate
* @return Zero on success, -1 on error
*/
-static int validate_subtree(mds_kbdc_tree_t* restrict tree);
+static int validate_subtree(mds_kbdc_tree_t *restrict tree);
@@ -115,17 +115,18 @@ static int validate_subtree(mds_kbdc_tree_t* restrict tree);
* @param tree The tree to validate
* @return Zero on success, -1 on error
*/
-static int validate_include(mds_kbdc_tree_include_t* restrict tree)
+static int
+validate_include(mds_kbdc_tree_include_t *restrict tree)
{
- void* data;
- int r;
- fail_if (mds_kbdc_include_stack_push(tree, &data));
- r = validate_subtree(tree->inner);
- mds_kbdc_include_stack_pop(data);
- fail_if (r);
- return 0;
- fail:
- return -1;
+ void *data;
+ int r;
+ fail_if (mds_kbdc_include_stack_push(tree, &data));
+ r = validate_subtree(tree->inner);
+ mds_kbdc_include_stack_pop(data);
+ fail_if (r);
+ return 0;
+fail:
+ return -1;
}
@@ -135,34 +136,30 @@ static int validate_include(mds_kbdc_tree_include_t* restrict tree)
* @param tree The tree to validate
* @return Zero on success, -1 on error
*/
-static int validate_function(mds_kbdc_tree_function_t* restrict tree)
+static int
+validate_function(mds_kbdc_tree_function_t *restrict tree)
{
- int r;
- if (VISITING(FUNCTION))
- {
- NEW_ERROR(tree, includes_ptr, ERROR, "nested function definition");
- NEW_ERROR(function, def_includes_ptr, NOTE, "outer function defined here");
- return 0;
- }
- else if (VISITING(MACRO))
- {
- NEW_ERROR(tree, includes_ptr, ERROR, "function definition inside macro definition");
- NEW_ERROR(macro, def_includes_ptr, NOTE, "outer macro defined here");
- return 0;
- }
- else if (VISITING(INFORMATION))
- {
- NEW_ERROR(tree, includes_ptr, ERROR, "function definition inside information clause");
- NEW_ERROR(information, def_includes_ptr, NOTE, "outer information clause defined here");
- return 0;
- }
- innermost_visit = tree->type;
- function = tree;
- def_includes_ptr = includes_ptr;
- r = validate_subtree(tree->inner);
- return function = NULL, r;
- fail:
- return -1;
+ int r;
+ if (VISITING(FUNCTION)) {
+ NEW_ERROR(tree, includes_ptr, ERROR, "nested function definition");
+ NEW_ERROR(function, def_includes_ptr, NOTE, "outer function defined here");
+ return 0;
+ } else if (VISITING(MACRO)) {
+ NEW_ERROR(tree, includes_ptr, ERROR, "function definition inside macro definition");
+ NEW_ERROR(macro, def_includes_ptr, NOTE, "outer macro defined here");
+ return 0;
+ } else if (VISITING(INFORMATION)) {
+ NEW_ERROR(tree, includes_ptr, ERROR, "function definition inside information clause");
+ NEW_ERROR(information, def_includes_ptr, NOTE, "outer information clause defined here");
+ return 0;
+ }
+ innermost_visit = tree->type;
+ function = tree;
+ def_includes_ptr = includes_ptr;
+ r = validate_subtree(tree->inner);
+ return function = NULL, r;
+fail:
+ return -1;
}
@@ -172,34 +169,30 @@ static int validate_function(mds_kbdc_tree_function_t* restrict tree)
* @param tree The tree to validate
* @return Zero on success, -1 on error
*/
-static int validate_macro(mds_kbdc_tree_macro_t* restrict tree)
+static int
+validate_macro(mds_kbdc_tree_macro_t *restrict tree)
{
- int r;
- if (VISITING(FUNCTION))
- {
- NEW_ERROR(tree, includes_ptr, ERROR, "macro definition inside function definition");
- NEW_ERROR(function, def_includes_ptr, NOTE, "outer function definition defined here");
- return 0;
- }
- else if (VISITING(MACRO))
- {
- NEW_ERROR(tree, includes_ptr, ERROR, "nested macro definition");
- NEW_ERROR(macro, def_includes_ptr, NOTE, "outer macro defined here");
- return 0;
- }
- else if (VISITING(INFORMATION))
- {
- NEW_ERROR(tree, includes_ptr, ERROR, "macro definition inside information clause");
- NEW_ERROR(information, def_includes_ptr, NOTE, "outer information clause defined here");
- return 0;
- }
- innermost_visit = tree->type;
- macro = tree;
- def_includes_ptr = includes_ptr;
- r = validate_subtree(tree->inner);
- return macro = NULL, r;
- fail:
- return -1;
+ int r;
+ if (VISITING(FUNCTION)) {
+ NEW_ERROR(tree, includes_ptr, ERROR, "macro definition inside function definition");
+ NEW_ERROR(function, def_includes_ptr, NOTE, "outer function definition defined here");
+ return 0;
+ } else if (VISITING(MACRO)) {
+ NEW_ERROR(tree, includes_ptr, ERROR, "nested macro definition");
+ NEW_ERROR(macro, def_includes_ptr, NOTE, "outer macro defined here");
+ return 0;
+ } else if (VISITING(INFORMATION)) {
+ NEW_ERROR(tree, includes_ptr, ERROR, "macro definition inside information clause");
+ NEW_ERROR(information, def_includes_ptr, NOTE, "outer information clause defined here");
+ return 0;
+ }
+ innermost_visit = tree->type;
+ macro = tree;
+ def_includes_ptr = includes_ptr;
+ r = validate_subtree(tree->inner);
+ return macro = NULL, r;
+fail:
+ return -1;
}
@@ -209,40 +202,34 @@ static int validate_macro(mds_kbdc_tree_macro_t* restrict tree)
* @param tree The tree to validate
* @return Zero on success, -1 on error
*/
-static int validate_information(mds_kbdc_tree_information_t* restrict tree)
+static int
+validate_information(mds_kbdc_tree_information_t *restrict tree)
{
- int r;
- if (VISITING(FUNCTION))
- {
- NEW_ERROR(tree, includes_ptr, ERROR, "information clause inside function definition");
- NEW_ERROR(function, def_includes_ptr, NOTE, "outer function definition defined here");
- return 0;
- }
- else if (VISITING(MACRO))
- {
- NEW_ERROR(tree, includes_ptr, ERROR, "information clause inside macro definition");
- NEW_ERROR(macro, def_includes_ptr, NOTE, "outer macro defined here");
- return 0;
- }
- else if (VISITING(INFORMATION))
- {
- NEW_ERROR(tree, includes_ptr, ERROR, "nested information clause");
- NEW_ERROR(information, def_includes_ptr, NOTE, "outer information clause defined here");
- return 0;
- }
- else if (VISITING(ASSUMPTION))
- {
- NEW_ERROR(tree, includes_ptr, ERROR, "information clause inside assumption clause");
- NEW_ERROR(assumption, def_includes_ptr, NOTE, "outer assumption clause defined here");
- return 0;
- }
- innermost_visit = tree->type;
- information = tree;
- def_includes_ptr = includes_ptr;
- r = validate_subtree(tree->inner);
- return information = NULL, r;
- fail:
- return -1;
+ int r;
+ if (VISITING(FUNCTION)) {
+ NEW_ERROR(tree, includes_ptr, ERROR, "information clause inside function definition");
+ NEW_ERROR(function, def_includes_ptr, NOTE, "outer function definition defined here");
+ return 0;
+ } else if (VISITING(MACRO)) {
+ NEW_ERROR(tree, includes_ptr, ERROR, "information clause inside macro definition");
+ NEW_ERROR(macro, def_includes_ptr, NOTE, "outer macro defined here");
+ return 0;
+ } else if (VISITING(INFORMATION)) {
+ NEW_ERROR(tree, includes_ptr, ERROR, "nested information clause");
+ NEW_ERROR(information, def_includes_ptr, NOTE, "outer information clause defined here");
+ return 0;
+ } else if (VISITING(ASSUMPTION)) {
+ NEW_ERROR(tree, includes_ptr, ERROR, "information clause inside assumption clause");
+ NEW_ERROR(assumption, def_includes_ptr, NOTE, "outer assumption clause defined here");
+ return 0;
+ }
+ innermost_visit = tree->type;
+ information = tree;
+ def_includes_ptr = includes_ptr;
+ r = validate_subtree(tree->inner);
+ return information = NULL, r;
+fail:
+ return -1;
}
@@ -252,40 +239,34 @@ static int validate_information(mds_kbdc_tree_information_t* restrict tree)
* @param tree The tree to validate
* @return Zero on success, -1 on error
*/
-static int validate_assumption(mds_kbdc_tree_assumption_t* restrict tree)
+static int
+validate_assumption(mds_kbdc_tree_assumption_t *restrict tree)
{
- int r;
- if (VISITING(FUNCTION))
- {
- NEW_ERROR(tree, includes_ptr, ERROR, "assumption clause inside function definition");
- NEW_ERROR(function, def_includes_ptr, NOTE, "outer function definition defined here");
- return 0;
- }
- else if (VISITING(MACRO))
- {
- NEW_ERROR(tree, includes_ptr, ERROR, "assumption clause inside macro definition");
- NEW_ERROR(macro, def_includes_ptr, NOTE, "outer macro defined here");
- return 0;
- }
- else if (VISITING(INFORMATION))
- {
- NEW_ERROR(tree, includes_ptr, ERROR, "assumption clause inside information clause");
- NEW_ERROR(information, def_includes_ptr, NOTE, "outer information clause defined here");
- return 0;
- }
- else if (VISITING(ASSUMPTION))
- {
- NEW_ERROR(tree, includes_ptr, ERROR, "nested assumption clause");
- NEW_ERROR(assumption, def_includes_ptr, NOTE, "outer assumption clause defined here");
- return 0;
- }
- innermost_visit = tree->type;
- assumption = tree;
- def_includes_ptr = includes_ptr;
- r = validate_subtree(tree->inner);
- return assumption = NULL, r;
- fail:
- return -1;
+ int r;
+ if (VISITING(FUNCTION)) {
+ NEW_ERROR(tree, includes_ptr, ERROR, "assumption clause inside function definition");
+ NEW_ERROR(function, def_includes_ptr, NOTE, "outer function definition defined here");
+ return 0;
+ } else if (VISITING(MACRO)) {
+ NEW_ERROR(tree, includes_ptr, ERROR, "assumption clause inside macro definition");
+ NEW_ERROR(macro, def_includes_ptr, NOTE, "outer macro defined here");
+ return 0;
+ } else if (VISITING(INFORMATION)) {
+ NEW_ERROR(tree, includes_ptr, ERROR, "assumption clause inside information clause");
+ NEW_ERROR(information, def_includes_ptr, NOTE, "outer information clause defined here");
+ return 0;
+ } else if (VISITING(ASSUMPTION)) {
+ NEW_ERROR(tree, includes_ptr, ERROR, "nested assumption clause");
+ NEW_ERROR(assumption, def_includes_ptr, NOTE, "outer assumption clause defined here");
+ return 0;
+ }
+ innermost_visit = tree->type;
+ assumption = tree;
+ def_includes_ptr = includes_ptr;
+ r = validate_subtree(tree->inner);
+ return assumption = NULL, r;
+fail:
+ return -1;
}
@@ -295,25 +276,26 @@ static int validate_assumption(mds_kbdc_tree_assumption_t* restrict tree)
* @param tree The tree to validate
* @return Zero on success, -1 on error
*/
-static int validate_map(mds_kbdc_tree_map_t* restrict tree)
+static int
+validate_map(mds_kbdc_tree_map_t *restrict tree)
{
- int is_value = tree->result == NULL;
- if (is_value);
- /* We do not want value-statments outside function
- * definitions, however, we do want \set/3 to be usable,
- * from anywhere, even indirectly, therefore we cannot,
- * at this process level, determine whether a
- * value-statement is used correctly or not.
- */
- else if (VISITING(INFORMATION))
- NEW_ERROR(tree, includes_ptr, ERROR, "mapping-statement inside information clause");
- else if (VISITING(ASSUMPTION))
- NEW_ERROR(tree, includes_ptr, ERROR, "mapping-statement inside assumption clause");
- else if (VISITING(FUNCTION))
- NEW_ERROR(tree, includes_ptr, ERROR, "mapping-statement inside function definition");
- return 0;
+ int is_value = tree->result == NULL;
+ if (is_value)
+ /* We do not want value-statments outside function
+ * definitions, however, we do want \set/3 to be usable,
+ * from anywhere, even indirectly, therefore we cannot,
+ * at this process level, determine whether a
+ * value-statement is used correctly or not.
+ */;
+ else if (VISITING(INFORMATION))
+ NEW_ERROR(tree, includes_ptr, ERROR, "mapping-statement inside information clause");
+ else if (VISITING(ASSUMPTION))
+ NEW_ERROR(tree, includes_ptr, ERROR, "mapping-statement inside assumption clause");
+ else if (VISITING(FUNCTION))
+ NEW_ERROR(tree, includes_ptr, ERROR, "mapping-statement inside function definition");
+ return 0;
fail:
- return -1;
+ return -1;
}
@@ -323,17 +305,18 @@ static int validate_map(mds_kbdc_tree_map_t* restrict tree)
* @param tree The tree to validate
* @return Zero on success, -1 on error
*/
-static int validate_macro_call(mds_kbdc_tree_macro_call_t* restrict tree)
+static int
+validate_macro_call(mds_kbdc_tree_macro_call_t *restrict tree)
{
- if (VISITING(INFORMATION))
- NEW_ERROR(tree, includes_ptr, ERROR, "macro call inside information clause");
- else if (VISITING(ASSUMPTION))
- NEW_ERROR(tree, includes_ptr, ERROR, "macro call inside assumption clause");
- else if (VISITING(FUNCTION))
- NEW_ERROR(tree, includes_ptr, ERROR, "macro call inside function definition");
- return 0;
- fail:
- return -1;
+ if (VISITING(INFORMATION))
+ NEW_ERROR(tree, includes_ptr, ERROR, "macro call inside information clause");
+ else if (VISITING(ASSUMPTION))
+ NEW_ERROR(tree, includes_ptr, ERROR, "macro call inside assumption clause");
+ else if (VISITING(FUNCTION))
+ NEW_ERROR(tree, includes_ptr, ERROR, "macro call inside function definition");
+ return 0;
+fail:
+ return -1;
}
@@ -343,14 +326,15 @@ static int validate_macro_call(mds_kbdc_tree_macro_call_t* restrict tree)
* @param tree The tree to validate
* @return Zero on success, -1 on error
*/
-static int validate_for(mds_kbdc_tree_for_t* restrict tree)
+static int
+validate_for(mds_kbdc_tree_for_t *restrict tree)
{
- int r;
- fors++, r = validate_subtree(tree->inner), fors--;
- fail_if (r);
- return 0;
- fail:
- return -1;
+ int r;
+ fors++, r = validate_subtree(tree->inner), fors--;
+ fail_if (r);
+ return 0;
+fail:
+ return -1;
}
@@ -360,12 +344,13 @@ static int validate_for(mds_kbdc_tree_for_t* restrict tree)
* @param tree The tree to validate
* @return Zero on success, -1 on error
*/
-static int validate_if(mds_kbdc_tree_if_t* restrict tree)
+static int
+validate_if(mds_kbdc_tree_if_t *restrict tree)
{
- fail_if ((validate_subtree(tree->inner) || validate_subtree(tree->otherwise)));
- return 0;
- fail:
- return -1;
+ fail_if ((validate_subtree(tree->inner) || validate_subtree(tree->otherwise)));
+ return 0;
+fail:
+ return -1;
}
@@ -375,13 +360,14 @@ static int validate_if(mds_kbdc_tree_if_t* restrict tree)
* @param tree The tree to validate
* @return Zero on success, -1 on error
*/
-static int validate_return(mds_kbdc_tree_return_t* restrict tree)
+static int
+validate_return(mds_kbdc_tree_return_t *restrict tree)
{
- if ((function == NULL) && (macro == NULL))
- NEW_ERROR(tree, includes_ptr, ERROR, "‘return’ outside function and macro definition");
- return 0;
- fail:
- return -1;
+ if (!function && !macro)
+ NEW_ERROR(tree, includes_ptr, ERROR, "‘return’ outside function and macro definition");
+ return 0;
+fail:
+ return -1;
}
@@ -391,13 +377,14 @@ static int validate_return(mds_kbdc_tree_return_t* restrict tree)
* @param tree The tree to validate
* @return Zero on success, -1 on error
*/
-static int validate_break(mds_kbdc_tree_break_t* restrict tree)
+static int
+validate_break(mds_kbdc_tree_break_t *restrict tree)
{
- if (fors == 0)
- NEW_ERROR(tree, includes_ptr, ERROR, "‘break’ outside ‘for’");
- return 0;
- fail:
- return -1;
+ if (!fors)
+ NEW_ERROR(tree, includes_ptr, ERROR, "‘break’ outside ‘for’");
+ return 0;
+fail:
+ return -1;
}
@@ -407,13 +394,14 @@ static int validate_break(mds_kbdc_tree_break_t* restrict tree)
* @param tree The tree to validate
* @return Zero on success, -1 on error
*/
-static int validate_continue(mds_kbdc_tree_continue_t* restrict tree)
+static int
+validate_continue(mds_kbdc_tree_continue_t *restrict tree)
{
- if (fors == 0)
- NEW_ERROR(tree, includes_ptr, ERROR, "‘continue’ outside ‘for’");
- return 0;
- fail:
- return -1;
+ if (!fors)
+ NEW_ERROR(tree, includes_ptr, ERROR, "‘continue’ outside ‘for’");
+ return 0;
+fail:
+ return -1;
}
@@ -423,13 +411,14 @@ static int validate_continue(mds_kbdc_tree_continue_t* restrict tree)
* @param tree The tree to validate
* @return Zero on success, -1 on error
*/
-static int validate_assumption_data(mds_kbdc_tree_t* restrict tree)
+static int
+validate_assumption_data(mds_kbdc_tree_t *restrict tree)
{
- if (assumption == NULL)
- NEW_ERROR(tree, includes_ptr, ERROR, "assumption outside assumption clause");
- return 0;
- fail:
- return -1;
+ if (!assumption)
+ NEW_ERROR(tree, includes_ptr, ERROR, "assumption outside assumption clause");
+ return 0;
+fail:
+ return -1;
}
@@ -439,13 +428,14 @@ static int validate_assumption_data(mds_kbdc_tree_t* restrict tree)
* @param tree The tree to validate
* @return Zero on success, -1 on error
*/
-static int validate_information_data(mds_kbdc_tree_t* restrict tree)
+static int
+validate_information_data(mds_kbdc_tree_t *restrict tree)
{
- if (information == NULL)
- NEW_ERROR(tree, includes_ptr, ERROR, "information outside information clause");
- return 0;
- fail:
- return -1;
+ if (!information)
+ NEW_ERROR(tree, includes_ptr, ERROR, "information outside information clause");
+ return 0;
+fail:
+ return -1;
}
@@ -455,48 +445,48 @@ static int validate_information_data(mds_kbdc_tree_t* restrict tree)
* @param tree The tree to validate
* @return Zero on success, -1 on error
*/
-static int validate_subtree(mds_kbdc_tree_t* restrict tree)
+static int
+validate_subtree(mds_kbdc_tree_t *restrict tree)
{
-#define v(type) fail_if (validate_##type(&(tree->type)))
-#define V(type) fail_if (validate_##type(&(tree->type##_)))
- int old_innermost_visit = innermost_visit;
- again:
- if (tree == NULL)
- return 0;
-
- switch (tree->type)
- {
- case C(INFORMATION): v(information); break;
- case C(INCLUDE): v(include); break;
- case C(FUNCTION): v(function); break;
- case C(MACRO): v(macro); break;
- case C(ASSUMPTION): v(assumption); break;
- case C(FOR): V(for); break;
- case C(IF): V(if); break;
- case C(MAP): v(map); break;
- case C(MACRO_CALL): v(macro_call); break;
- case C(RETURN): V(return); break;
- case C(BREAK): V(break); break;
- case C(CONTINUE): V(continue); break;
- case C(INFORMATION_LANGUAGE):
- case C(INFORMATION_COUNTRY):
- case C(INFORMATION_VARIANT):
- fail_if (validate_information_data(tree));
- break;
- case C(ASSUMPTION_HAVE):
- case C(ASSUMPTION_HAVE_CHARS):
- case C(ASSUMPTION_HAVE_RANGE):
- fail_if (validate_assumption_data(tree));
- break;
- default:
- break;
- }
-
- innermost_visit = old_innermost_visit;
- tree = tree->next;
- goto again;
- fail:
- return innermost_visit = old_innermost_visit, -1;
+#define v(type) fail_if (validate_##type(&(tree->type)))
+#define V(type) fail_if (validate_##type(&(tree->type##_)))
+ int old_innermost_visit = innermost_visit;
+again:
+ if (!tree)
+ return 0;
+
+ switch (tree->type) {
+ case C(INFORMATION): v(information); break;
+ case C(INCLUDE): v(include); break;
+ case C(FUNCTION): v(function); break;
+ case C(MACRO): v(macro); break;
+ case C(ASSUMPTION): v(assumption); break;
+ case C(FOR): V(for); break;
+ case C(IF): V(if); break;
+ case C(MAP): v(map); break;
+ case C(MACRO_CALL): v(macro_call); break;
+ case C(RETURN): V(return); break;
+ case C(BREAK): V(break); break;
+ case C(CONTINUE): V(continue); break;
+ case C(INFORMATION_LANGUAGE):
+ case C(INFORMATION_COUNTRY):
+ case C(INFORMATION_VARIANT):
+ fail_if (validate_information_data(tree));
+ break;
+ case C(ASSUMPTION_HAVE):
+ case C(ASSUMPTION_HAVE_CHARS):
+ case C(ASSUMPTION_HAVE_RANGE):
+ fail_if (validate_assumption_data(tree));
+ break;
+ default:
+ break;
+ }
+
+ innermost_visit = old_innermost_visit;
+ tree = tree->next;
+ goto again;
+fail:
+ return innermost_visit = old_innermost_visit, -1;
#undef V
#undef v
}
@@ -508,17 +498,18 @@ static int validate_subtree(mds_kbdc_tree_t* restrict tree)
* @param result_ `result` from `process_includes`, will be updated
* @return -1 if an error occursed that cannot be stored in `result`, zero otherwise
*/
-int validate_tree(mds_kbdc_parsed_t* restrict result_)
+int
+validate_tree(mds_kbdc_parsed_t *restrict result_)
{
- int r;
- mds_kbdc_include_stack_begin(result = result_);
- r = validate_subtree(result_->tree);
- fors = 0;
- mds_kbdc_include_stack_end();
- fail_if (r);
- return 0;
- fail:
- return -1;
+ int r;
+ mds_kbdc_include_stack_begin(result = result_);
+ r = validate_subtree(result_->tree);
+ fors = 0;
+ mds_kbdc_include_stack_end();
+ fail_if (r);
+ return 0;
+fail:
+ return -1;
}
@@ -526,4 +517,3 @@ int validate_tree(mds_kbdc_parsed_t* restrict result_)
#undef NEW_ERROR
#undef VISITING
#undef C
-