MCPcopy Create free account
hub / github.com/dchester/jsonpath / scanRegExpFlags

Function scanRegExpFlags

jsonpath.js:1100–1143  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

1098 }
1099
1100 function scanRegExpFlags() {
1101 var ch, str, flags, restore;
1102
1103 str = '';
1104 flags = '';
1105 while (index < length) {
1106 ch = source[index];
1107 if (!isIdentifierPart(ch.charCodeAt(0))) {
1108 break;
1109 }
1110
1111 ++index;
1112 if (ch === '\\' && index < length) {
1113 ch = source[index];
1114 if (ch === 'u') {
1115 ++index;
1116 restore = index;
1117 ch = scanHexEscape('u');
1118 if (ch) {
1119 flags += ch;
1120 for (str += '\\u'; restore < index; ++restore) {
1121 str += source[restore];
1122 }
1123 } else {
1124 index = restore;
1125 flags += 'u';
1126 str += '\\u';
1127 }
1128 throwErrorTolerant({}, Messages.UnexpectedToken, 'ILLEGAL');
1129 } else {
1130 str += '\\';
1131 throwErrorTolerant({}, Messages.UnexpectedToken, 'ILLEGAL');
1132 }
1133 } else {
1134 flags += ch;
1135 str += ch;
1136 }
1137 }
1138
1139 return {
1140 value: flags,
1141 literal: str
1142 };
1143 }
1144
1145 function scanRegExp() {
1146 var start, body, flags, pattern, value;

Callers 1

scanRegExpFunction · 0.85

Calls 3

isIdentifierPartFunction · 0.85
scanHexEscapeFunction · 0.85
throwErrorTolerantFunction · 0.85

Tested by

no test coverage detected