aboutsummaryrefslogtreecommitdiff
path: root/src/basic_emitter.rs
diff options
context:
space:
mode:
Diffstat (limited to 'src/basic_emitter.rs')
-rw-r--r--src/basic_emitter.rs126
1 files changed, 126 insertions, 0 deletions
diff --git a/src/basic_emitter.rs b/src/basic_emitter.rs
new file mode 100644
index 0000000..046b645
--- /dev/null
+++ b/src/basic_emitter.rs
@@ -0,0 +1,126 @@
+use std::collections::VecDeque;
+use std::ops::Range;
+
+use crate::offset::Offset;
+use crate::Emitter;
+use crate::Error;
+use crate::Token;
+
+/// An [`Emitter`] implementation that yields [`Token`].
+pub struct BasicEmitter<O> {
+ errors: VecDeque<(Error, Range<O>)>,
+}
+
+impl<O: Default> Default for BasicEmitter<O> {
+ fn default() -> Self {
+ BasicEmitter {
+ errors: VecDeque::new(),
+ }
+ }
+}
+
+impl<O> BasicEmitter<O> {
+ /// Removes all encountered tokenizer errors and returns them as an iterator.
+ pub fn drain_errors(&mut self) -> impl Iterator<Item = (Error, Range<O>)> + '_ {
+ self.errors.drain(0..)
+ }
+}
+
+impl<O> Iterator for BasicEmitter<O> {
+ type Item = Token<O>;
+
+ fn next(&mut self) -> Option<Self::Item> {
+ todo!()
+ }
+}
+
+#[allow(unused_variables)]
+impl<O: Offset> Emitter<O> for BasicEmitter<O> {
+ fn report_error(&mut self, error: Error, span: Range<O>) {
+ todo!()
+ }
+
+ fn emit_char(&mut self, c: char) {
+ todo!()
+ }
+
+ fn emit_eof(&mut self) {
+ todo!()
+ }
+
+ fn init_start_tag(&mut self, tag_offset: O, name_offset: O) {
+ todo!()
+ }
+
+ fn init_end_tag(&mut self, tag_offset: O, name_offset: O) {
+ todo!()
+ }
+
+ fn push_tag_name(&mut self, s: &str) {
+ todo!()
+ }
+
+ fn init_attribute_name(&mut self, offset: O) {
+ todo!()
+ }
+
+ fn push_attribute_name(&mut self, s: &str) {
+ todo!()
+ }
+
+ fn push_attribute_value(&mut self, s: &str) {
+ todo!()
+ }
+
+ fn set_self_closing(&mut self, slash_span: Range<O>) {
+ todo!()
+ }
+
+ fn emit_current_tag(&mut self, offset: O) {
+ todo!()
+ }
+
+ fn init_comment(&mut self, data_start_offset: O) {
+ todo!()
+ }
+
+ fn push_comment(&mut self, s: &str) {
+ todo!()
+ }
+
+ fn emit_current_comment(&mut self, data_end_offset: O) {
+ todo!()
+ }
+
+ fn init_doctype(&mut self, offset: O) {
+ todo!()
+ }
+
+ fn push_doctype_name(&mut self, s: &str) {
+ todo!()
+ }
+
+ fn init_doctype_public_id(&mut self, offset: O) {
+ todo!()
+ }
+
+ fn push_doctype_public_id(&mut self, s: &str) {
+ todo!()
+ }
+
+ fn init_doctype_system_id(&mut self, offset: O) {
+ todo!()
+ }
+
+ fn push_doctype_system_id(&mut self, s: &str) {
+ todo!()
+ }
+
+ fn set_force_quirks(&mut self) {
+ todo!()
+ }
+
+ fn emit_current_doctype(&mut self, offset: O) {
+ todo!()
+ }
+}