in src/scanner.ts [1188:1226]
private scanRegExpFlags(): string {
let str = '';
let flags = '';
while (!this.eof()) {
let ch = this.source[this.index];
if (!Character.isIdentifierPart(ch.charCodeAt(0))) {
break;
}
++this.index;
if (ch === '\\' && !this.eof()) {
ch = this.source[this.index];
if (ch === 'u') {
++this.index;
let restore = this.index;
const char = this.scanHexEscape('u');
if (char !== null) {
flags += char;
for (str += '\\u'; restore < this.index; ++restore) {
str += this.source[restore];
}
} else {
this.index = restore;
flags += 'u';
str += '\\u';
}
this.tolerateUnexpectedToken();
} else {
str += '\\';
this.tolerateUnexpectedToken();
}
} else {
flags += ch;
str += ch;
}
}
return flags;
}