CSC448: HW2/3: Switch, default and case [9/18] | ![]() ![]() ![]() |
Option 1: Make default and case labels. (Note that default is not a valid label otherwise so there is no possible confusion.) (For case labels, you can use the number of the case as the label. Note that numbers are not valid labels, and only numbers are valid cases.)
| StatSwitch { Exp exp; Stat stat; }
Option 2a: Does this make sense?
| StatSwitch { Exp exp; Stat stat; } | StatCase { Exp exp; Stat stat; } | StatDefault { Stat stat; }
Option 2b: What about this?
| StatSwitch { Exp exp; List<Stat> stat; } | StatCase { Exp exp; List<Stat> stat; } | StatDefault { List<Stat> stat; }
Option 2c: What about this?
| StatSwitch { Exp exp; List<SwitchStat> stat; } SwitchStat { List<String> labels; } ::= StatCase { Exp exp; List<Stat> stat; } | StatDefault { List<Stat> stat; }