| @@ 218-261 (lines=44) @@ | ||
| 215 | } |
|
| 216 | ||
| 217 | // fallthrough intentional |
|
| 218 | case self::ACTION_DELETE_A_B: // 3 |
|
| 219 | $this->b = $this->next(); |
|
| 220 | if ($this->b === '/' && $this->isRegexpLiteral()) {
|
|
| 221 | $this->output .= $this->a . $this->b; |
|
| 222 | $pattern = '/'; // keep entire pattern in case we need to report it in the exception |
|
| 223 | for(;;) {
|
|
| 224 | $this->a = $this->get(); |
|
| 225 | $pattern .= $this->a; |
|
| 226 | if ($this->a === '[') {
|
|
| 227 | for(;;) {
|
|
| 228 | $this->output .= $this->a; |
|
| 229 | $this->a = $this->get(); |
|
| 230 | $pattern .= $this->a; |
|
| 231 | if ($this->a === ']') {
|
|
| 232 | break; |
|
| 233 | } |
|
| 234 | if ($this->a === '\\') {
|
|
| 235 | $this->output .= $this->a; |
|
| 236 | $this->a = $this->get(); |
|
| 237 | $pattern .= $this->a; |
|
| 238 | } |
|
| 239 | if ($this->isEOF($this->a)) {
|
|
| 240 | throw new JSMin_UnterminatedRegExpException( |
|
| 241 | "JSMin: Unterminated set in RegExp at byte " |
|
| 242 | . $this->inputIndex .": {$pattern}");
|
|
| 243 | } |
|
| 244 | } |
|
| 245 | } |
|
| 246 | ||
| 247 | if ($this->a === '/') { // end pattern
|
|
| 248 | break; // while (true) |
|
| 249 | } elseif ($this->a === '\\') {
|
|
| 250 | $this->output .= $this->a; |
|
| 251 | $this->a = $this->get(); |
|
| 252 | $pattern .= $this->a; |
|
| 253 | } elseif ($this->isEOF($this->a)) {
|
|
| 254 | throw new JSMin_UnterminatedRegExpException( |
|
| 255 | "JSMin: Unterminated RegExp at byte {$this->inputIndex}: {$pattern}");
|
|
| 256 | } |
|
| 257 | $this->output .= $this->a; |
|
| 258 | $this->lastByteOut = $this->a; |
|
| 259 | } |
|
| 260 | $this->b = $this->next(); |
|
| 261 | } |
|
| 262 | // end case ACTION_DELETE_A_B |
|
| 263 | } |
|
| 264 | } |
|
| @@ 225-269 (lines=45) @@ | ||
| 222 | } |
|
| 223 | ||
| 224 | // fallthrough intentional |
|
| 225 | case self::ACTION_DELETE_A_B: // 3 |
|
| 226 | $this->b = $this->next(); |
|
| 227 | if ($this->b === '/' && $this->isRegexpLiteral()) { |
|
| 228 | $this->output .= $this->a . $this->b; |
|
| 229 | $pattern = '/'; // keep entire pattern in case we need to report it in the exception |
|
| 230 | for(;;) { |
|
| 231 | $this->a = $this->get(); |
|
| 232 | $pattern .= $this->a; |
|
| 233 | if ($this->a === '[') { |
|
| 234 | for(;;) { |
|
| 235 | $this->output .= $this->a; |
|
| 236 | $this->a = $this->get(); |
|
| 237 | $pattern .= $this->a; |
|
| 238 | if ($this->a === ']') { |
|
| 239 | break; |
|
| 240 | } |
|
| 241 | if ($this->a === '\\') { |
|
| 242 | $this->output .= $this->a; |
|
| 243 | $this->a = $this->get(); |
|
| 244 | $pattern .= $this->a; |
|
| 245 | } |
|
| 246 | if ($this->isEOF($this->a)) { |
|
| 247 | throw new JSMin_UnterminatedRegExpException( |
|
| 248 | "JSMin: Unterminated set in RegExp at byte " |
|
| 249 | . $this->inputIndex .": {$pattern}"); |
|
| 250 | } |
|
| 251 | } |
|
| 252 | } |
|
| 253 | ||
| 254 | if ($this->a === '/') { // end pattern |
|
| 255 | break; // while (true) |
|
| 256 | } elseif ($this->a === '\\') { |
|
| 257 | $this->output .= $this->a; |
|
| 258 | $this->a = $this->get(); |
|
| 259 | $pattern .= $this->a; |
|
| 260 | } elseif ($this->isEOF($this->a)) { |
|
| 261 | $byte = $this->inputIndex - 1; |
|
| 262 | throw new JSMin_UnterminatedRegExpException( |
|
| 263 | "JSMin: Unterminated RegExp at byte {$byte}: {$pattern}"); |
|
| 264 | } |
|
| 265 | $this->output .= $this->a; |
|
| 266 | $this->lastByteOut = $this->a; |
|
| 267 | } |
|
| 268 | $this->b = $this->next(); |
|
| 269 | } |
|
| 270 | // end case ACTION_DELETE_A_B |
|
| 271 | } |
|
| 272 | } |
|