302{
303 int len = 0;
304 TowerPolynomial *elems =
newarray(TowerPolynomial, 100);
305 TowerPolynomial this_elem = nullptr;
306 if (*str != '[')
307 {
308 fprintf(stderr, "expected '[', got %s\n", str);
309 exit(1);
310 }
311 str++;
312
313 while (*str != ']')
314 {
315 while (isspace(*str)) str++;
316 if (*str == ',')
317 {
318 str++;
319 }
320 else if (*str == '[')
321 {
323 while (isspace(*str)) str++;
324 if (*str == ',') str++;
325 }
326 else
327 {
328 fprintf(stderr, "expected , or [, but got %s\n", str);
329 exit(1);
330 }
331 elems[len++] = this_elem;
332 this_elem = nullptr;
333 }
334
335 str++;
339}
static TowerPolynomial read_poly(char *&str, int level)
static TowerPolynomial alloc_poly_n(int deg, TowerPolynomial *elems=nullptr)
VALGRIND_MAKE_MEM_DEFINED & result(result)