From 2a4baa4973b74a09f90cee99f6b22c0dbca2887e Mon Sep 17 00:00:00 2001 From: Sven Verdoolaege Date: Fri, 1 Jul 2016 14:07:17 +0200 Subject: [PATCH] isl_pw_aff_read_from_str: handle 0D domains Trying to parse affine expressions with a 0D domain would result in parsing errors. Signed-off-by: Sven Verdoolaege --- isl_input.c | 11 +++++++++-- isl_test.c | 1 + 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/isl_input.c b/isl_input.c index 72381270..8a448708 100644 --- a/isl_input.c +++ b/isl_input.c @@ -3112,12 +3112,15 @@ static int next_is_fresh_ident(__isl_keep isl_stream *s, struct vars *v) * If the tuple we are reading is named, we assume it's the domain. * Also, if inside the tuple, the first thing we find is a nested tuple * or a new identifier, we again assume it's the domain. + * Finally, if the tuple is empty, then it must be the domain + * since it does not contain an affine expression. * Otherwise, we assume we are reading an affine expression. */ static __isl_give isl_set *read_aff_domain(__isl_keep isl_stream *s, __isl_take isl_set *dom, struct vars *v) { - struct isl_token *tok; + struct isl_token *tok, *tok2; + int is_empty; tok = isl_stream_next_token(s); if (tok && (tok->type == ISL_TOKEN_IDENT || tok->is_keyword)) { @@ -3128,7 +3131,11 @@ static __isl_give isl_set *read_aff_domain(__isl_keep isl_stream *s, isl_stream_error(s, tok, "expecting '['"); goto error; } - if (next_is_tuple(s) || next_is_fresh_ident(s, v)) { + tok2 = isl_stream_next_token(s); + is_empty = tok2 && tok2->type == ']'; + if (tok2) + isl_stream_push_token(s, tok2); + if (is_empty || next_is_tuple(s) || next_is_fresh_ident(s, v)) { isl_stream_push_token(s, tok); dom = read_map_tuple(s, dom, isl_dim_set, v, 1, 0); } else diff --git a/isl_test.c b/isl_test.c index fd902eb6..7a08fe00 100644 --- a/isl_test.c +++ b/isl_test.c @@ -249,6 +249,7 @@ int test_parse(struct isl_ctx *ctx) test_parse_map(ctx, "{ S1[i] -> [([i/10]),i%10] : 0 <= i <= 45 }"); test_parse_pwaff(ctx, "{ [i] -> [i + 1] : i > 0; [a] -> [a] : a < 0 }"); test_parse_pwqp(ctx, "{ [x] -> ([(x)/2] * [(x)/3]) }"); + test_parse_pwaff(ctx, "{ [] -> [(100)] }"); return 0; } -- 2.11.4.GIT