Case Statement

The “case” or “switch” statement is available in various languages. The following is the syntax for the case statement:

Translation of Switch Statement

The translation scheme for the above code is shown below:

Code to evaluate E into T

  • When we see the switch keyword, two labels test and next and a temporary variable t are generated.
  • When we see the case keyword, a new label Li is created and entered into the symbol table. It is used to store the value Vi of the constant Li, or a pointer to the symbol table entry for Li is placed in the queue.

source