isl_stream: accept "/\" and "\/" as alternatives for "and" and "or"
authorSven Verdoolaege <skimo@kotnet.org>
Sat, 5 Mar 2011 09:47:34 +0000 (10:47 +0100)
committerSven Verdoolaege <skimo@kotnet.org>
Sat, 5 Mar 2011 09:56:06 +0000 (10:56 +0100)
Signed-off-by: Sven Verdoolaege <skimo@kotnet.org>
isl_stream.c

index 6a7a912..139e4c0 100644 (file)
@@ -320,7 +320,6 @@ static struct isl_token *next_token(struct isl_stream *s, int same_line)
        if (c == '(' ||
            c == ')' ||
            c == '+' ||
-           c == '/' ||
            c == '*' ||
            c == '%' ||
            c == '^' ||
@@ -504,6 +503,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)