diff options
author | Martin Fischer <martin@push-f.com> | 2021-11-30 19:11:19 +0100 |
---|---|---|
committer | Martin Fischer <martin@push-f.com> | 2021-12-05 02:52:36 +0100 |
commit | f9639d724e1a6f1e8edaeafa78c2c3d8b43640a3 (patch) | |
tree | 643dfe2a34082edb6b7ca3bd293f59f343766e10 /src/tokenizer.rs | |
parent | 042409a2c40bb997739326928eab7d0430cec50b (diff) |
spans: add spans to Token::Error
Diffstat (limited to 'src/tokenizer.rs')
-rw-r--r-- | src/tokenizer.rs | 13 |
1 files changed, 9 insertions, 4 deletions
diff --git a/src/tokenizer.rs b/src/tokenizer.rs index efaa870..6e928e9 100644 --- a/src/tokenizer.rs +++ b/src/tokenizer.rs @@ -122,6 +122,12 @@ impl<R: Reader, E: Emitter<R>> Tokenizer<R, E> { self.state = state.into(); } + /// Just a helper method for the machine. + #[inline] + pub(crate) fn emit_error(&mut self, error: Error) { + self.emitter.emit_error(error, &self.reader); + } + /// Test-internal function to override internal state. /// /// Only available with the `integration-tests` feature which is not public API. @@ -139,17 +145,16 @@ impl<R: Reader, E: Emitter<R>> Tokenizer<R, E> { fn validate_char(&mut self, c: char) { match c as u32 { surrogate_pat!() => { - self.emitter.emit_error(Error::SurrogateInInputStream); + self.emit_error(Error::SurrogateInInputStream); } noncharacter_pat!() => { - self.emitter.emit_error(Error::NoncharacterInInputStream); + self.emit_error(Error::NoncharacterInInputStream); } // control without whitespace or nul x @ control_pat!() if !matches!(x, 0x0000 | 0x0009 | 0x000a | 0x000c | 0x000d | 0x0020) => { - self.emitter - .emit_error(Error::ControlCharacterInInputStream); + self.emit_error(Error::ControlCharacterInInputStream); } _ => (), } |