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

Function peg$computePosDetails

lib/parser.js:883–914  ·  view source on GitHub ↗
(pos)

Source from the content-addressed store, hash-verified

881 }
882
883 function peg$computePosDetails(pos) {
884 function advance(details, startPos, endPos) {
885 var p, ch;
886
887 for (p = startPos; p < endPos; p++) {
888 ch = input.charAt(p);
889 if (ch === "\n") {
890 if (!details.seenCR) { details.line++; }
891 details.column = 1;
892 details.seenCR = false;
893 } else if (ch === "\r" || ch === "\u2028" || ch === "\u2029") {
894 details.line++;
895 details.column = 1;
896 details.seenCR = true;
897 } else {
898 details.column++;
899 details.seenCR = false;
900 }
901 }
902 }
903
904 if (peg$cachedPos !== pos) {
905 if (peg$cachedPos > pos) {
906 peg$cachedPos = 0;
907 peg$cachedPosDetails = { line: 1, column: 1, seenCR: false };
908 }
909 advance(peg$cachedPosDetails, peg$cachedPos, pos);
910 peg$cachedPos = pos;
911 }
912
913 return peg$cachedPosDetails;
914 }
915
916 function peg$fail(expected) {
917 if (peg$currPos < peg$maxFailPos) { return; }

Callers 3

lineFunction · 0.85
columnFunction · 0.85
peg$buildExceptionFunction · 0.85

Calls 1

advanceFunction · 0.85

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…