Match and consume an optional offset32 immediate. Note that this will match an empty string as an empty offset, and that if an offset is present, it must contain a sign.
(&mut self)
| 811 | // Note that this will match an empty string as an empty offset, and that if an offset is |
| 812 | // present, it must contain a sign. |
| 813 | fn optional_offset32(&mut self) -> ParseResult<Offset32> { |
| 814 | if let Some(Token::Integer(text)) = self.token() { |
| 815 | if text.starts_with('+') || text.starts_with('-') { |
| 816 | self.consume(); |
| 817 | // Lexer just gives us raw text that looks like an integer. |
| 818 | // Parse it as an `Offset32` to check for overflow and other issues. |
| 819 | return text.parse().map_err(|e| self.error(e)); |
| 820 | } |
| 821 | } |
| 822 | // An offset32 operand can be absent. |
| 823 | Ok(Offset32::new(0)) |
| 824 | } |
| 825 | |
| 826 | // Match and consume an optional offset32 immediate. |
| 827 | // |