()
| 3774 | } |
| 3775 | |
| 3776 | function scanRegExpBody() { |
| 3777 | var ch, str, classMarker, terminated, body; |
| 3778 | |
| 3779 | ch = source[index]; |
| 3780 | assert(ch === '/', 'Regular expression literal must start with a slash'); |
| 3781 | str = source[index++]; |
| 3782 | |
| 3783 | classMarker = false; |
| 3784 | terminated = false; |
| 3785 | while (index < length) { |
| 3786 | ch = source[index++]; |
| 3787 | str += ch; |
| 3788 | if (ch === '\\') { |
| 3789 | ch = source[index++]; |
| 3790 | // ECMA-262 7.8.5 |
| 3791 | if (isLineTerminator(ch.charCodeAt(0))) { |
| 3792 | throwError({}, Messages.UnterminatedRegExp); |
| 3793 | } |
| 3794 | str += ch; |
| 3795 | } else if (isLineTerminator(ch.charCodeAt(0))) { |
| 3796 | throwError({}, Messages.UnterminatedRegExp); |
| 3797 | } else if (classMarker) { |
| 3798 | if (ch === ']') { |
| 3799 | classMarker = false; |
| 3800 | } |
| 3801 | } else { |
| 3802 | if (ch === '/') { |
| 3803 | terminated = true; |
| 3804 | break; |
| 3805 | } else if (ch === '[') { |
| 3806 | classMarker = true; |
| 3807 | } |
| 3808 | } |
| 3809 | } |
| 3810 | |
| 3811 | if (!terminated) { |
| 3812 | throwError({}, Messages.UnterminatedRegExp); |
| 3813 | } |
| 3814 | |
| 3815 | // Exclude leading and trailing slash. |
| 3816 | body = str.substr(1, str.length - 2); |
| 3817 | return { |
| 3818 | value: body, |
| 3819 | literal: str |
| 3820 | }; |
| 3821 | } |
| 3822 | |
| 3823 | function scanRegExpFlags() { |
| 3824 | var ch, str, flags, restore; |
no test coverage detected