psym_if_expr_stmt.c revision 1.5
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 15void 16function(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{ 32for (ever1) 33for (ever2) 34for (ever3) 35if (cond1) 36if (cond2) 37if (cond3) 38return; 39 40stmt; 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