Parses a character class character, or, if the character is followed by a hyphen, parses a character class range. For single characters, rr->lo == rr->hi. Sets *s to span the remainder of the string. Sets *rp to the character.
| 1879 | // Sets *s to span the remainder of the string. |
| 1880 | // Sets *rp to the character. |
| 1881 | bool Regexp::ParseState::ParseCCRange(StringPiece* s, RuneRange* rr, |
| 1882 | const StringPiece& whole_class, |
| 1883 | RegexpStatus* status) { |
| 1884 | StringPiece os = *s; |
| 1885 | if (!ParseCCCharacter(s, &rr->lo, whole_class, status)) |
| 1886 | return false; |
| 1887 | // [a-] means (a|-), so check for final ]. |
| 1888 | if (s->size() >= 2 && (*s)[0] == '-' && (*s)[1] != ']') { |
| 1889 | s->remove_prefix(1); // '-' |
| 1890 | if (!ParseCCCharacter(s, &rr->hi, whole_class, status)) |
| 1891 | return false; |
| 1892 | if (rr->hi < rr->lo) { |
| 1893 | status->set_code(kRegexpBadCharRange); |
| 1894 | status->set_error_arg( |
| 1895 | StringPiece(os.data(), static_cast<size_t>(s->data() - os.data()))); |
| 1896 | return false; |
| 1897 | } |
| 1898 | } else { |
| 1899 | rr->hi = rr->lo; |
| 1900 | } |
| 1901 | return true; |
| 1902 | } |
| 1903 | |
| 1904 | // Parses a possibly-negated character class expression like [^abx-z[:digit:]]. |
| 1905 | // Sets *s to span the remainder of the string. |
nothing calls this directly
no test coverage detected