1 /* $NetBSD: lsym_question.c,v 1.2 2021/11/28 16:20:13 rillig Exp $ */ 2 /* $FreeBSD$ */ 3 4 /* 5 * Tests for the token lsym_question, which represents the '?' in a '?:' 6 * conditional expression. 7 */ 8 9 #indent input 10 const char *result = cond ? "then" : "else"; 11 12 const char *multi = cond1 ? "cond1" : cond2 ? "cond2" : cond3 ? "cond3" : ""; 13 #indent end 14 15 #indent run-equals-input -di0 16 17 18 /* 19 * To make them easier to read, conditional expressions can be split into 20 * multiple lines. 21 */ 22 #indent input 23 const char *separate_lines = cond 24 ? "then" 25 : "else"; 26 #indent end 27 28 #indent run -di0 29 const char *separate_lines = cond 30 // $ XXX: Continuation lines in expressions should be indented, even in column 1. 31 ? "then" 32 : "else"; 33 #indent end 34 35 36 /* 37 * In functions, conditional expressions are indented as intended. 38 */ 39 #indent input 40 void 41 function(void) 42 { 43 return cond 44 ? "then" 45 : "else"; 46 } 47 #indent end 48 49 #indent run-equals-input 50 51 52 /* 53 * In functions, conditional expressions are indented as intended. 54 */ 55 #indent input 56 void 57 function(void) 58 { 59 const char *branch = cond 60 // $ TODO: Indent these continuation lines as they are part of the 61 // $ TODO: initializer expression, not of the declarator part to the 62 // $ TODO: left of the '='. 63 ? "then" 64 : "else"; 65 } 66 #indent end 67 68 #indent run-equals-input -di0 69