Next: , Previous: Conditional Construct Symbols, Up: Syntactic Symbols

10.2.4 Switch Statement Symbols

Switch statements have their own set of syntactic symbols. Here's an example:

      1: void spam( enum Ingredient i )
      2: {
      3:     switch( i ) {
      4:     case Ham:
      5:         be_a_pig();
      6:         break;
      7:     case Salt:
      8:         drink_some_water();
      9:         break;
     10:     default:
     11:         {
     12:             what_is_it();
     13:             break;
     14:         }
     15:     }
     14: }

Here, lines 4, 7, and 10 are all assigned case-label syntax, while lines 5 and 8 are assigned statement-case-intro. Line 11 is treated slightly differently since it contains a brace that opens a block; it is given statement-case-open syntax.