static bool parse_variable(parser_t *parser, ast_block *localblock, bool nofields, int qualifier, ast_value *cached_typedef);
static ast_block* parse_block(parser_t *parser);
static bool parse_block_into(parser_t *parser, ast_block *block);
-static ast_expression* parse_statement_or_block(parser_t *parser);
+static bool parse_statement_or_block(parser_t *parser, ast_expression **out);
static bool parse_statement(parser_t *parser, ast_block *block, ast_expression **out, bool allow_cases);
static ast_expression* parse_expression_leave(parser_t *parser, bool stopatcomma);
static ast_expression* parse_expression(parser_t *parser, bool stopatcomma);
ast_delete(cond);
return false;
}
- ontrue = parse_statement_or_block(parser);
- if (!ontrue) {
+ if (!parse_statement_or_block(parser, &ontrue)) {
ast_delete(cond);
return false;
}
ast_delete(cond);
return false;
}
- onfalse = parse_statement_or_block(parser);
- if (!onfalse) {
+ if (!parse_statement_or_block(parser, &onfalse)) {
ast_delete(ontrue);
ast_delete(cond);
return false;
ast_delete(cond);
return false;
}
- ontrue = parse_statement_or_block(parser);
- if (!ontrue) {
+ if (!parse_statement_or_block(parser, &ontrue)) {
ast_delete(cond);
return false;
}
parseerror(parser, "expected loop body");
return false;
}
- ontrue = parse_statement_or_block(parser);
- if (!ontrue)
+ if (!parse_statement_or_block(parser, &ontrue))
return false;
/* expect the "while" */
parseerror(parser, "expected for-loop body");
goto onerr;
}
- ontrue = parse_statement_or_block(parser);
- if (!ontrue) {
+ if (!parse_statement_or_block(parser, &ontrue))
goto onerr;
- }
aloop = ast_loop_new(ctx, initexpr, cond, NULL, increment, ontrue);
*out = (ast_expression*)aloop;
return block;
}
-static ast_expression* parse_statement_or_block(parser_t *parser)
+static bool parse_statement_or_block(parser_t *parser, ast_expression **out)
{
- ast_expression *expr = NULL;
- if (parser->tok == '{')
- return (ast_expression*)parse_block(parser);
- if (!parse_statement(parser, NULL, &expr, false))
- return NULL;
- return expr;
+ if (parser->tok == '{') {
+ *out = (ast_expression*)parse_block(parser);
+ return !!*out;
+ }
+ return parse_statement(parser, NULL, out, false);
}
static bool create_vector_members(ast_value *var, ast_member **me)