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

Function parseFunctionSourceElements

jsonpath.js:3291–3352  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

3289 // 13 Function Definition
3290
3291 function parseFunctionSourceElements() {
3292 var sourceElement, sourceElements = [], token, directive, firstRestricted,
3293 oldLabelSet, oldInIteration, oldInSwitch, oldInFunctionBody, startToken;
3294
3295 startToken = lookahead;
3296 expect('{');
3297
3298 while (index < length) {
3299 if (lookahead.type !== Token.StringLiteral) {
3300 break;
3301 }
3302 token = lookahead;
3303
3304 sourceElement = parseSourceElement();
3305 sourceElements.push(sourceElement);
3306 if (sourceElement.expression.type !== Syntax.Literal) {
3307 // this is not directive
3308 break;
3309 }
3310 directive = source.slice(token.start + 1, token.end - 1);
3311 if (directive === 'use strict') {
3312 strict = true;
3313 if (firstRestricted) {
3314 throwErrorTolerant(firstRestricted, Messages.StrictOctalLiteral);
3315 }
3316 } else {
3317 if (!firstRestricted && token.octal) {
3318 firstRestricted = token;
3319 }
3320 }
3321 }
3322
3323 oldLabelSet = state.labelSet;
3324 oldInIteration = state.inIteration;
3325 oldInSwitch = state.inSwitch;
3326 oldInFunctionBody = state.inFunctionBody;
3327
3328 state.labelSet = {};
3329 state.inIteration = false;
3330 state.inSwitch = false;
3331 state.inFunctionBody = true;
3332
3333 while (index < length) {
3334 if (match('}')) {
3335 break;
3336 }
3337 sourceElement = parseSourceElement();
3338 if (typeof sourceElement === 'undefined') {
3339 break;
3340 }
3341 sourceElements.push(sourceElement);
3342 }
3343
3344 expect('}');
3345
3346 state.labelSet = oldLabelSet;
3347 state.inIteration = oldInIteration;
3348 state.inSwitch = oldInSwitch;

Callers 3

parsePropertyFunctionFunction · 0.85
parseFunctionDeclarationFunction · 0.85
parseFunctionExpressionFunction · 0.85

Calls 4

expectFunction · 0.85
parseSourceElementFunction · 0.85
throwErrorTolerantFunction · 0.85
matchFunction · 0.85

Tested by

no test coverage detected