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

Function advance

jsonpath.js:1287–1338  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

1285 }
1286
1287 function advance() {
1288 var ch;
1289
1290 skipComment();
1291
1292 if (index >= length) {
1293 return {
1294 type: Token.EOF,
1295 lineNumber: lineNumber,
1296 lineStart: lineStart,
1297 start: index,
1298 end: index
1299 };
1300 }
1301
1302 ch = source.charCodeAt(index);
1303
1304 if (isIdentifierStart(ch)) {
1305 return scanIdentifier();
1306 }
1307
1308 // Very common: ( and ) and ;
1309 if (ch === 0x28 || ch === 0x29 || ch === 0x3B) {
1310 return scanPunctuator();
1311 }
1312
1313 // String literal starts with single quote (U+0027) or double quote (U+0022).
1314 if (ch === 0x27 || ch === 0x22) {
1315 return scanStringLiteral();
1316 }
1317
1318
1319 // Dot (.) U+002E can also start a floating-point number, hence the need
1320 // to check the next character.
1321 if (ch === 0x2E) {
1322 if (isDecimalDigit(source.charCodeAt(index + 1))) {
1323 return scanNumericLiteral();
1324 }
1325 return scanPunctuator();
1326 }
1327
1328 if (isDecimalDigit(ch)) {
1329 return scanNumericLiteral();
1330 }
1331
1332 // Slash (/) U+002F can also start a regex.
1333 if (extra.tokenize && ch === 0x2F) {
1334 return advanceSlash();
1335 }
1336
1337 return scanPunctuator();
1338 }
1339
1340 function collectToken() {
1341 var loc, token, range, value;

Callers 3

collectTokenFunction · 0.85
lexFunction · 0.85
peekFunction · 0.85

Calls 8

skipCommentFunction · 0.85
isIdentifierStartFunction · 0.85
scanIdentifierFunction · 0.85
scanPunctuatorFunction · 0.85
scanStringLiteralFunction · 0.85
isDecimalDigitFunction · 0.85
scanNumericLiteralFunction · 0.85
advanceSlashFunction · 0.85

Tested by

no test coverage detected