#define isl_int_set_si(r,i) mpz_set_si(r,i)
#define isl_int_get_gmp(i,g) mpz_set(g,i)
#define isl_int_get_si(r) mpz_get_si(r)
+#define isl_int_get_ui(r) mpz_get_ui(r)
#define isl_int_get_d(r) mpz_get_d(r)
#define isl_int_get_str(r) mpz_get_str(0, 10, r)
#define isl_int_abs(r,i) mpz_abs(r,i)
#define isl_int_sub(r,i,j) mpz_sub(r,i,j)
#define isl_int_mul(r,i,j) mpz_mul(r,i,j)
#define isl_int_mul_ui(r,i,j) mpz_mul_ui(r,i,j)
+#define isl_int_pow_ui(r,i,j) mpz_pow_ui(r,i,j)
#define isl_int_addmul(r,i,j) mpz_addmul(r,i,j)
#define isl_int_submul(r,i,j) mpz_submul(r,i,j)
return bmap;
}
+/* Obtain next token, with some preprocessing.
+ * In particular, evaluate expressions of the form x^y,
+ * with x and y values.
+ */
+static struct isl_token *next_token(struct isl_stream *s)
+{
+ struct isl_token *tok, *tok2;
+
+ tok = isl_stream_next_token(s);
+ if (!tok || tok->type != ISL_TOKEN_VALUE)
+ return tok;
+ if (!isl_stream_eat_if_available(s, '^'))
+ return tok;
+ tok2 = isl_stream_next_token(s);
+ if (!tok2 || tok2->type != ISL_TOKEN_VALUE) {
+ isl_stream_error(s, tok2, "expecting constant value");
+ goto error;
+ }
+
+ isl_int_pow_ui(tok->u.v, tok->u.v, isl_int_get_ui(tok2->u.v));
+
+ isl_token_free(tok2);
+ return tok;
+error:
+ isl_token_free(tok);
+ isl_token_free(tok2);
+ return NULL;
+}
+
static int accept_cst_factor(struct isl_stream *s, isl_int *f)
{
struct isl_token *tok;
- tok = isl_stream_next_token(s);
+ tok = next_token(s);
if (!tok || tok->type != ISL_TOKEN_VALUE) {
isl_stream_error(s, tok, "expecting constant value");
goto error;
struct variable *var;
isl_vec *mod;
- tok = isl_stream_next_token(s);
+ tok = next_token(s);
if (!tok || tok->type != ISL_TOKEN_VALUE) {
isl_stream_error(s, tok, "expecting constant value");
goto error;
struct isl_token *tok = NULL;
isl_vec *aff = NULL;
- tok = isl_stream_next_token(s);
+ tok = next_token(s);
if (!tok) {
isl_stream_error(s, NULL, "unexpected EOF");
goto error;
isl_seq_clr(aff->el, aff->size);
for (;;) {
- tok = isl_stream_next_token(s);
+ tok = next_token(s);
if (!tok) {
isl_stream_error(s, NULL, "unexpected EOF");
goto error;
}
isl_token_free(tok);
- tok = isl_stream_next_token(s);
+ tok = next_token(s);
if (tok && tok->type == '-') {
sign = -sign;
isl_token_free(tok);
int i = 0;
struct isl_token *tok;
- while ((tok = isl_stream_next_token(s)) != NULL) {
+ while ((tok = next_token(s)) != NULL) {
int new_name = 0;
if (tok->type == ISL_TOKEN_IDENT) {
if (isl_stream_eat(s, '/'))
return -1;
- tok = isl_stream_next_token(s);
+ tok = next_token(s);
if (!tok)
return -1;
if (tok->type != ISL_TOKEN_VALUE) {
struct isl_qpolynomial *qp;
struct isl_token *tok;
- tok = isl_stream_next_token(s);
+ tok = next_token(s);
if (!tok) {
isl_stream_error(s, NULL, "unexpected EOF");
return NULL;
tok2 = isl_stream_next_token(s);
if (tok2 && tok2->type == '/') {
isl_token_free(tok2);
- tok2 = isl_stream_next_token(s);
+ tok2 = next_token(s);
if (!tok2 || tok2->type != ISL_TOKEN_VALUE) {
isl_stream_error(s, tok2, "expected denominator");
isl_token_free(tok);
qp = read_factor(s, bmap, v);
for (;;) {
- tok = isl_stream_next_token(s);
+ tok = next_token(s);
if (!tok)
return qp;
struct vars *v = NULL;
struct isl_obj obj = { isl_obj_set, NULL };
- tok = isl_stream_next_token(s);
+ tok = next_token(s);
if (!tok) {
isl_stream_error(s, NULL, "unexpected EOF");
goto error;