From 90c4f2993168cd413e9b7afe066256072603c08e Mon Sep 17 00:00:00 2001 From: Sven Verdoolaege Date: Thu, 1 Mar 2012 11:02:01 +0100 Subject: [PATCH] isl_stream_read_map: accept rational affine expressions Signed-off-by: Sven Verdoolaege --- isl_input.c | 37 ++++++++++++++++++++----------------- isl_test.c | 4 ++++ 2 files changed, 24 insertions(+), 17 deletions(-) diff --git a/isl_input.c b/isl_input.c index 1282224..b3a845d 100644 --- a/isl_input.c +++ b/isl_input.c @@ -283,7 +283,6 @@ static __isl_give isl_pw_aff *accept_div(struct isl_stream *s, __isl_take isl_space *dim, struct vars *v) { struct isl_token *tok; - int seen_paren = 0; int f = 0; int c = 0; isl_pw_aff *pwaff = NULL; @@ -298,8 +297,6 @@ static __isl_give isl_pw_aff *accept_div(struct isl_stream *s, } else { if (isl_stream_eat(s, '[')) goto error; - if (isl_stream_eat_if_available(s, '(')) - seen_paren = 1; } pwaff = accept_affine(s, isl_space_copy(dim), v); @@ -307,24 +304,19 @@ static __isl_give isl_pw_aff *accept_div(struct isl_stream *s, if (f || c) { if (isl_stream_eat(s, ',')) goto error; - } else { - if (seen_paren && isl_stream_eat(s, ')')) + + tok = next_token(s); + if (!tok) goto error; - if (isl_stream_eat(s, '/')) + if (tok->type != ISL_TOKEN_VALUE) { + isl_stream_error(s, tok, "expected denominator"); + isl_stream_push_token(s, tok); goto error; + } + isl_pw_aff_scale_down(pwaff, tok->u.v); + isl_token_free(tok); } - tok = next_token(s); - if (!tok) - goto error; - if (tok->type != ISL_TOKEN_VALUE) { - isl_stream_error(s, tok, "expected denominator"); - isl_stream_push_token(s, tok); - goto error; - } - isl_pw_aff_scale_down(pwaff, tok->u.v); - isl_token_free(tok); - if (c) pwaff = isl_pw_aff_ceil(pwaff); else @@ -430,6 +422,17 @@ static __isl_give isl_pw_aff *accept_affine_factor(struct isl_stream *s, res = isl_pw_aff_scale(res, f); isl_int_clear(f); } + if (isl_stream_eat_if_available(s, '/')) { + isl_int f; + isl_int_init(f); + isl_int_set_si(f, 1); + if (accept_cst_factor(s, &f) < 0) { + isl_int_clear(f); + goto error2; + } + res = isl_pw_aff_scale_down(res, f); + isl_int_clear(f); + } isl_space_free(dim); return res; diff --git a/isl_test.c b/isl_test.c index d9cf3cc..45f8c97 100644 --- a/isl_test.c +++ b/isl_test.c @@ -196,6 +196,10 @@ int test_parse(struct isl_ctx *ctx) "{ [a] -> [b] : true }") < 0) return -1; + if (test_parse_map_equal(ctx, "{ [i] : i/2 <= 5 }", + "{ [i] : i <= 10 }") < 0) + return -1; + return 0; } -- 2.7.4