Transform isl_point_print into isl_printer_print_point
[platform/upstream/isl.git] / isl_stream.c
index 6a7a912..c544149 100644 (file)
@@ -213,10 +213,12 @@ static int isl_stream_getc(struct isl_stream *s)
 static int isl_stream_push_char(struct isl_stream *s, int c)
 {
        if (s->len >= s->size) {
+               char *buffer;
                s->size = (3*s->size)/2;
-               s->buffer = isl_realloc_array(s->ctx, s->buffer, char, s->size);
-               if (!s->buffer)
+               buffer = isl_realloc_array(s->ctx, s->buffer, char, s->size);
+               if (!buffer)
                        return -1;
+               s->buffer = buffer;
        }
        s->buffer[s->len++] = c;
        return 0;
@@ -248,6 +250,8 @@ static enum isl_token_type check_keywords(struct isl_stream *s)
                return ISL_TOKEN_INFTY;
        if (!strcasecmp(s->buffer, "NaN"))
                return ISL_TOKEN_NAN;
+       if (!strcasecmp(s->buffer, "min"))
+               return ISL_TOKEN_MIN;
        if (!strcasecmp(s->buffer, "max"))
                return ISL_TOKEN_MAX;
        if (!strcasecmp(s->buffer, "rat"))
@@ -256,6 +260,10 @@ static enum isl_token_type check_keywords(struct isl_stream *s)
                return ISL_TOKEN_TRUE;
        if (!strcasecmp(s->buffer, "false"))
                return ISL_TOKEN_FALSE;
+       if (!strcasecmp(s->buffer, "ceild"))
+               return ISL_TOKEN_CEILD;
+       if (!strcasecmp(s->buffer, "floord"))
+               return ISL_TOKEN_FLOORD;
 
        if (!s->keywords)
                return ISL_TOKEN_IDENT;
@@ -320,12 +328,12 @@ static struct isl_token *next_token(struct isl_stream *s, int same_line)
        if (c == '(' ||
            c == ')' ||
            c == '+' ||
-           c == '/' ||
            c == '*' ||
            c == '%' ||
            c == '^' ||
            c == '=' ||
            c == '@' ||
+           c == '$' ||
            c == ',' ||
            c == '.' ||
            c == ';' ||
@@ -504,6 +512,32 @@ static struct isl_token *next_token(struct isl_stream *s, int same_line)
                        tok->u.s = strdup("||");
                return tok;
        }
+       if (c == '/') {
+               tok = isl_token_new(s->ctx, line, col, old_line != line);
+               if (!tok)
+                       return NULL;
+               if ((c = isl_stream_getc(s)) != '\\' && c != -1) {
+                       tok->type = (enum isl_token_type) '/';
+                       isl_stream_ungetc(s, c);
+               } else {
+                       tok->u.s = strdup("/\\");
+                       tok->type = ISL_TOKEN_AND;
+               }
+               return tok;
+       }
+       if (c == '\\') {
+               tok = isl_token_new(s->ctx, line, col, old_line != line);
+               if (!tok)
+                       return NULL;
+               if ((c = isl_stream_getc(s)) != '/' && c != -1) {
+                       tok->type = (enum isl_token_type) '\\';
+                       isl_stream_ungetc(s, c);
+               } else {
+                       tok->u.s = strdup("\\/");
+                       tok->type = ISL_TOKEN_OR;
+               }
+               return tok;
+       }
        if (c == '!') {
                tok = isl_token_new(s->ctx, line, col, old_line != line);
                if (!tok)