static bool parse_array(parser_t *parser, ast_value *array)
{
+ if (array->initlist) {
+ parseerror(parser, "array already initialized elsewhere");
+ return false;
+ }
if (!parser_next(parser)) {
parseerror(parser, "parse error in array initializer");
return false;
}
+ size_t i = 0;
while (parser->tok != '}') {
ast_value *v = (ast_value*)parse_expression_leave(parser, true, false, false);
if (!v)
return false;
}
vec_push(array->initlist, v->constval);
+ if (v->expression.vtype == TYPE_STRING) {
+ array->initlist[i].vstring = util_strdupe(array->initlist[i].vstring);
+ ++i;
+ }
ast_unref(v);
if (parser->tok == '}')
break;
float glob1[7] = { 10, 20, 30, 40, 50, 60, 70 };
float glob2[7] = { 100, 200, 300, 400, 500, 600 };
-float globs[] = { 1, 2, 3 };
+string globs[] = { "Hello ", "World" };
void main() {
float i;
print(" ", ftos(glob2[i]));
print("\n");
- print(ftos(globs[0]));
- for (i = 1; i != 3; ++i)
- print(" ", ftos(globs[i]));
- print("\n");
+ print(globs[0], globs[1], "\n");
}