2025-02-06 17:55:54 +00:00
|
|
|
use super::interface::Tokenizer;
|
|
|
|
use crate::token::Token;
|
|
|
|
use std::{iter::Peekable, str::CharIndices};
|
|
|
|
|
2025-02-07 08:21:23 +00:00
|
|
|
/// Consume newlines. Do not yield a token but increase the current line.
|
2025-02-06 17:55:54 +00:00
|
|
|
pub struct Newline;
|
|
|
|
impl Tokenizer for Newline {
|
|
|
|
fn run(
|
|
|
|
&self,
|
|
|
|
c: (usize, char),
|
|
|
|
_chars: &mut Peekable<CharIndices<'_>>,
|
|
|
|
_source: &str,
|
|
|
|
_line: usize,
|
|
|
|
) -> Option<(usize, Option<Token>)> {
|
|
|
|
match c.1 {
|
|
|
|
'\n' => Some((1, None)),
|
|
|
|
_ => None,
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|