(token)
| 5142 | // Throw an exception because of the token. |
| 5143 | |
| 5144 | function throwUnexpected(token) { |
| 5145 | if (token.type === Token.EOF) { |
| 5146 | throwError(token, Messages.UnexpectedEOS); |
| 5147 | } |
| 5148 | |
| 5149 | if (token.type === Token.NumericLiteral) { |
| 5150 | throwError(token, Messages.UnexpectedNumber); |
| 5151 | } |
| 5152 | |
| 5153 | if (token.type === Token.StringLiteral || token.type === Token.JSXText) { |
| 5154 | throwError(token, Messages.UnexpectedString); |
| 5155 | } |
| 5156 | |
| 5157 | if (token.type === Token.Identifier) { |
| 5158 | throwError(token, Messages.UnexpectedIdentifier); |
| 5159 | } |
| 5160 | |
| 5161 | if (token.type === Token.Keyword) { |
| 5162 | if (isFutureReservedWord(token.value)) { |
| 5163 | throwError(token, Messages.UnexpectedReserved); |
| 5164 | } else if (strict && isStrictModeReservedWord(token.value)) { |
| 5165 | throwErrorTolerant(token, Messages.StrictReservedWord); |
| 5166 | return; |
| 5167 | } |
| 5168 | throwError(token, Messages.UnexpectedToken, token.value); |
| 5169 | } |
| 5170 | |
| 5171 | if (token.type === Token.Template) { |
| 5172 | throwError(token, Messages.UnexpectedTemplate, token.value.raw); |
| 5173 | } |
| 5174 | |
| 5175 | // BooleanLiteral, NullLiteral, or Punctuator. |
| 5176 | throwError(token, Messages.UnexpectedToken, token.value); |
| 5177 | } |
| 5178 | |
| 5179 | // Expect the next token to match the specified punctuator. |
| 5180 | // If not, an exception will be thrown. |
no test coverage detected