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

Function commentOrStringEnd

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

* The index after the comment or string that starts at `i`, or -1 when none * does. Pascal comments are `{…}` (compiler directives included), `(*…*)` and * `//…`; a string is `'…'` with `''` for a quote and ends at its line's end * when unterminated.

(s: string, i: number)

Source from the content-addressed store, hash-verified

139 * when unterminated.
140 */
141function commentOrStringEnd(s: string, i: number): number {
142 const c = s.charCodeAt(i);
143 if (c === CH_LBRACE) {
144 const e = s.indexOf('}', i + 1);
145 return e < 0 ? s.length : e + 1;
146 }
147 if (c === CH_LPAREN && s.charCodeAt(i + 1) === CH_STAR) {
148 const e = s.indexOf('*)', i + 2);
149 return e < 0 ? s.length : e + 2;
150 }
151 if (c === CH_SLASH && s.charCodeAt(i + 1) === CH_SLASH) {
152 const e = s.indexOf('\n', i + 2);
153 return e < 0 ? s.length : e;
154 }
155 if (c === CH_QUOTE) {
156 let j = i + 1;
157 while (j < s.length) {
158 const d = s.charCodeAt(j);
159 if (d === CH_QUOTE) {
160 if (s.charCodeAt(j + 1) !== CH_QUOTE) return j + 1;
161 j += 2;
162 continue;
163 }
164 if (d === CH_LF) return j;
165 j++;
166 }
167 return j;
168 }
169 return -1;
170}
171
172/** Whether a comment starts at `i`. */
173function isCommentStart(s: string, i: number): boolean {

Callers 13

skipTriviaFunction · 0.85
semicolonEndFunction · 0.85
attributeEndFunction · 0.85
scanParameterListFunction · 0.85
scanForInVariableFunction · 0.85
conditionalGroupsFunction · 0.85
holdsBodyFunction · 0.85
holdsBlockFunction · 0.85
skipTriviaToGroupFunction · 0.85
openBlocksFunction · 0.85
statementsShapeFunction · 0.85
recordEndFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected