xref: /netbsd-src/tests/usr.bin/indent/psym_if_expr_stmt.c (revision ac44793a2e00cec9486cd83f506ba438e09cad07)
1 /* $NetBSD: psym_if_expr_stmt.c,v 1.5 2025/01/07 03:14:24 rillig Exp $ */
2 
3 /*
4  * Tests for the parser symbol psym_if_expr_stmt, which represents the state
5  * after reading the keyword 'if', the controlling expression and the
6  * statement for the 'then' branch.
7  *
8  * At this point, the 'if' statement is not necessarily complete, it can be
9  * completed with the keyword 'else' followed by a statement.
10  *
11  * Any token other than 'else' completes the 'if' statement.
12  */
13 
14 //indent input
15 void
16 function(void)
17 {
18 	if (cond)
19 		stmt();
20 	if (cond)
21 		stmt();
22 	else			/* belongs to the second 'if' */
23 		stmt();
24 }
25 //indent end
26 
27 //indent run-equals-input
28 
29 
30 //indent input
31 {
32 for (ever1)
33 for (ever2)
34 for (ever3)
35 if (cond1)
36 if (cond2)
37 if (cond3)
38 return;
39 
40 stmt;
41 }
42 //indent end
43 
44 //indent run
45 {
46 	for (ever1)
47 		for (ever2)
48 			for (ever3)
49 				if (cond1)
50 					if (cond2)
51 						if (cond3)
52 							return;
53 
54 	stmt;
55 }
56 //indent end
57