tok->col = col;
tok->on_new_line = on_new_line;
tok->is_keyword = 0;
+ tok->u.s = NULL;
return tok;
}
return;
if (tok->type == ISL_TOKEN_VALUE)
isl_int_clear(tok->u.v);
- else if (tok->type == ISL_TOKEN_IDENT ||
- tok->type == ISL_TOKEN_STRING ||
- tok->is_keyword)
+ else
free(tok->u.s);
free(tok);
}
fprintf(stderr, "got ident '%s'\n", tok->u.s);
else if (tok->is_keyword)
fprintf(stderr, "got keyword '%s'\n", tok->u.s);
+ else if (tok->type == ISL_TOKEN_VALUE) {
+ fprintf(stderr, "got value '");
+ isl_int_print(stderr, tok->u.v, 0);
+ fprintf(stderr, "'\n");
+ } else if (tok->u.s)
+ fprintf(stderr, "got token '%s'\n", tok->u.s);
else
fprintf(stderr, "got token type %d\n", tok->type);
}
tok = isl_token_new(s->ctx, line, col, old_line != line);
if (!tok)
return NULL;
+ tok->u.s = strdup("->");
tok->type = ISL_TOKEN_TO;
return tok;
}
if (!tok)
return NULL;
if ((c = isl_stream_getc(s)) == '=') {
+ tok->u.s = strdup(":=");
tok->type = ISL_TOKEN_DEF;
return tok;
}
if (!tok)
return NULL;
if ((c = isl_stream_getc(s)) == '=') {
+ tok->u.s = strdup(">=");
tok->type = ISL_TOKEN_GE;
return tok;
} else if (c == '>') {
if ((c = isl_stream_getc(s)) == '=') {
+ tok->u.s = strdup(">>=");
tok->type = ISL_TOKEN_LEX_GE;
return tok;
}
+ tok->u.s = strdup(">>");
tok->type = ISL_TOKEN_LEX_GT;
- } else
+ } else {
+ tok->u.s = strdup(">");
tok->type = ISL_TOKEN_GT;
+ }
if (c != -1)
isl_stream_ungetc(s, c);
return tok;
if (!tok)
return NULL;
if ((c = isl_stream_getc(s)) == '=') {
+ tok->u.s = strdup("<=");
tok->type = ISL_TOKEN_LE;
return tok;
} else if (c == '<') {
if ((c = isl_stream_getc(s)) == '=') {
+ tok->u.s = strdup("<<=");
tok->type = ISL_TOKEN_LEX_LE;
return tok;
}
+ tok->u.s = strdup("<<");
tok->type = ISL_TOKEN_LEX_LT;
- } else
+ } else {
+ tok->u.s = strdup("<");
tok->type = ISL_TOKEN_LT;
+ }
if (c != -1)
isl_stream_ungetc(s, c);
return tok;
if (!tok)
return NULL;
tok->type = ISL_TOKEN_AND;
- if ((c = isl_stream_getc(s)) != '&' && c != -1)
+ if ((c = isl_stream_getc(s)) != '&' && c != -1) {
+ tok->u.s = strdup("&");
isl_stream_ungetc(s, c);
+ } else
+ tok->u.s = strdup("&&");
return tok;
}
if (c == '|') {
if (!tok)
return NULL;
tok->type = ISL_TOKEN_OR;
- if ((c = isl_stream_getc(s)) != '|' && c != -1)
+ if ((c = isl_stream_getc(s)) != '|' && c != -1) {
+ tok->u.s = strdup("|");
isl_stream_ungetc(s, c);
+ } else
+ tok->u.s = strdup("||");
return tok;
}