()
| 3080 | } |
| 3081 | |
| 3082 | function parseSwitchStatement() { |
| 3083 | var discriminant, cases, clause, oldInSwitch, defaultFound; |
| 3084 | |
| 3085 | expectKeyword('switch'); |
| 3086 | |
| 3087 | expect('('); |
| 3088 | |
| 3089 | discriminant = parseExpression(); |
| 3090 | |
| 3091 | expect(')'); |
| 3092 | |
| 3093 | expect('{'); |
| 3094 | |
| 3095 | cases = []; |
| 3096 | |
| 3097 | if (match('}')) { |
| 3098 | lex(); |
| 3099 | return delegate.createSwitchStatement(discriminant, cases); |
| 3100 | } |
| 3101 | |
| 3102 | oldInSwitch = state.inSwitch; |
| 3103 | state.inSwitch = true; |
| 3104 | defaultFound = false; |
| 3105 | |
| 3106 | while (index < length) { |
| 3107 | if (match('}')) { |
| 3108 | break; |
| 3109 | } |
| 3110 | clause = parseSwitchCase(); |
| 3111 | if (clause.test === null) { |
| 3112 | if (defaultFound) { |
| 3113 | throwError({}, Messages.MultipleDefaultsInSwitch); |
| 3114 | } |
| 3115 | defaultFound = true; |
| 3116 | } |
| 3117 | cases.push(clause); |
| 3118 | } |
| 3119 | |
| 3120 | state.inSwitch = oldInSwitch; |
| 3121 | |
| 3122 | expect('}'); |
| 3123 | |
| 3124 | return delegate.createSwitchStatement(discriminant, cases); |
| 3125 | } |
| 3126 | |
| 3127 | // 12.13 The throw statement |
| 3128 |
no test coverage detected