The example shows how to rewrite a non-ground logic program.
./ast 0
Solving with enable = false...
Model:
Solving with enable = true...
Model: enable a
Model: enable b
Solving with enable = false...
Model:
#include <stdlib.h>
#include <stdio.h>
bool ret = true;
size_t atoms_n;
char *str = NULL;
size_t str_n = 0;
goto error;
}
printf("Model:");
for (it = atoms, ie = atoms + atoms_n; it != ie; ++it) {
size_t n;
char *str_new;
if (str_n < n) {
if (!(str_new = (char*)realloc(str, sizeof(*str) * n))) {
goto error;
}
str = str_new;
str_n = n;
}
printf(" %s", str);
}
printf("\n");
goto out;
error:
ret = false;
out:
if (atoms) { free(atoms); }
if (str) { free(str); }
return ret;
}
typedef struct {
} on_statement_data;
bool on_statement (
clingo_ast_t *stm, on_statement_data *data) {
bool ret = true;
size_t size;
if (type != clingo_ast_type_rule) {
goto out;
}
goto error;
}
goto error;
}
goto error;
}
goto out;
error:
ret = false;
out:
if (lit != NULL) {
}
return ret;
}
bool ret = true;
while (true) {
if (model) { print_model(model); }
else { break; }
}
goto out;
error:
ret = false;
out:
}
int main(int argc, char const **argv) {
char const *error_message;
int ret = 0;
on_statement_data data = {NULL, NULL, NULL};
data.loc = &location;
goto error;
}
goto error;
}
goto error;
}
printf("Solving with enable = false...\n");
if (!solve(ctl, &solve_ret)) { goto error; }
printf("Solving with enable = true...\n");
if (!solve(ctl, &solve_ret)) { goto error; }
printf("Solving with enable = false...\n");
if (!solve(ctl, &solve_ret)) { goto error; }
goto out;
error:
printf("%s\n", error_message);
out:
return ret;
}