(node)
| 3705 | } |
| 3706 | |
| 3707 | function parseSwitchStatement(node) { |
| 3708 | var discriminant, cases, clause, oldInSwitch, defaultFound; |
| 3709 | |
| 3710 | expectKeyword('switch'); |
| 3711 | |
| 3712 | expect('('); |
| 3713 | |
| 3714 | discriminant = parseExpression(); |
| 3715 | |
| 3716 | expect(')'); |
| 3717 | |
| 3718 | expect('{'); |
| 3719 | |
| 3720 | cases = []; |
| 3721 | |
| 3722 | if (match('}')) { |
| 3723 | lex(); |
| 3724 | return node.finishSwitchStatement(discriminant, cases); |
| 3725 | } |
| 3726 | |
| 3727 | oldInSwitch = state.inSwitch; |
| 3728 | state.inSwitch = true; |
| 3729 | defaultFound = false; |
| 3730 | |
| 3731 | while (startIndex < length) { |
| 3732 | if (match('}')) { |
| 3733 | break; |
| 3734 | } |
| 3735 | clause = parseSwitchCase(); |
| 3736 | if (clause.test === null) { |
| 3737 | if (defaultFound) { |
| 3738 | throwError(Messages.MultipleDefaultsInSwitch); |
| 3739 | } |
| 3740 | defaultFound = true; |
| 3741 | } |
| 3742 | cases.push(clause); |
| 3743 | } |
| 3744 | |
| 3745 | state.inSwitch = oldInSwitch; |
| 3746 | |
| 3747 | expect('}'); |
| 3748 | |
| 3749 | return node.finishSwitchStatement(discriminant, cases); |
| 3750 | } |
| 3751 | |
| 3752 | // 12.13 The throw statement |
| 3753 |
no test coverage detected