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

Function commentOrStringEnd

src/extraction/languages/pascal-preparse.ts:146–175  ·  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

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