MCPcopy Create free account
hub / github.com/colbymchenry/codegraph / holdsBlock

Function holdsBlock

src/extraction/languages/pascal-preparse.ts:554–574  ·  view source on GitHub ↗

Whether the code from `from` to `to` holds a `begin` or an `asm`: a body, or a part of one.

(s: string, from: number, to: number)

Source from the content-addressed store, hash-verified

552
553/** Whether the code from `from` to `to` holds a `begin` or an `asm`: a body, or a part of one. */
554function holdsBlock(s: string, from: number, to: number): boolean {
555 let i = from;
556 while (i < to) {
557 const k = commentOrStringEnd(s, i);
558 if (k >= 0) {
559 i = k;
560 continue;
561 }
562 if (isIdentStart(s.charCodeAt(i))) {
563 const e = wordEnd(s, i + 1);
564 if (e - i === 3 || e - i === 5) {
565 const word = s.slice(i, e).toLowerCase();
566 if (word === 'begin' || word === 'asm') return true;
567 }
568 i = e;
569 continue;
570 }
571 i++;
572 }
573 return false;
574}
575
576/** The index of the first character from `i` that is neither whitespace nor in a comment, stopping at a conditional group's opening directive. */
577function skipTriviaToGroup(s: string, i: number, groupAt: ReadonlyMap<number, ConditionalGroup>): number {

Callers 1

Calls 3

commentOrStringEndFunction · 0.85
isIdentStartFunction · 0.85
wordEndFunction · 0.70

Tested by

no test coverage detected