MCPcopy Index your code
hub / github.com/dchester/jsonpath / parseForStatement

Function parseForStatement

jsonpath.js:2837–2907  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

2835 }
2836
2837 function parseForStatement() {
2838 var init, test, update, left, right, body, oldInIteration, previousAllowIn = state.allowIn;
2839
2840 init = test = update = null;
2841
2842 expectKeyword('for');
2843
2844 expect('(');
2845
2846 if (match(';')) {
2847 lex();
2848 } else {
2849 if (matchKeyword('var') || matchKeyword('let')) {
2850 state.allowIn = false;
2851 init = parseForVariableDeclaration();
2852 state.allowIn = previousAllowIn;
2853
2854 if (init.declarations.length === 1 && matchKeyword('in')) {
2855 lex();
2856 left = init;
2857 right = parseExpression();
2858 init = null;
2859 }
2860 } else {
2861 state.allowIn = false;
2862 init = parseExpression();
2863 state.allowIn = previousAllowIn;
2864
2865 if (matchKeyword('in')) {
2866 // LeftHandSideExpression
2867 if (!isLeftHandSide(init)) {
2868 throwErrorTolerant({}, Messages.InvalidLHSInForIn);
2869 }
2870
2871 lex();
2872 left = init;
2873 right = parseExpression();
2874 init = null;
2875 }
2876 }
2877
2878 if (typeof left === 'undefined') {
2879 expect(';');
2880 }
2881 }
2882
2883 if (typeof left === 'undefined') {
2884
2885 if (!match(';')) {
2886 test = parseExpression();
2887 }
2888 expect(';');
2889
2890 if (!match(')')) {
2891 update = parseExpression();
2892 }
2893 }
2894

Callers 1

parseStatementFunction · 0.85

Calls 10

expectKeywordFunction · 0.85
expectFunction · 0.85
matchFunction · 0.85
matchKeywordFunction · 0.85
parseExpressionFunction · 0.85
isLeftHandSideFunction · 0.85
throwErrorTolerantFunction · 0.85
parseStatementFunction · 0.85
lexFunction · 0.70

Tested by

no test coverage detected