add isl_token_get_str
authorSven Verdoolaege <skimo@kotnet.org>
Tue, 28 May 2013 10:04:06 +0000 (12:04 +0200)
committerSven Verdoolaege <skimo@kotnet.org>
Tue, 28 May 2013 18:42:48 +0000 (20:42 +0200)
Signed-off-by: Sven Verdoolaege <skimo@kotnet.org>
include/isl/stream.h
isl_stream.c

index 58c03cc..2e6e1b7 100644 (file)
@@ -54,6 +54,7 @@ struct isl_token {
 };
 
 __isl_give isl_val *isl_token_get_val(isl_ctx *ctx, struct isl_token *tok);
+__isl_give char *isl_token_get_str(isl_ctx *ctx, struct isl_token *tok);
 void isl_token_free(struct isl_token *tok);
 
 struct isl_stream {
index 7ead411..388c204 100644 (file)
@@ -94,6 +94,19 @@ __isl_give isl_val *isl_token_get_val(isl_ctx *ctx, struct isl_token *tok)
        return isl_val_int_from_isl_int(ctx, tok->u.v);
 }
 
+/* Given a token of type ISL_TOKEN_STRING, return the string it represents.
+ */
+__isl_give char *isl_token_get_str(isl_ctx *ctx, struct isl_token *tok)
+{
+       if (!tok)
+               return NULL;
+       if (tok->type != ISL_TOKEN_STRING)
+               isl_die(ctx, isl_error_invalid, "not a string token",
+                       return NULL);
+
+       return strdup(tok->u.s);
+}
+
 void isl_token_free(struct isl_token *tok)
 {
        if (!tok)