X-Git-Url: https://ocean-lang.org/code/?p=ocean;a=blobdiff_plain;f=csrc%2Foceani.mdc;h=02968bb473926333f3341ed78663d24d2b9144dd;hp=07caefafca523bf1014752bf1cc228f0f7689a72;hb=e337fbef5e42c992089fe1e51292f2f82380642d;hpb=bdabb1a2d91b54bceef373b2b06ea1e2d1006cf5 diff --git a/csrc/oceani.mdc b/csrc/oceani.mdc index 07caefa..02968bb 100644 --- a/csrc/oceani.mdc +++ b/csrc/oceani.mdc @@ -3430,26 +3430,31 @@ make a copy of an array with controllable depth. $0->array.member = $<4; $0->array.vsize = NULL; { + struct parse_context *c = config2context(config); char tail[3]; mpq_t num; if (number_parse(num, tail, $2.txt) == 0) - tok_err(config2context(config), "error: unrecognised number", &$2); + tok_err(c, "error: unrecognised number", &$2); else if (tail[0]) - tok_err(config2context(config), "error: unsupported number suffix", &$2); + tok_err(c, "error: unsupported number suffix", &$2); else { $0->array.size = mpz_get_ui(mpq_numref(num)); if (mpz_cmp_ui(mpq_denref(num), 1) != 0) { - tok_err(config2context(config), "error: array size must be an integer", + tok_err(c, "error: array size must be an integer", &$2); } else if (mpz_cmp_ui(mpq_numref(num), 1UL << 30) >= 0) - tok_err(config2context(config), "error: array size is too large", + tok_err(c, "error: array size is too large", &$2); + mpq_clear(num); } + $0->next= c->anon_typelist; + c->anon_typelist = $0; } }$ | [ IDENTIFIER ] Type ${ { - struct variable *v = var_ref(config2context(config), $2.txt); + struct parse_context *c = config2context(config); + struct variable *v = var_ref(c, $2.txt); if (!v) tok_err(config2context(config), "error: name undeclared", &$2); @@ -3461,8 +3466,23 @@ make a copy of an array with controllable depth. $0->array.member = $<4; $0->array.size = 0; $0->array.vsize = v; + $0->next= c->anon_typelist; + c->anon_typelist = $0; } }$ +###### parse context + + struct type *anon_typelist; + +###### free context types + + while (context.anon_typelist) { + struct type *t = context.anon_typelist; + + context.anon_typelist = t->next; + free(t); + } + ###### Binode types Index,