MCPcopy Create free account
hub / github.com/estools/esquery / peg$computePosDetails

Function peg$computePosDetails

parser.js:349–380  ·  view source on GitHub ↗
(pos)

Source from the content-addressed store, hash-verified

347 }
348
349 function peg$computePosDetails(pos) {
350 var details = peg$posDetailsCache[pos], p;
351
352 if (details) {
353 return details;
354 } else {
355 p = pos - 1;
356 while (!peg$posDetailsCache[p]) {
357 p--;
358 }
359
360 details = peg$posDetailsCache[p];
361 details = {
362 line: details.line,
363 column: details.column
364 };
365
366 while (p < pos) {
367 if (input.charCodeAt(p) === 10) {
368 details.line++;
369 details.column = 1;
370 } else {
371 details.column++;
372 }
373
374 p++;
375 }
376
377 peg$posDetailsCache[pos] = details;
378 return details;
379 }
380 }
381
382 function peg$computeLocation(startPos, endPos) {
383 var startPosDetails = peg$computePosDetails(startPos),

Callers 1

peg$computeLocationFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected