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

Function parseFunctionDeclaration

jsonpath.js:3404–3445  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

3402 }
3403
3404 function parseFunctionDeclaration() {
3405 var id, params = [], body, token, stricted, tmp, firstRestricted, message, previousStrict, startToken;
3406
3407 startToken = lookahead;
3408
3409 expectKeyword('function');
3410 token = lookahead;
3411 id = parseVariableIdentifier();
3412 if (strict) {
3413 if (isRestrictedWord(token.value)) {
3414 throwErrorTolerant(token, Messages.StrictFunctionName);
3415 }
3416 } else {
3417 if (isRestrictedWord(token.value)) {
3418 firstRestricted = token;
3419 message = Messages.StrictFunctionName;
3420 } else if (isStrictModeReservedWord(token.value)) {
3421 firstRestricted = token;
3422 message = Messages.StrictReservedWord;
3423 }
3424 }
3425
3426 tmp = parseParams(firstRestricted);
3427 params = tmp.params;
3428 stricted = tmp.stricted;
3429 firstRestricted = tmp.firstRestricted;
3430 if (tmp.message) {
3431 message = tmp.message;
3432 }
3433
3434 previousStrict = strict;
3435 body = parseFunctionSourceElements();
3436 if (strict && firstRestricted) {
3437 throwError(firstRestricted, message);
3438 }
3439 if (strict && stricted) {
3440 throwErrorTolerant(stricted, message);
3441 }
3442 strict = previousStrict;
3443
3444 return delegate.markEnd(delegate.createFunctionDeclaration(id, params, [], body), startToken);
3445 }
3446
3447 function parseFunctionExpression() {
3448 var token, id = null, stricted, firstRestricted, message, tmp, params = [], body, previousStrict, startToken;

Callers 2

parseStatementFunction · 0.85
parseSourceElementFunction · 0.85

Calls 8

expectKeywordFunction · 0.85
parseVariableIdentifierFunction · 0.85
isRestrictedWordFunction · 0.85
throwErrorTolerantFunction · 0.85
isStrictModeReservedWordFunction · 0.85
parseParamsFunction · 0.85
throwErrorFunction · 0.85

Tested by

no test coverage detected