Home | History | Annotate | Line # | Download | only in indent
psym_for_exprs.c revision 1.5
      1 /* $NetBSD: psym_for_exprs.c,v 1.5 2023/05/15 08:22:23 rillig Exp $ */
      2 
      3 /*
      4  * Tests for the parser state psym_for_exprs, which represents the state after
      5  * reading the keyword 'for' and the 3 expressions, now waiting for the body
      6  * of the loop.
      7  */
      8 
      9 //indent input
     10 void
     11 for_loops(void)
     12 {
     13 	for (int i = 0; i < 10; i++)
     14 		printf("%d * %d = %d\n", i, 7, i * 7);
     15 
     16 	for (int i = 0; i < 10; i++) {
     17 		printf("%d * %d = %d\n", i, 7, i * 7);
     18 	}
     19 }
     20 //indent end
     21 
     22 //indent run
     23 void
     24 for_loops(void)
     25 {
     26 	for (int i = 0; i < 10; i++)
     27 		printf("%d * %d = %d\n", i, 7, i * 7);
     28 
     29 	/* $ FIXME: Add space between ')' and '{'. */
     30 	for (int i = 0; i < 10; i++){
     31 		printf("%d * %d = %d\n", i, 7, i * 7);
     32 	}
     33 }
     34 //indent end
     35 
     36 
     37 /*
     38  * Since C99, the first expression of a 'for' loop may be a declaration, not
     39  * only an expression.
     40  */
     41 //indent input
     42 void
     43 small_scope(void)
     44 {
     45 	for (int i = 0; i < 3; i++)
     46 		stmt();
     47 }
     48 //indent end
     49 
     50 //indent run-equals-input
     51