return c;
}
+static void isl_stream_ungetc(struct isl_stream *s, int c)
+{
+ isl_assert(s->ctx, s->n_un < 5, return);
+ s->un[s->n_un++] = c;
+ s->c = -1;
+}
+
static int isl_stream_getc(struct isl_stream *s)
{
int c;
do {
c = stream_getc(s);
if (c != '\\')
- break;
+ return c;
c = stream_getc(s);
} while (c == '\n');
- return c;
-}
+ isl_stream_ungetc(s, c);
-static void isl_stream_ungetc(struct isl_stream *s, int c)
-{
- isl_assert(s->ctx, s->n_un < 5, return);
- s->un[s->n_un++] = c;
- s->c = -1;
+ return '\\';
}
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;
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"))
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;
if (c == '(' ||
c == ')' ||
c == '+' ||
- c == '/' ||
c == '*' ||
c == '%' ||
c == '^' ||
c == '=' ||
c == '@' ||
+ c == '$' ||
c == ',' ||
c == '.' ||
c == ';' ||
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)