Expects the peeked token to be `t` and consumes it. Otherwise, leaves the token in the stream and fails with error `err`, pointing at `pos` as the original location of the problem.
(
&mut self,
t: Token,
pos: LineCol,
err: E,
)
| 286 | /// stream and fails with error `err`, pointing at `pos` as the original location of the |
| 287 | /// problem. |
| 288 | fn expect_and_consume_with_pos<E: Into<String>>( |
| 289 | &mut self, |
| 290 | t: Token, |
| 291 | pos: LineCol, |
| 292 | err: E, |
| 293 | ) -> Result<()> { |
| 294 | let peeked = self.lexer.peek()?; |
| 295 | if peeked.token != t { |
| 296 | return Err(Error::Bad(pos, err.into())); |
| 297 | } |
| 298 | self.lexer.consume_peeked(); |
| 299 | Ok(()) |
| 300 | } |
| 301 | |
| 302 | /// Reads statements until the `delim` keyword is found. The delimiter is not consumed. |
| 303 | fn parse_until(&mut self, delim: Token) -> Result<Vec<Statement>> { |
no test coverage detected