(s: &'a str)
| 141 | |
| 142 | impl<'a> Lexer<'a> { |
| 143 | pub fn new(s: &'a str) -> Self { |
| 144 | let mut lex = Self { |
| 145 | source: s, |
| 146 | chars: s.char_indices(), |
| 147 | lookahead: None, |
| 148 | pos: 0, |
| 149 | line_number: 1, |
| 150 | }; |
| 151 | // Advance to the first char. |
| 152 | lex.next_ch(); |
| 153 | lex |
| 154 | } |
| 155 | |
| 156 | // Advance to the next character. |
| 157 | // Return the next lookahead character, or None when the end is encountered. |