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

Function parseSwitchStatement

jsonpath.js:3082–3125  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

3080 }
3081
3082 function parseSwitchStatement() {
3083 var discriminant, cases, clause, oldInSwitch, defaultFound;
3084
3085 expectKeyword('switch');
3086
3087 expect('(');
3088
3089 discriminant = parseExpression();
3090
3091 expect(')');
3092
3093 expect('{');
3094
3095 cases = [];
3096
3097 if (match('}')) {
3098 lex();
3099 return delegate.createSwitchStatement(discriminant, cases);
3100 }
3101
3102 oldInSwitch = state.inSwitch;
3103 state.inSwitch = true;
3104 defaultFound = false;
3105
3106 while (index < length) {
3107 if (match('}')) {
3108 break;
3109 }
3110 clause = parseSwitchCase();
3111 if (clause.test === null) {
3112 if (defaultFound) {
3113 throwError({}, Messages.MultipleDefaultsInSwitch);
3114 }
3115 defaultFound = true;
3116 }
3117 cases.push(clause);
3118 }
3119
3120 state.inSwitch = oldInSwitch;
3121
3122 expect('}');
3123
3124 return delegate.createSwitchStatement(discriminant, cases);
3125 }
3126
3127 // 12.13 The throw statement
3128

Callers 1

parseStatementFunction · 0.85

Calls 7

expectKeywordFunction · 0.85
expectFunction · 0.85
parseExpressionFunction · 0.85
matchFunction · 0.85
parseSwitchCaseFunction · 0.85
throwErrorFunction · 0.85
lexFunction · 0.70

Tested by

no test coverage detected