(token)
| 1877 | // Throw an exception because of the token. |
| 1878 | |
| 1879 | function throwUnexpected(token) { |
| 1880 | if (token.type === Token.EOF) { |
| 1881 | throwError(token, Messages.UnexpectedEOS); |
| 1882 | } |
| 1883 | |
| 1884 | if (token.type === Token.NumericLiteral) { |
| 1885 | throwError(token, Messages.UnexpectedNumber); |
| 1886 | } |
| 1887 | |
| 1888 | if (token.type === Token.StringLiteral) { |
| 1889 | throwError(token, Messages.UnexpectedString); |
| 1890 | } |
| 1891 | |
| 1892 | if (token.type === Token.Identifier) { |
| 1893 | throwError(token, Messages.UnexpectedIdentifier); |
| 1894 | } |
| 1895 | |
| 1896 | if (token.type === Token.Keyword) { |
| 1897 | if (isFutureReservedWord(token.value)) { |
| 1898 | throwError(token, Messages.UnexpectedReserved); |
| 1899 | } else if (strict && isStrictModeReservedWord(token.value)) { |
| 1900 | throwErrorTolerant(token, Messages.StrictReservedWord); |
| 1901 | return; |
| 1902 | } |
| 1903 | throwError(token, Messages.UnexpectedToken, token.value); |
| 1904 | } |
| 1905 | |
| 1906 | // BooleanLiteral, NullLiteral, or Punctuator. |
| 1907 | throwError(token, Messages.UnexpectedToken, token.value); |
| 1908 | } |
| 1909 | |
| 1910 | // Expect the next token to match the specified punctuator. |
| 1911 | // If not, an exception will be thrown. |
no test coverage detected