MCPcopy Create free account
hub / github.com/codemix/graph / peg$computePosDetails

Function peg$computePosDetails

packages/graph/src/grammar.js:2420–2455  ·  view source on GitHub ↗
(pos)

Source from the content-addressed store, hash-verified

2418 }
2419
2420 function peg$computePosDetails(pos) {
2421 let details = peg$posDetailsCache[pos];
2422 let p;
2423
2424 if (details) {
2425 return details;
2426 } else {
2427 if (pos >= peg$posDetailsCache.length) {
2428 p = peg$posDetailsCache.length - 1;
2429 } else {
2430 p = pos;
2431 while (!peg$posDetailsCache[--p]) {}
2432 }
2433
2434 details = peg$posDetailsCache[p];
2435 details = {
2436 line: details.line,
2437 column: details.column,
2438 };
2439
2440 while (p < pos) {
2441 if (input.charCodeAt(p) === 10) {
2442 details.line++;
2443 details.column = 1;
2444 } else {
2445 details.column++;
2446 }
2447
2448 p++;
2449 }
2450
2451 peg$posDetailsCache[pos] = details;
2452
2453 return details;
2454 }
2455 }
2456
2457 function peg$computeLocation(startPos, endPos, offset) {
2458 const startPosDetails = peg$computePosDetails(startPos);

Callers 1

peg$computeLocationFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected