MCPcopy
hub / github.com/BloombergGraphics/whatiscode / parseFunctionDeclaration

Function parseFunctionDeclaration

scripts/libs/esprima.js:4066–4106  ·  view source on GitHub ↗
(node)

Source from the content-addressed store, hash-verified

4064 }
4065
4066 function parseFunctionDeclaration(node) {
4067 var id, params = [], defaults = [], body, token, stricted, tmp, firstRestricted, message, previousStrict;
4068
4069 expectKeyword('function');
4070 token = lookahead;
4071 id = parseVariableIdentifier();
4072 if (strict) {
4073 if (isRestrictedWord(token.value)) {
4074 tolerateUnexpectedToken(token, Messages.StrictFunctionName);
4075 }
4076 } else {
4077 if (isRestrictedWord(token.value)) {
4078 firstRestricted = token;
4079 message = Messages.StrictFunctionName;
4080 } else if (isStrictModeReservedWord(token.value)) {
4081 firstRestricted = token;
4082 message = Messages.StrictReservedWord;
4083 }
4084 }
4085
4086 tmp = parseParams(firstRestricted);
4087 params = tmp.params;
4088 defaults = tmp.defaults;
4089 stricted = tmp.stricted;
4090 firstRestricted = tmp.firstRestricted;
4091 if (tmp.message) {
4092 message = tmp.message;
4093 }
4094
4095 previousStrict = strict;
4096 body = parseFunctionSourceElements();
4097 if (strict && firstRestricted) {
4098 throwUnexpectedToken(firstRestricted, message);
4099 }
4100 if (strict && stricted) {
4101 tolerateUnexpectedToken(stricted, message);
4102 }
4103 strict = previousStrict;
4104
4105 return node.finishFunctionDeclaration(id, params, defaults, body);
4106 }
4107
4108 function parseFunctionExpression() {
4109 var token, id = null, stricted, firstRestricted, message, tmp,

Callers 2

parseStatementListItemFunction · 0.85
parseStatementFunction · 0.85

Calls 8

expectKeywordFunction · 0.85
parseVariableIdentifierFunction · 0.85
isRestrictedWordFunction · 0.85
tolerateUnexpectedTokenFunction · 0.85
isStrictModeReservedWordFunction · 0.85
parseParamsFunction · 0.85
throwUnexpectedTokenFunction · 0.85

Tested by

no test coverage detected