MCPcopy
hub / github.com/jquery/esprima / scanRegExpFlags

Method scanRegExpFlags

src/scanner.ts:1185–1223  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

1183 }
1184
1185 private scanRegExpFlags(): string {
1186 let str = '';
1187 let flags = '';
1188 while (!this.eof()) {
1189 let ch = this.source[this.index];
1190 if (!Character.isIdentifierPart(ch.charCodeAt(0))) {
1191 break;
1192 }
1193
1194 ++this.index;
1195 if (ch === '\\' && !this.eof()) {
1196 ch = this.source[this.index];
1197 if (ch === 'u') {
1198 ++this.index;
1199 let restore = this.index;
1200 const char = this.scanHexEscape('u');
1201 if (char !== null) {
1202 flags += char;
1203 for (str += '\\u'; restore < this.index; ++restore) {
1204 str += this.source[restore];
1205 }
1206 } else {
1207 this.index = restore;
1208 flags += 'u';
1209 str += '\\u';
1210 }
1211 this.tolerateUnexpectedToken();
1212 } else {
1213 str += '\\';
1214 this.tolerateUnexpectedToken();
1215 }
1216 } else {
1217 flags += ch;
1218 str += ch;
1219 }
1220 }
1221
1222 return flags;
1223 }
1224
1225 public scanRegExp(): RawToken {
1226 const start = this.index;

Callers 1

scanRegExpMethod · 0.95

Calls 3

eofMethod · 0.95
scanHexEscapeMethod · 0.95

Tested by

no test coverage detected