add isl_aff_domain_factor_domain
[isl.git] / read_in_string_templ.c
blob3dc630ee03686c3610cef4b365eab45e685ec7c7
1 #include <isl/stream.h>
3 #define xCAT(A,B) A ## B
4 #define CAT(A,B) xCAT(A,B)
5 #undef TYPE
6 #define TYPE CAT(isl_,BASE)
7 #define xFN(TYPE,NAME) TYPE ## _ ## NAME
8 #define FN(TYPE,NAME) xFN(TYPE,NAME)
10 /* Read an object of type TYPE from "s", where the object may
11 * either be specified directly or as a string.
13 * First check if the next token in "s" is a string. If so, try and
14 * extract the object from the string.
15 * Otherwise, try and read the object directly from "s".
17 static __isl_give TYPE *FN(read,BASE)(__isl_keep isl_stream *s)
19 struct isl_token *tok;
20 int type;
22 tok = isl_stream_next_token(s);
23 type = isl_token_get_type(tok);
24 if (type == ISL_TOKEN_STRING) {
25 char *str;
26 isl_ctx *ctx;
27 TYPE *res;
29 ctx = isl_stream_get_ctx(s);
30 str = isl_token_get_str(ctx, tok);
31 res = FN(TYPE,read_from_str)(ctx, str);
32 free(str);
33 isl_token_free(tok);
34 return res;
36 isl_stream_push_token(s, tok);
37 return FN(isl_stream_read,BASE)(s);