}
}
- if (parser->tok != '{') {
+ if (parser->tok != '{' || var->expression.vtype != TYPE_FUNCTION) {
if (parser->tok != '=') {
parseerror(parser, "missing semicolon or initializer, got: `%s`", parser_tokval(parser));
break;
}
if (parser->tok == '#') {
- ast_function *func = NULL;
- ast_value *number = NULL;
- float fractional = 0;
- float integral = 0;
- int builtin_num = 0;
+ ast_function *func = NULL;
+ ast_value *number = NULL;
+ float fractional;
+ float integral;
+ int builtin_num;
if (localblock) {
parseerror(parser, "cannot declare builtins within functions");
/* we only want the integral part anyways */
builtin_num = integral;
- } else if (parser->tok != TOKEN_INTCONST) {
+ } else if (parser->tok == TOKEN_INTCONST) {
+ builtin_num = parser_token(parser)->constval.i;
+ } else {
parseerror(parser, "builtin number must be a compile time constant");
break;
}
}
vec_push(parser->functions, func);
- func->builtin = -((OPTS_FLAG(EXPRESSIONS_FOR_BUILTINS))
- ? builtin_num
- : parser_token(parser)->constval.i) - 1;
+ func->builtin = -builtin_num-1;
}
if (OPTS_FLAG(EXPRESSIONS_FOR_BUILTINS)
break;
}
}
- else if (parser->tok == '{' || parser->tok == '[')
+ else if (var->expression.vtype == TYPE_ARRAY && parser->tok == '{')
+ {
+ if (localblock) {
+ /* Note that fteqcc and most others don't even *have*
+ * local arrays, so this is not a high priority.
+ */
+ parseerror(parser, "TODO: initializers for local arrays");
+ break;
+ }
+ /*
+static ast_expression* parse_expression_leave(parser_t *parser, bool stopatcomma, bool truthvalue, bool with_labels);
+*/
+ parseerror(parser, "TODO: initializing global arrays is not supported yet!");
+ break;
+ }
+ else if (var->expression.vtype == TYPE_FUNCTION && (parser->tok == '{' || parser->tok == '['))
{
if (localblock) {
parseerror(parser, "cannot declare functions within functions");