1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
|
/* $NetBSD: lsym_rbrace.c,v 1.7 2023/06/08 06:47:14 rillig Exp $ */
/*
* Tests for the token lsym_rbrace, which represents a '}' in these contexts:
*
* In an initializer, '}' ends an inner group of initializers, usually to
* initialize a nested struct, union or array.
*
* In a function body, '}' ends a block.
*
* In an expression like '(type){...}', '}' ends a compound literal, which is
* typically used in an assignment to a struct or array.
*
* In macro arguments, a '}' is an ordinary character, it does not need to be
* balanced. This is in contrast to '(' and ')', which must be balanced.
*
* TODO: try to split this token into lsym_rbrace_block and lsym_rbrace_init.
*
* See also:
* lsym_lbrace.c
*/
/* Brace level in an initializer */
//indent input
void
function(void)
{
struct person p = {
.name = "Name",
.age = {{{35}}}, /* C11 6.7.9 allows this. */
};
}
//indent end
//indent run-equals-input
/* Begin of a block of statements */
//indent input
void function(void) {{{ body(); }}}
//indent end
//indent run
void
function(void)
{
{
{
body();
}
}
}
//indent end
/* Compound literal */
//indent input
struct point
origin(void)
{
return (struct point){
.x = 0,
.y = 0,
};
}
//indent end
//indent run-equals-input
//indent input
{
int numbers[][] = {
{11},
{21},
{31},
};
int numbers[][] = {{11},
{21},
{31},
};
}
//indent end
//indent run -di0
{
int numbers[][] = {
{11},
{21},
{31},
};
int numbers[][] = {{11},
// $ FIXME: Must be indented.
{21},
{31},
};
}
//indent end
|