Polly 19.0.0git
isl_list_read_templ.c
Go to the documentation of this file.
1/*
2 * Copyright 2017 Sven Verdoolaege
3 *
4 * Use of this software is governed by the MIT license
5 *
6 * Written by Sven Verdoolaege.
7 */
8
9#include <isl/stream.h>
10
11#include <isl_list_macro.h>
12
13/* Read a list of elements of type EL from "s".
14 * The input format corresponds to the way lists are printed
15 * by isl_printer_print_list_*.
16 * In particular, the elements are separated by a comma and
17 * the entire list is surrounded by parentheses.
18 */
19__isl_give LIST(EL) *FN(isl_stream_read,LIST(EL_BASE))(isl_stream *s)
20{
21 isl_ctx *ctx;
22 LIST(EL) *list;
23
24 if (!s)
25 return NULL;
26 ctx = isl_stream_get_ctx(s);
27 list = FN(LIST(EL),alloc)(ctx, 0);
28 if (!list)
29 return NULL;
30 if (isl_stream_eat(s, '(') < 0)
31 return FN(LIST(EL),free)(list);
33 return list;
34 do {
35 EL *el;
36
37 el = FN(isl_stream_read,EL_BASE)(s);
38 list = FN(LIST(EL),add)(list, el);
39 if (!list)
40 return NULL;
41 } while (isl_stream_eat_if_available(s, ','));
42 if (isl_stream_eat(s, ')') < 0)
43 return FN(LIST(EL),free)(list);
44 return list;
45}
46
47#undef TYPE_BASE
48#define TYPE_BASE LIST(EL_BASE)
#define FN(TYPE, NAME)
#define __isl_give
Definition: ctx.h:19
void GMPZAPI() add(mp_int rop, mp_int op1, mp_int op2)
#define EL_BASE
Definition: isl_aff.c:64
#define EL
#define LIST(EL)
Definition: isl_list_macro.h:8
isl_ctx * isl_stream_get_ctx(__isl_keep isl_stream *s)
Definition: isl_stream.c:800
int isl_stream_eat(__isl_keep isl_stream *s, int type)
Definition: isl_stream.c:747
int isl_stream_eat_if_available(__isl_keep isl_stream *s, int type)
Definition: isl_stream.c:703