aboutsummaryrefslogtreecommitdiff
path: root/src/tokenizer/mod.rs
diff options
context:
space:
mode:
authorMartin Fischer <martin@push-f.com>2021-11-30 10:56:59 +0100
committerMartin Fischer <martin@push-f.com>2021-11-30 11:22:35 +0100
commit915530c02029f8bd4444930ed949e14f09afab03 (patch)
tree6f58b9728386dc5c1709137bc0a250640a7ce572 /src/tokenizer/mod.rs
parent414e5838618123cb00216a7426b898aab88ee45a (diff)
report spans for errors
Diffstat (limited to 'src/tokenizer/mod.rs')
-rw-r--r--src/tokenizer/mod.rs15
1 files changed, 11 insertions, 4 deletions
diff --git a/src/tokenizer/mod.rs b/src/tokenizer/mod.rs
index 6793eb2..1809275 100644
--- a/src/tokenizer/mod.rs
+++ b/src/tokenizer/mod.rs
@@ -538,7 +538,10 @@ impl<Sink: TokenSink> Tokenizer<Sink> {
};
if dup {
- self.emit_error(Error::DuplicateAttribute);
+ self.emit_error(Error::DuplicateAttribute {
+ #[cfg(feature = "spans")]
+ span: self.spans.current_attr_name.clone(),
+ });
self.current_attr_name.clear();
self.current_attr_value.clear();
} else {
@@ -598,7 +601,11 @@ impl<Sink: TokenSink> Tokenizer<Sink> {
}
fn emit_error(&mut self, error: Error) {
- self.process_token_and_continue(ParseError(error));
+ self.process_token_and_continue(ParseError {
+ error,
+ #[cfg(feature = "spans")]
+ span: self.spans.current_pos - 1..self.spans.current_pos - 1,
+ });
}
}
//ยง END
@@ -2293,7 +2300,7 @@ mod test {
self.current_str.push('\0');
}
- token @ ParseError(_) => {
+ token @ ParseError { .. } => {
self.push(token, line_number);
}
@@ -2453,7 +2460,7 @@ mod test {
(3, CharacterTokens(c1)),
(
3,
- ParseError(Error::CharRef(CharRefError::InvalidNamedCharRef)),
+ ParseError{error: Error::CharRef(CharRefError::InvalidNamedCharRef), ..},
),
(4, CharacterTokens(c2)),
] if c1 == "&\n" && c2 == "&aamp;\n"