Lines Matching refs:stmt

62 static struct token *parse_if_statement(struct token *token, struct statement *stmt);
63 static struct token *parse_return_statement(struct token *token, struct statement *stmt);
64 static struct token *parse_loop_iterator(struct token *token, struct statement *stmt);
65 static struct token *parse_default_statement(struct token *token, struct statement *stmt);
66 static struct token *parse_case_statement(struct token *token, struct statement *stmt);
67 static struct token *parse_switch_statement(struct token *token, struct statement *stmt);
68 static struct token *parse_for_statement(struct token *token, struct statement *stmt);
69 static struct token *parse_while_statement(struct token *token, struct statement *stmt);
70 static struct token *parse_do_statement(struct token *token, struct statement *stmt);
71 static struct token *parse_goto_statement(struct token *token, struct statement *stmt);
72 static struct token *parse_context_statement(struct token *token, struct statement *stmt);
73 static struct token *parse_range_statement(struct token *token, struct statement *stmt);
74 static struct token *parse_asm_statement(struct token *token, struct statement *stmt);
664 struct statement *stmt = __alloc_statement(0);
665 stmt->type = type;
666 stmt->pos = pos;
667 return stmt;
1984 static struct token *parse_asm_operands(struct token *token, struct statement *stmt,
2006 static struct token *parse_asm_clobbers(struct token *token, struct statement *stmt,
2019 static struct token *parse_asm_labels(struct token *token, struct statement *stmt,
2035 static struct token *parse_asm_statement(struct token *token, struct statement *stmt)
2040 stmt->type = STMT_ASM;
2050 token = string_expression(token, &stmt->asm_string, "inline asm");
2052 token = parse_asm_operands(token, stmt, &stmt->asm_outputs);
2054 token = parse_asm_operands(token, stmt, &stmt->asm_inputs);
2056 token = parse_asm_clobbers(token, stmt, &stmt->asm_clobbers);
2058 token = parse_asm_labels(token, stmt, &stmt->asm_labels);
2096 struct statement *stmt;
2100 stmt = alloc_statement(expr->pos, STMT_EXPRESSION);
2101 stmt->expression = expr;
2102 return stmt;
2114 static void start_iterator(struct statement *stmt)
2119 cont = alloc_symbol(stmt->pos, SYM_NODE);
2121 brk = alloc_symbol(stmt->pos, SYM_NODE);
2124 stmt->type = STMT_ITERATOR;
2125 stmt->iterator_break = brk;
2126 stmt->iterator_continue = cont;
2131 static void end_iterator(struct statement *stmt)
2139 struct statement *stmt = alloc_statement(sym->pos, STMT_COMPOUND);
2147 stmt->ret = ret;
2153 return stmt;
2174 static void start_switch(struct statement *stmt)
2179 brk = alloc_symbol(stmt->pos, SYM_NODE);
2182 switch_case = alloc_symbol(stmt->pos, SYM_NODE);
2184 switch_case->stmt = stmt;
2186 stmt->type = STMT_SWITCH;
2187 stmt->switch_break = brk;
2188 stmt->switch_case = switch_case;
2194 static void end_switch(struct statement *stmt)
2196 if (!stmt->switch_case->symbol_list)
2197 warning(stmt->pos, "switch with no cases");
2201 static void add_case_statement(struct statement *stmt)
2207 sparse_error(stmt->pos, "not in switch scope");
2208 stmt->type = STMT_NONE;
2211 sym = alloc_symbol(stmt->pos, SYM_NODE);
2213 sym->stmt = stmt;
2214 stmt->case_label = sym;
2218 static struct token *parse_return_statement(struct token *token, struct statement *stmt)
2224 stmt->type = STMT_RETURN;
2225 stmt->ret_target = target;
2226 return expression_statement(token->next, &stmt->ret_value);
2240 static struct token *parse_for_statement(struct token *token, struct statement *stmt)
2246 start_iterator(stmt);
2264 stmt->iterator_syms = syms;
2265 stmt->iterator_pre_statement = make_statement(e1);
2266 stmt->iterator_pre_condition = e2;
2267 stmt->iterator_post_statement = make_statement(e3);
2268 stmt->iterator_post_condition = NULL;
2269 stmt->iterator_statement = iterator;
2270 end_iterator(stmt);
2275 static struct token *parse_while_statement(struct token *token, struct statement *stmt)
2280 start_iterator(stmt);
2284 stmt->iterator_pre_condition = expr;
2285 stmt->iterator_post_condition = NULL;
2286 stmt->iterator_statement = iterator;
2287 end_iterator(stmt);
2292 static struct token *parse_do_statement(struct token *token, struct statement *stmt)
2297 start_iterator(stmt);
2305 stmt->iterator_post_condition = expr;
2306 stmt->iterator_statement = iterator;
2307 end_iterator(stmt);
2315 static struct token *parse_if_statement(struct token *token, struct statement *stmt)
2317 stmt->type = STMT_IF;
2318 token = parens_expression(token->next, &stmt->if_conditional, "after if");
2319 token = statement(token, &stmt->if_true);
2324 return statement(token->next, &stmt->if_false);
2327 static inline struct token *case_statement(struct token *token, struct statement *stmt)
2329 stmt->type = STMT_CASE;
2331 add_case_statement(stmt);
2332 return statement(token, &stmt->case_statement);
2335 static struct token *parse_case_statement(struct token *token, struct statement *stmt)
2337 token = parse_expression(token->next, &stmt->case_expression);
2339 token = parse_expression(token->next, &stmt->case_to);
2340 return case_statement(token, stmt);
2343 static struct token *parse_default_statement(struct token *token, struct statement *stmt)
2345 return case_statement(token->next, stmt);
2348 static struct token *parse_loop_iterator(struct token *token, struct statement *stmt)
2351 stmt->type = STMT_GOTO;
2352 stmt->goto_label = target;
2354 sparse_error(stmt->pos, "break/continue not in iterator scope");
2358 static struct token *parse_switch_statement(struct token *token, struct statement *stmt)
2360 stmt->type = STMT_SWITCH;
2361 start_switch(stmt);
2362 token = parens_expression(token->next, &stmt->switch_expression, "after 'switch'");
2363 token = statement(token, &stmt->switch_statement);
2364 end_switch(stmt);
2378 struct statement *def = label->stmt;
2389 static struct token *parse_goto_statement(struct token *token, struct statement *stmt)
2391 stmt->type = STMT_GOTO;
2394 token = parse_expression(token->next, &stmt->goto_expression);
2395 add_statement(&function_computed_goto_list, stmt);
2398 stmt->goto_label = label;
2399 check_label_usage(label, stmt->pos);
2407 static struct token *parse_context_statement(struct token *token, struct statement *stmt)
2409 stmt->type = STMT_CONTEXT;
2412 token = assignment_expression(token, &stmt->expression);
2413 if (!stmt->expression)
2417 stmt->context = stmt->expression;
2418 token = assignment_expression(token, &stmt->expression);
2419 if (!stmt->expression)
2426 static struct token *parse_range_statement(struct token *token, struct statement *stmt)
2428 stmt->type = STMT_RANGE;
2431 token = assignment_expression(token, &stmt->range_expression);
2433 token = assignment_expression(token, &stmt->range_low);
2435 token = assignment_expression(token, &stmt->range_high);
2451 struct statement *stmt = alloc_statement(token->pos, STMT_NONE);
2453 *tree = stmt;
2457 return s->op->statement(token, stmt);
2462 if (s->stmt) {
2463 sparse_error(stmt->pos, "label '%s' redefined", show_ident(s->ident));
2467 stmt->type = STMT_LABEL;
2468 stmt->label_identifier = s;
2469 stmt->label_scope = label_scope;
2472 warn_label_usage(stmt->pos, s->label_pos, s->ident);
2474 s->stmt = stmt;
2477 stmt->label_statement = alloc_statement(token->pos, STMT_NONE);
2480 return statement(token, &stmt->label_statement);
2485 token = compound_statement(token->next, stmt);
2489 stmt->type = STMT_EXPRESSION;
2490 return expression_statement(token, &stmt->expression);
2493 /* gcc extension - __label__ ident-list; in the beginning of compound stmt */
2516 struct statement * stmt;
2530 stmt = alloc_statement(token->pos, STMT_DECLARATION);
2531 token = external_declaration(token, &stmt->declaration, NULL);
2534 token = statement(token, &stmt);
2536 add_statement(list, stmt);
2589 struct token *compound_statement(struct token *token, struct statement *stmt)
2591 stmt->type = STMT_COMPOUND;
2593 token = statement_list(token, &stmt->stmts);
2741 struct statement *stmt, **p;
2751 p = &base_type->stmt;
2763 stmt = start_function(decl);
2764 *p = stmt;
2770 token = statement_list(token->next, &stmt->stmts);
2794 FOR_EACH_PTR(function_computed_goto_list, stmt) {
2795 stmt->target_list = function_computed_target_list;
2796 } END_FOR_EACH_PTR(stmt);
2875 struct statement *stmt;
2878 stmt = alloc_statement(token->pos, STMT_NONE);
2879 fn->stmt = stmt;
2881 token = parse_asm_statement(token, stmt);