#define ISL_FORMAT_OMEGA 2
struct isl_basic_set *isl_basic_set_read_from_file(struct isl_ctx *ctx,
FILE *input, unsigned nparam, unsigned input_format);
+struct isl_basic_set *isl_basic_set_read_from_str(struct isl_ctx *ctx,
+ const char *str, unsigned nparam, unsigned input_format);
struct isl_set *isl_set_read_from_file(struct isl_ctx *ctx,
FILE *input, unsigned nparam, unsigned input_format);
#define ISL_FORMAT_POLYLIB_CONSTRAINTS 3
isl_assert(ctx, 0, return NULL);
}
+struct isl_basic_set *isl_basic_set_read_from_str(struct isl_ctx *ctx,
+ const char *str, unsigned nparam, unsigned input_format)
+{
+ if (input_format == ISL_FORMAT_OMEGA) {
+ isl_assert(ctx, nparam == 0, return NULL);
+ return isl_basic_set_read_from_str_omega(ctx, str);
+ } else
+ isl_assert(ctx, 0, return NULL);
+}
+
struct isl_basic_map *isl_basic_map_read_from_file(struct isl_ctx *ctx,
FILE *input, unsigned nparam, unsigned input_format)
{
return s;
}
+static struct stream* stream_new_str(struct isl_ctx *ctx, const char *str)
+{
+ struct stream *s = stream_new(ctx);
+ s->str = str;
+ return s;
+}
+
static int stream_getc(struct stream *s)
{
int c;
isl_basic_map_free(bmap);
return NULL;
}
+
+struct isl_basic_map *isl_basic_map_read_from_str_omega(
+ struct isl_ctx *ctx, const char *str)
+{
+ struct isl_basic_map *bmap;
+ struct stream *s = stream_new_str(ctx, str);
+ if (!s)
+ return NULL;
+ bmap = basic_map_read(s);
+ stream_free(s);
+ return bmap;
+}
+
+struct isl_basic_set *isl_basic_set_read_from_str_omega(
+ struct isl_ctx *ctx, const char *str)
+{
+ struct isl_basic_map *bmap;
+ bmap = isl_basic_map_read_from_str_omega(ctx, str);
+ if (!bmap)
+ return NULL;
+ isl_assert(ctx, isl_basic_map_n_in(bmap) == 0, goto error);
+ return (struct isl_basic_set *)bmap;
+error:
+ isl_basic_map_free(bmap);
+ return NULL;
+}
struct isl_basic_set *isl_basic_set_read_from_file_omega(
struct isl_ctx *ctx, FILE *input);
+struct isl_basic_set *isl_basic_set_read_from_str_omega(
+ struct isl_ctx *ctx, const char *str);
struct isl_basic_map *isl_basic_map_read_from_file_omega(
struct isl_ctx *ctx, FILE *input);
+struct isl_basic_map *isl_basic_map_read_from_str_omega(
+ struct isl_ctx *ctx, const char *str);
#endif
static char *srcdir;
+void test_read(struct isl_ctx *ctx)
+{
+ char filename[PATH_MAX];
+ FILE *input;
+ int n;
+ struct isl_basic_set *bset1, *bset2;
+ const char *str = "{[y]: Exists ( alpha : 2alpha = y)}";
+
+ n = snprintf(filename, sizeof(filename),
+ "%s/test_inputs/set.omega", srcdir);
+ assert(n < sizeof(filename));
+ input = fopen(filename, "r");
+ assert(input);
+
+ bset1 = isl_basic_set_read_from_file(ctx, input, 0, ISL_FORMAT_OMEGA);
+ bset2 = isl_basic_set_read_from_str(ctx, str, 0, ISL_FORMAT_OMEGA);
+
+ assert(isl_basic_set_is_equal(bset1, bset2) == 1);
+
+ isl_basic_set_free(bset1);
+ isl_basic_set_free(bset2);
+
+ fclose(input);
+}
+
/* Construct the basic set { [i] : 5 <= i <= N } */
void test_construction(struct isl_ctx *ctx)
{
srcdir = getenv("srcdir");
ctx = isl_ctx_alloc();
+ test_read(ctx);
test_construction(ctx);
test_application(ctx);
test_affine_hull(ctx);
--- /dev/null
+{[y]: Exists ( alpha : 2alpha = y)}