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

Function parsePrimaryExpression

jsonpath.js:2170–2225  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

2168 // 11.1 Primary Expressions
2169
2170 function parsePrimaryExpression() {
2171 var type, token, expr, startToken;
2172
2173 if (match('(')) {
2174 return parseGroupExpression();
2175 }
2176
2177 if (match('[')) {
2178 return parseArrayInitialiser();
2179 }
2180
2181 if (match('{')) {
2182 return parseObjectInitialiser();
2183 }
2184
2185 type = lookahead.type;
2186 startToken = lookahead;
2187
2188 if (type === Token.Identifier) {
2189 expr = delegate.createIdentifier(lex().value);
2190 } else if (type === Token.StringLiteral || type === Token.NumericLiteral) {
2191 if (strict && lookahead.octal) {
2192 throwErrorTolerant(lookahead, Messages.StrictOctalLiteral);
2193 }
2194 expr = delegate.createLiteral(lex());
2195 } else if (type === Token.Keyword) {
2196 if (matchKeyword('function')) {
2197 return parseFunctionExpression();
2198 }
2199 if (matchKeyword('this')) {
2200 lex();
2201 expr = delegate.createThisExpression();
2202 } else {
2203 throwUnexpected(lex());
2204 }
2205 } else if (type === Token.BooleanLiteral) {
2206 token = lex();
2207 token.value = (token.value === 'true');
2208 expr = delegate.createLiteral(token);
2209 } else if (type === Token.NullLiteral) {
2210 token = lex();
2211 token.value = null;
2212 expr = delegate.createLiteral(token);
2213 } else if (match('/') || match('/=')) {
2214 if (typeof extra.tokens !== 'undefined') {
2215 expr = delegate.createLiteral(collectRegex());
2216 } else {
2217 expr = delegate.createLiteral(scanRegExp());
2218 }
2219 peek();
2220 } else {
2221 throwUnexpected(lex());
2222 }
2223
2224 return delegate.markEnd(expr, startToken);
2225 }
2226
2227 // 11.2 Left-Hand-Side Expressions

Calls 12

matchFunction · 0.85
parseGroupExpressionFunction · 0.85
parseArrayInitialiserFunction · 0.85
parseObjectInitialiserFunction · 0.85
throwErrorTolerantFunction · 0.85
matchKeywordFunction · 0.85
parseFunctionExpressionFunction · 0.85
throwUnexpectedFunction · 0.85
collectRegexFunction · 0.85
scanRegExpFunction · 0.85
peekFunction · 0.85
lexFunction · 0.70

Tested by

no test coverage detected