MCPcopy Create free account
hub / github.com/dchester/jsonpath / throwUnexpected

Function throwUnexpected

jsonpath.js:1879–1908  ·  view source on GitHub ↗
(token)

Source from the content-addressed store, hash-verified

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.

Callers 9

expectFunction · 0.85
expectKeywordFunction · 0.85
consumeSemicolonFunction · 0.85
parseObjectPropertyFunction · 0.85
parsePrimaryExpressionFunction · 0.85
parseNonComputedPropertyFunction · 0.85
parseVariableIdentifierFunction · 0.85
parseCatchClauseFunction · 0.85
parseStatementFunction · 0.85

Calls 4

throwErrorFunction · 0.85
isFutureReservedWordFunction · 0.85
isStrictModeReservedWordFunction · 0.85
throwErrorTolerantFunction · 0.85

Tested by

no test coverage detected