Next: , Previous: , Up: Syntactic Symbols   [Contents][Index]

10.2.5 Brace List Symbols

There are a set of syntactic symbols that are used to recognize constructs inside of brace lists. A brace list is defined as an enum or aggregate initializer list, such as might statically initialize an array of structs. The three special aggregate constructs in Pike, ({ }), ([ ]) and (< >), are treated as brace lists too. An example:

 1: static char* ingredients[] =
 2: {
 3:     "Ham",
 4:     "Salt",
 5:     NULL
 6: };

Following convention, line 2 in this example is assigned brace-list-open syntax, and line 3 is assigned brace-list-intro syntax. Likewise, line 6 is assigned brace-list-close syntax. Lines 4 and 5 however, are assigned brace-list-entry syntax, as would all subsequent lines in this initializer list.

Your static initializer might be initializing nested structures, for example:

 1: struct intpairs[] =
 2: {
 3:     { 1, 2 },
 4:     {
 5:         3,
 6:         4
 7:     }
 8:     { 1,
 9:       2 },
10:     { 3, 4 }
11: };

Here, you’ve already seen the analysis of lines 1, 2, 3, and 11. On line 4, things get interesting; this line is assigned brace-entry-open syntactic symbol because it’s a bracelist entry line that starts with an open brace. Lines 5 and 6 (and line 9) are pretty standard, and line 7 is a brace-list-close as you’d expect. Once again, line 8 is assigned as brace-entry-open as is line 10.