The end of the preprocessor line that starts at `i`, through `\` continuations and comments.
(source: string, i: number)
| 181 | |
| 182 | /** The end of the preprocessor line that starts at `i`, through `\` continuations and comments. */ |
| 183 | function directiveEnd(source: string, i: number): number { |
| 184 | const n = source.length; |
| 185 | let j = i + 1; |
| 186 | while (j < n) { |
| 187 | const d = source.charCodeAt(j); |
| 188 | if (d === NEWLINE) { |
| 189 | let k = j - 1; |
| 190 | if (source.charCodeAt(k) === 13) k--; |
| 191 | if (source.charCodeAt(k) !== 92) break; |
| 192 | j++; |
| 193 | } else if (d === SLASH && source.charCodeAt(j + 1) === SLASH) { |
| 194 | j = lineCommentEnd(source, j + 2); |
| 195 | } else if (d === SLASH && source.charCodeAt(j + 1) === STAR) { |
| 196 | const end = source.indexOf('*/', j + 2); |
| 197 | j = end < 0 ? n : end + 2; |
| 198 | } else if (d === QUOTE) { |
| 199 | j = quotedEnd(source, j); |
| 200 | } else { |
| 201 | j++; |
| 202 | } |
| 203 | } |
| 204 | return j; |
| 205 | } |
| 206 | |
| 207 | /** The name of the directive whose `#` is at `i` (`if`, `import`, `endif`). */ |
| 208 | function directiveName(source: string, i: number): string { |
no test coverage detected