in src/scanner.ts [243:309]
public scanComments() {
let comments;
if (this.trackComment) {
comments = [];
}
let start = (this.index === 0);
while (!this.eof()) {
let ch = this.source.charCodeAt(this.index);
if (Character.isWhiteSpace(ch)) {
++this.index;
} else if (Character.isLineTerminator(ch)) {
++this.index;
if (ch === 0x0D && this.source.charCodeAt(this.index) === 0x0A) {
++this.index;
}
++this.lineNumber;
this.lineStart = this.index;
start = true;
} else if (ch === 0x2F) { // U+002F is '/'
ch = this.source.charCodeAt(this.index + 1);
if (ch === 0x2F) {
this.index += 2;
const comment = this.skipSingleLineComment(2);
if (this.trackComment) {
comments = comments.concat(comment);
}
start = true;
} else if (ch === 0x2A) { // U+002A is '*'
this.index += 2;
const comment = this.skipMultiLineComment();
if (this.trackComment) {
comments = comments.concat(comment);
}
} else {
break;
}
} else if (start && ch === 0x2D) { // U+002D is '-'
// U+003E is '>'
if ((this.source.charCodeAt(this.index + 1) === 0x2D) && (this.source.charCodeAt(this.index + 2) === 0x3E)) {
// '-->' is a single-line comment
this.index += 3;
const comment = this.skipSingleLineComment(3);
if (this.trackComment) {
comments = comments.concat(comment);
}
} else {
break;
}
} else if (ch === 0x3C && !this.isModule) { // U+003C is '<'
if (this.source.slice(this.index + 1, this.index + 4) === '!--') {
this.index += 4; // `<!--`
const comment = this.skipSingleLineComment(4);
if (this.trackComment) {
comments = comments.concat(comment);
}
} else {
break;
}
} else {
break;
}
}
return comments;
}