* 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)
| 139 | * when unterminated. |
| 140 | */ |
| 141 | function 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`. */ |
| 173 | function isCommentStart(s: string, i: number): boolean { |
no outgoing calls
no test coverage detected