MCPcopy
hub / github.com/BloombergGraphics/whatiscode / scanRegExpFlags

Function scanRegExpFlags

scripts/libs/esprima.js:1174–1217  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

1172 }
1173
1174 function scanRegExpFlags() {
1175 var ch, str, flags, restore;
1176
1177 str = '';
1178 flags = '';
1179 while (index < length) {
1180 ch = source[index];
1181 if (!isIdentifierPart(ch.charCodeAt(0))) {
1182 break;
1183 }
1184
1185 ++index;
1186 if (ch === '\\' && index < length) {
1187 ch = source[index];
1188 if (ch === 'u') {
1189 ++index;
1190 restore = index;
1191 ch = scanHexEscape('u');
1192 if (ch) {
1193 flags += ch;
1194 for (str += '\\u'; restore < index; ++restore) {
1195 str += source[restore];
1196 }
1197 } else {
1198 index = restore;
1199 flags += 'u';
1200 str += '\\u';
1201 }
1202 tolerateUnexpectedToken();
1203 } else {
1204 str += '\\';
1205 tolerateUnexpectedToken();
1206 }
1207 } else {
1208 flags += ch;
1209 str += ch;
1210 }
1211 }
1212
1213 return {
1214 value: flags,
1215 literal: str
1216 };
1217 }
1218
1219 function scanRegExp() {
1220 scanning = true;

Callers 1

scanRegExpFunction · 0.85

Calls 3

isIdentifierPartFunction · 0.85
scanHexEscapeFunction · 0.85
tolerateUnexpectedTokenFunction · 0.85

Tested by

no test coverage detected