Read a single-line comment token.
(&mut self)
| 465 | |
| 466 | /// Read a single-line comment token. |
| 467 | fn read_comment(&mut self) -> Token<'a> { |
| 468 | let start = self.position; |
| 469 | self.advance(); // first / |
| 470 | self.advance(); // second / |
| 471 | |
| 472 | // Read until newline |
| 473 | while let Some(b) = self.peek() { |
| 474 | if Self::is_newline(b) { |
| 475 | break; |
| 476 | } |
| 477 | self.advance(); |
| 478 | } |
| 479 | |
| 480 | Token::new( |
| 481 | &self.content[start..self.position], |
| 482 | TokenKind::Comment, |
| 483 | start, |
| 484 | ) |
| 485 | } |
| 486 | |
| 487 | /// Read a punctuation token. |
| 488 | fn read_punctuation(&mut self) -> Token<'a> { |