Usage of switch expression with only else case
According to the grammar of CIF, we allow a switch expression to be only the else
case as the SwitchBody
.
ExpressionFactor : ...
| "switch" Expression ":" SwitchBody "end"
SwitchBody : SwitchCases
| SwitchCases "else" Expression
| "else" Expression
;
SwitchCases : "case" Expression ":" Expression
| SwitchCases "case" Expression ":" Expression
This seems to be a convoluted way of just writing the expression related to the else
case. Is there an actual use case for having a switch statement with only the else
case? Otherwise, I propose to change the grammar to
SwitchBody : SwitchCases
| SwitchCases "else" Expression
;