aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorMartin Fischer <martin@push-f.com>2023-08-28 13:04:57 +0200
committerMartin Fischer <martin@push-f.com>2023-09-03 23:00:05 +0200
commit896ad0d57d003d59585106c33f30fdfd29ebdb17 (patch)
treef7a766dcc36db285cbd3bc353e6cb5e00ffe5afd /src
parent1818a84b01b10d43429e352e8a4fb85c03855bec (diff)
refactor: simplify Iterator impl for Tokenizer
Diffstat (limited to 'src')
-rw-r--r--src/tokenizer.rs22
1 files changed, 12 insertions, 10 deletions
diff --git a/src/tokenizer.rs b/src/tokenizer.rs
index 2580144..96d1c34 100644
--- a/src/tokenizer.rs
+++ b/src/tokenizer.rs
@@ -313,18 +313,20 @@ where
loop {
if let Some(token) = self.emitter.pop_token() {
return Some(Ok(token));
- } else if !self.eof {
- match machine::consume(self) {
- Ok(ControlToken::Continue) => (),
- Ok(ControlToken::Eof) => {
- self.eof = true;
- self.emitter.emit_eof();
- }
- Err(e) => return Some(Err(e)),
- }
- } else {
+ }
+
+ if self.eof {
return None;
}
+
+ match machine::consume(self) {
+ Err(e) => return Some(Err(e)),
+ Ok(ControlToken::Continue) => (),
+ Ok(ControlToken::Eof) => {
+ self.eof = true;
+ self.emitter.emit_eof();
+ }
+ }
}
}
}