return NULL;
}
+static struct isl_basic_map *read_disjunct(struct isl_stream *s,
+ struct vars **v, __isl_take isl_dim *dim)
+{
+ struct isl_basic_map *bmap;
+
+ bmap = isl_basic_map_alloc_dim(dim, 0, 0, 0);
+ if (!bmap)
+ return NULL;
+
+ bmap = add_constraints(s, v, bmap);
+ bmap = isl_basic_map_simplify(bmap);
+ bmap = isl_basic_map_finalize(bmap);
+ return bmap;
+}
+
+static struct isl_map *read_disjuncts(struct isl_stream *s,
+ struct vars **v, __isl_take isl_dim *dim)
+{
+ struct isl_token *tok;
+ struct isl_map *map;
+
+ tok = isl_stream_next_token(s);
+ if (!tok) {
+ isl_stream_error(s, NULL, "unexpected EOF");
+ goto error;
+ }
+ if (tok->type == '}') {
+ isl_stream_push_token(s, tok);
+ return isl_map_universe(dim);
+ }
+ isl_stream_push_token(s, tok);
+
+ map = isl_map_empty(isl_dim_copy(dim));
+ for (;;) {
+ struct isl_basic_map *bmap;
+
+ bmap = read_disjunct(s, v, isl_dim_copy(dim));
+ map = isl_map_union(map, isl_map_from_basic_map(bmap));
+
+ tok = isl_stream_next_token(s);
+ if (!tok || tok->type != ISL_TOKEN_OR)
+ break;
+ isl_token_free(tok);
+ }
+ if (tok)
+ isl_stream_push_token(s, tok);
+
+ isl_dim_free(dim);
+ return map;
+error:
+ isl_dim_free(dim);
+ return NULL;
+}
+
static __isl_give isl_basic_map *basic_map_read_polylib_constraint(
struct isl_stream *s, __isl_take isl_basic_map *bmap)
{
static struct isl_map *map_read(struct isl_stream *s, int nparam)
{
- struct isl_dim *dim;
- struct isl_basic_map *bmap = NULL;
+ struct isl_dim *dim = NULL;
+ struct isl_map *map = NULL;
struct isl_token *tok;
struct vars *v = NULL;
int n1;
n1 = 0;
}
dim = dim_from_vars(v, nparam, n1, n2);
- bmap = isl_basic_map_alloc_dim(dim, 0, 0, 0);
- if (!bmap)
- goto error;
tok = isl_stream_next_token(s);
- if (tok && tok->type == ':') {
+ if (!tok) {
+ isl_stream_error(s, NULL, "unexpected EOF");
+ goto error;
+ }
+ if (tok->type == ':') {
isl_token_free(tok);
- bmap = add_constraints(s, &v, bmap);
+ map = read_disjuncts(s, &v, isl_dim_copy(dim));
tok = isl_stream_next_token(s);
- }
+ } else
+ map = isl_map_universe(isl_dim_copy(dim));
if (tok && tok->type == '}') {
isl_token_free(tok);
} else {
goto error;
}
vars_free(v);
+ isl_dim_free(dim);
- bmap = isl_basic_map_simplify(bmap);
- bmap = isl_basic_map_finalize(bmap);
- return isl_map_from_basic_map(bmap);
+ return map;
error:
- isl_basic_map_free(bmap);
+ isl_dim_free(dim);
+ isl_map_free(map);
if (v)
vars_free(v);
return NULL;
tok->type = ISL_TOKEN_EXISTS;
else if (!strcasecmp(s->buffer, "and"))
tok->type = ISL_TOKEN_AND;
+ else if (!strcasecmp(s->buffer, "or"))
+ tok->type = ISL_TOKEN_OR;
else {
tok->type = ISL_TOKEN_IDENT;
tok->u.s = strdup(s->buffer);
isl_stream_ungetc(s, c);
return tok;
}
+ if (c == '|') {
+ tok = isl_token_new(s->ctx, line, col, old_line != line);
+ if (!tok)
+ return NULL;
+ tok->type = ISL_TOKEN_OR;
+ if ((c = isl_stream_getc(s)) != '|' && c != -1)
+ isl_stream_ungetc(s, c);
+ return tok;
+ }
tok = isl_token_new(s->ctx, line, col, old_line != line);
if (!tok)