Creates a checkpoint to which the lexer can later return to using [`Self::rewind`].
(&self)
| 1459 | |
| 1460 | /// Creates a checkpoint to which the lexer can later return to using [`Self::rewind`]. |
| 1461 | pub(crate) fn checkpoint(&self) -> LexerCheckpoint { |
| 1462 | LexerCheckpoint { |
| 1463 | value: self.current_value.clone(), |
| 1464 | current_kind: self.current_kind, |
| 1465 | current_range: self.current_range, |
| 1466 | current_flags: self.current_flags, |
| 1467 | cursor_offset: self.offset(), |
| 1468 | state: self.state, |
| 1469 | nesting: self.nesting, |
| 1470 | indentations_checkpoint: self.indentations.checkpoint(), |
| 1471 | pending_indentation: self.pending_indentation, |
| 1472 | fstrings_checkpoint: self.fstrings.checkpoint(), |
| 1473 | errors_position: self.errors.len(), |
| 1474 | } |
| 1475 | } |
| 1476 | |
| 1477 | /// Restore the lexer to the given checkpoint. |
| 1478 | pub(crate) fn rewind(&mut self, checkpoint: LexerCheckpoint) { |