Parse a decimal number into a u32 while trimming leading and trailing whitespace. This expects the parser to be positioned at the first position where a decimal digit could occur. This will advance the parser to the byte immediately following the last contiguous decimal digit. If no decimal digit could be found or if there was a problem parsing the complete set of digits into a u32, then an erro
(&self)
| 1707 | /// If no decimal digit could be found or if there was a problem parsing |
| 1708 | /// the complete set of digits into a u32, then an error is returned. |
| 1709 | fn parse_decimal(&self) -> Result<u32> { |
| 1710 | let mut scratch = self.parser().scratch.borrow_mut(); |
| 1711 | scratch.clear(); |
| 1712 | |
| 1713 | while !self.is_eof() && self.char().is_whitespace() { |
| 1714 | self.bump(); |
| 1715 | } |
| 1716 | let start = self.pos(); |
| 1717 | while !self.is_eof() && '0' <= self.char() && self.char() <= '9' { |
| 1718 | scratch.push(self.char()); |
| 1719 | self.bump_and_bump_space(); |
| 1720 | } |
| 1721 | let span = Span::new(start, self.pos()); |
| 1722 | while !self.is_eof() && self.char().is_whitespace() { |
| 1723 | self.bump_and_bump_space(); |
| 1724 | } |
| 1725 | let digits = scratch.as_str(); |
| 1726 | if digits.is_empty() { |
| 1727 | return Err(self.error(span, ast::ErrorKind::DecimalEmpty)); |
| 1728 | } |
| 1729 | match u32::from_str_radix(digits, 10).ok() { |
| 1730 | Some(n) => Ok(n), |
| 1731 | None => Err(self.error(span, ast::ErrorKind::DecimalInvalid)), |
| 1732 | } |
| 1733 | } |
| 1734 | |
| 1735 | /// Parse a standard character class consisting primarily of characters or |
| 1736 | /// character ranges, but can also contain nested character classes of |
no test coverage detected