Advance to the next character. Return the next lookahead character, or None when the end is encountered. Always update cur_ch to reflect
(&mut self)
| 157 | // Return the next lookahead character, or None when the end is encountered. |
| 158 | // Always update cur_ch to reflect |
| 159 | fn next_ch(&mut self) -> Option<char> { |
| 160 | if self.lookahead == Some('\n') { |
| 161 | self.line_number += 1; |
| 162 | } |
| 163 | match self.chars.next() { |
| 164 | Some((idx, ch)) => { |
| 165 | self.pos = idx; |
| 166 | self.lookahead = Some(ch); |
| 167 | } |
| 168 | None => { |
| 169 | self.pos = self.source.len(); |
| 170 | self.lookahead = None; |
| 171 | } |
| 172 | } |
| 173 | self.lookahead |
| 174 | } |
| 175 | |
| 176 | // Get the location corresponding to `lookahead`. |
| 177 | fn loc(&self) -> Location { |
no test coverage detected