2 * Copyright 2017 Sven Verdoolaege
4 * Use of this software is governed by the MIT license
6 * Written by Sven Verdoolaege.
9 #include <isl/stream.h>
11 #include <isl_list_macro.h>
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.
19 static __isl_give
LIST(EL
) *FN(isl_stream_read
,LIST(EL_BASE
))(isl_stream
*s
)
26 ctx
= isl_stream_get_ctx(s
);
27 list
= FN(LIST(EL
),alloc
)(ctx
, 0);
30 if (isl_stream_eat(s
, '(') < 0)
31 return FN(LIST(EL
),free
)(list
);
32 if (isl_stream_eat_if_available(s
, ')'))
37 el
= FN(isl_stream_read
,EL_BASE
)(s
);
38 list
= FN(LIST(EL
),add
)(list
, el
);
41 } while (isl_stream_eat_if_available(s
, ','));
42 if (isl_stream_eat(s
, ')') < 0)
43 return FN(LIST(EL
),free
)(list
);
47 /* Read a list of elements of type EL from the string "str".
48 * The input format corresponds to the way lists are printed
49 * by isl_printer_print_list_*.
50 * In particular, the elements are separated by a comma and
51 * the entire list is surrounded by parentheses.
53 __isl_give
LIST(EL
) *FN(LIST(EL
),read_from_str
)(isl_ctx
*ctx
,
59 s
= isl_stream_new_str(ctx
, str
);
62 list
= FN(isl_stream_read
,LIST(EL_BASE
))(s
);