()
| 1125 | } |
| 1126 | |
| 1127 | function scanRegExpBody() { |
| 1128 | var ch, str, classMarker, terminated, body; |
| 1129 | |
| 1130 | ch = source[index]; |
| 1131 | assert(ch === '/', 'Regular expression literal must start with a slash'); |
| 1132 | str = source[index++]; |
| 1133 | |
| 1134 | classMarker = false; |
| 1135 | terminated = false; |
| 1136 | while (index < length) { |
| 1137 | ch = source[index++]; |
| 1138 | str += ch; |
| 1139 | if (ch === '\\') { |
| 1140 | ch = source[index++]; |
| 1141 | // ECMA-262 7.8.5 |
| 1142 | if (isLineTerminator(ch.charCodeAt(0))) { |
| 1143 | throwUnexpectedToken(null, Messages.UnterminatedRegExp); |
| 1144 | } |
| 1145 | str += ch; |
| 1146 | } else if (isLineTerminator(ch.charCodeAt(0))) { |
| 1147 | throwUnexpectedToken(null, Messages.UnterminatedRegExp); |
| 1148 | } else if (classMarker) { |
| 1149 | if (ch === ']') { |
| 1150 | classMarker = false; |
| 1151 | } |
| 1152 | } else { |
| 1153 | if (ch === '/') { |
| 1154 | terminated = true; |
| 1155 | break; |
| 1156 | } else if (ch === '[') { |
| 1157 | classMarker = true; |
| 1158 | } |
| 1159 | } |
| 1160 | } |
| 1161 | |
| 1162 | if (!terminated) { |
| 1163 | throwUnexpectedToken(null, Messages.UnterminatedRegExp); |
| 1164 | } |
| 1165 | |
| 1166 | // Exclude leading and trailing slash. |
| 1167 | body = str.substr(1, str.length - 2); |
| 1168 | return { |
| 1169 | value: body, |
| 1170 | literal: str |
| 1171 | }; |
| 1172 | } |
| 1173 | |
| 1174 | function scanRegExpFlags() { |
| 1175 | var ch, str, flags, restore; |
no test coverage detected