2 * (c) copyright 1987 by the Vrije Universiteit, Amsterdam, The Netherlands.
3 * See the copyright notice in the ACK home directory, in the file "Copyright".
5 /* $Id: statement.g,v 1.8 1994/06/27 08:02:37 ceriel Exp $ */
6 /* STATEMENT SYNTAX PARSER */
18 #include "botch_free.h"
21 #include <flt_arith.h>
36 extern char options[];
39 /* Each statement construction is stacked in order to trace a
40 * statement to such a construction. Example: a case statement should
41 * be recognized as a piece of the most enclosing switch statement.
107 print_expr("expression_statement", expr);
109 code_expr(expr, RVAL, FALSE, NO_LABEL, NO_LABEL);
110 free_expression(expr);
114 /* 3.6.1 (partially) */
120 /* This allows the following absurd case:
124 grz: printf("A labelled statement\n");
131 C_df_ilb((label)idf->id_label->df_address);
139 label l_true = text_label();
140 label l_false = text_label();
141 label l_end = text_label();
148 opnd2test(&expr, IF);
149 if (is_cp_cst(expr)) {
150 /* The comparison has been optimized
153 if (expr->VL_VALUE == (arith)0) {
156 /* else fall through */
162 code_expr(expr, RVAL, TRUE, l_true, l_false);
168 free_expression(expr);
201 label l_break = text_label();
202 label l_continue = text_label();
203 label l_body = text_label();
208 stack_stmt(l_break, l_continue);
209 C_df_ilb(l_continue);
214 opnd2test(&expr, WHILE);
215 if (is_cp_cst(expr)) {
216 if (expr->VL_VALUE == (arith)0) {
221 code_expr(expr, RVAL, TRUE, l_body, l_break);
225 start_while_stmt(expr);
234 free_expression(expr);
245 label l_break = text_label();
246 label l_continue = text_label();
247 label l_body = text_label();
252 stack_stmt(l_break, l_continue);
264 C_df_ilb(l_continue);
268 opnd2test(&expr, WHILE);
269 if (is_cp_cst(expr)) {
270 if (expr->VL_VALUE == (arith)1) {
274 end_do_stmt(1, expr->VL_VALUE != (arith)0);
278 code_expr(expr, RVAL, TRUE, l_body, l_break);
289 free_expression(expr);
295 { struct expr *e_init = 0, *e_test = 0, *e_incr = 0;
296 label l_break = text_label();
297 label l_continue = text_label();
298 label l_body = text_label();
299 label l_test = text_label();
303 { stack_stmt(l_break, l_continue);
308 { code_expr(e_init, RVAL, FALSE, NO_LABEL, NO_LABEL);
317 opnd2test(&e_test, FOR);
318 if (is_cp_cst(e_test)) {
319 if (e_test->VL_VALUE == (arith)0) {
324 code_expr(e_test, RVAL, TRUE, l_body, l_break);
334 start_for_stmt(e_test);
342 C_df_ilb(l_continue);
344 code_expr(e_incr, RVAL, FALSE,
349 free_expression(e_init);
350 free_expression(e_test);
351 free_expression(e_incr);
368 code_startswitch(&expr);
370 start_switch_part(is_cp_cst(expr));
380 free_expression(expr);
384 /* 3.6.1 (partially) */
391 constant_expression(&expr)
397 free_expression(expr);
403 /* 3.6.1 (partially) */
419 { struct expr *expr = 0;
430 do_return_expr(expr);
431 free_expression(expr);
433 lint_return_stmt(VALRETURNED);
441 lint_return_stmt(NOVALRETURNED);
448 /* 3.6.6.1 (partially) */
458 C_bra((label)idf->id_label->df_address);
469 static int brc_level = 1;
470 int decl_seen = brc_level == 1;
471 #endif /* DBSYMTAB */
478 [%while ((DOT != IDENTIFIER && AHEAD != ':') ||
479 (DOT == IDENTIFIER && AHEAD == IDENTIFIER))
480 /* >>> conflict on TYPE_IDENTIFIER, IDENTIFIER */
485 #endif /* DBSYMTAB */
491 if (options['g'] && decl_seen) {
492 C_ms_std((char *) 0, N_LBRAC, brc_level);
494 #endif /* DBSYMTAB */
503 if (options['g'] && decl_seen) {
504 C_ms_std((char *) 0, N_RBRAC, brc_level);
507 #endif /* DBSYMTAB */