diff options
author | Martin Fischer <martin@push-f.com> | 2023-08-13 21:40:46 +0200 |
---|---|---|
committer | Martin Fischer <martin@push-f.com> | 2023-08-19 06:41:55 +0200 |
commit | 0a02268b163db620c9e3d2b4f22da6d4bb67adf2 (patch) | |
tree | 5a65d1696995a68fdf3ed98ab8cb63cf6d5f3fff /src/machine.rs | |
parent | 69fdbee250ebfce135bff2671226097bc536d953 (diff) |
refactor: proxy essential Emitter methods through Tokenizer
Diffstat (limited to 'src/machine.rs')
-rw-r--r-- | src/machine.rs | 68 |
1 files changed, 34 insertions, 34 deletions
diff --git a/src/machine.rs b/src/machine.rs index aa07900..e6f439b 100644 --- a/src/machine.rs +++ b/src/machine.rs @@ -124,7 +124,7 @@ pub fn consume<R: Reader, E: Emitter<R>>( Ok(ControlToken::Continue) } Some(x) if x.is_ascii_alphabetic() => { - slf.emitter.init_start_tag(&slf.reader); + slf.init_start_tag(); slf.state = State::TagName; slf.unread_char(Some(x)); Ok(ControlToken::Continue) @@ -151,7 +151,7 @@ pub fn consume<R: Reader, E: Emitter<R>>( }, State::EndTagOpen => match slf.read_char()? { Some(x) if x.is_ascii_alphabetic() => { - slf.emitter.init_end_tag(&slf.reader); + slf.init_end_tag(); slf.state = State::TagName; slf.unread_char(Some(x)); Ok(ControlToken::Continue) @@ -185,16 +185,16 @@ pub fn consume<R: Reader, E: Emitter<R>>( } Some('>') => { slf.state = State::Data; - slf.emitter.emit_current_tag(); + slf.emit_current_tag(); Ok(ControlToken::Continue) } Some('\0') => { slf.emit_error(Error::UnexpectedNullCharacter); - slf.emitter.push_tag_name("\u{fffd}"); + slf.push_tag_name("\u{fffd}"); Ok(ControlToken::Continue) } Some(x) => { - slf.emitter.push_tag_name(ctostr!(x.to_ascii_lowercase())); + slf.push_tag_name(ctostr!(x.to_ascii_lowercase())); Ok(ControlToken::Continue) } None => { @@ -217,7 +217,7 @@ pub fn consume<R: Reader, E: Emitter<R>>( }, State::RcDataEndTagOpen => match slf.read_char()? { Some(x) if x.is_ascii_alphabetic() => { - slf.emitter.init_end_tag(&slf.reader); + slf.init_end_tag(); slf.state = State::RcDataEndTagName; slf.unread_char(Some(x)); Ok(ControlToken::Continue) @@ -230,21 +230,21 @@ pub fn consume<R: Reader, E: Emitter<R>>( } }, State::RcDataEndTagName => match slf.read_char()? { - Some(whitespace_pat!()) if slf.emitter.current_is_appropriate_end_tag_token() => { + Some(whitespace_pat!()) if slf.current_end_tag_is_appropriate() => { slf.state = State::BeforeAttributeName; Ok(ControlToken::Continue) } - Some('/') if slf.emitter.current_is_appropriate_end_tag_token() => { + Some('/') if slf.current_end_tag_is_appropriate() => { slf.state = State::SelfClosingStartTag; Ok(ControlToken::Continue) } - Some('>') if slf.emitter.current_is_appropriate_end_tag_token() => { + Some('>') if slf.current_end_tag_is_appropriate() => { slf.state = State::Data; - slf.emitter.emit_current_tag(); + slf.emit_current_tag(); Ok(ControlToken::Continue) } Some(x) if x.is_ascii_alphabetic() => { - slf.emitter.push_tag_name(ctostr!(x.to_ascii_lowercase())); + slf.push_tag_name(ctostr!(x.to_ascii_lowercase())); slf.temporary_buffer.push(x); Ok(ControlToken::Continue) } @@ -272,7 +272,7 @@ pub fn consume<R: Reader, E: Emitter<R>>( }, State::RawTextEndTagOpen => match slf.read_char()? { Some(x) if x.is_ascii_alphabetic() => { - slf.emitter.init_end_tag(&slf.reader); + slf.init_end_tag(); slf.state = State::RawTextEndTagName; slf.unread_char(Some(x)); Ok(ControlToken::Continue) @@ -285,21 +285,21 @@ pub fn consume<R: Reader, E: Emitter<R>>( } }, State::RawTextEndTagName => match slf.read_char()? { - Some(whitespace_pat!()) if slf.emitter.current_is_appropriate_end_tag_token() => { + Some(whitespace_pat!()) if slf.current_end_tag_is_appropriate() => { slf.state = State::BeforeAttributeName; Ok(ControlToken::Continue) } - Some('/') if slf.emitter.current_is_appropriate_end_tag_token() => { + Some('/') if slf.current_end_tag_is_appropriate() => { slf.state = State::SelfClosingStartTag; Ok(ControlToken::Continue) } - Some('>') if slf.emitter.current_is_appropriate_end_tag_token() => { + Some('>') if slf.current_end_tag_is_appropriate() => { slf.state = State::Data; - slf.emitter.emit_current_tag(); + slf.emit_current_tag(); Ok(ControlToken::Continue) } Some(x) if x.is_ascii_alphabetic() => { - slf.emitter.push_tag_name(ctostr!(x.to_ascii_lowercase())); + slf.push_tag_name(ctostr!(x.to_ascii_lowercase())); slf.temporary_buffer.push(x); Ok(ControlToken::Continue) } @@ -332,7 +332,7 @@ pub fn consume<R: Reader, E: Emitter<R>>( }, State::ScriptDataEndTagOpen => match slf.read_char()? { Some(x) if x.is_ascii_alphabetic() => { - slf.emitter.init_end_tag(&slf.reader); + slf.init_end_tag(); slf.state = State::ScriptDataEndTagName; slf.unread_char(Some(x)); Ok(ControlToken::Continue) @@ -345,21 +345,21 @@ pub fn consume<R: Reader, E: Emitter<R>>( } }, State::ScriptDataEndTagName => match slf.read_char()? { - Some(whitespace_pat!()) if slf.emitter.current_is_appropriate_end_tag_token() => { + Some(whitespace_pat!()) if slf.current_end_tag_is_appropriate() => { slf.state = State::BeforeAttributeName; Ok(ControlToken::Continue) } - Some('/') if slf.emitter.current_is_appropriate_end_tag_token() => { + Some('/') if slf.current_end_tag_is_appropriate() => { slf.state = State::SelfClosingStartTag; Ok(ControlToken::Continue) } - Some('>') if slf.emitter.current_is_appropriate_end_tag_token() => { + Some('>') if slf.current_end_tag_is_appropriate() => { slf.state = State::Data; - slf.emitter.emit_current_tag(); + slf.emit_current_tag(); Ok(ControlToken::Continue) } Some(x) if x.is_ascii_alphabetic() => { - slf.emitter.push_tag_name(ctostr!(x.to_ascii_lowercase())); + slf.push_tag_name(ctostr!(x.to_ascii_lowercase())); slf.temporary_buffer.push(x.to_ascii_lowercase()); Ok(ControlToken::Continue) } @@ -497,7 +497,7 @@ pub fn consume<R: Reader, E: Emitter<R>>( }, State::ScriptDataEscapedEndTagOpen => match slf.read_char()? { Some(x) if x.is_ascii_alphabetic() => { - slf.emitter.init_end_tag(&slf.reader); + slf.init_end_tag(); slf.state = State::ScriptDataEscapedEndTagName; slf.unread_char(Some(x)); Ok(ControlToken::Continue) @@ -510,21 +510,21 @@ pub fn consume<R: Reader, E: Emitter<R>>( } }, State::ScriptDataEscapedEndTagName => match slf.read_char()? { - Some(whitespace_pat!()) if slf.emitter.current_is_appropriate_end_tag_token() => { + Some(whitespace_pat!()) if slf.current_end_tag_is_appropriate() => { slf.state = State::BeforeAttributeName; Ok(ControlToken::Continue) } - Some('/') if slf.emitter.current_is_appropriate_end_tag_token() => { + Some('/') if slf.current_end_tag_is_appropriate() => { slf.state = State::SelfClosingStartTag; Ok(ControlToken::Continue) } - Some('>') if slf.emitter.current_is_appropriate_end_tag_token() => { + Some('>') if slf.current_end_tag_is_appropriate() => { slf.state = State::Data; - slf.emitter.emit_current_tag(); + slf.emit_current_tag(); Ok(ControlToken::Continue) } Some(x) if x.is_ascii_alphabetic() => { - slf.emitter.push_tag_name(ctostr!(x.to_ascii_lowercase())); + slf.push_tag_name(ctostr!(x.to_ascii_lowercase())); slf.temporary_buffer.push(x); Ok(ControlToken::Continue) } @@ -735,7 +735,7 @@ pub fn consume<R: Reader, E: Emitter<R>>( } Some('>') => { slf.state = State::Data; - slf.emitter.emit_current_tag(); + slf.emit_current_tag(); Ok(ControlToken::Continue) } None => { @@ -764,7 +764,7 @@ pub fn consume<R: Reader, E: Emitter<R>>( Some('>') => { slf.emit_error(Error::MissingAttributeValue); slf.state = State::Data; - slf.emitter.emit_current_tag(); + slf.emit_current_tag(); Ok(ControlToken::Continue) } c => { @@ -834,7 +834,7 @@ pub fn consume<R: Reader, E: Emitter<R>>( } Some('>') => { slf.state = State::Data; - slf.emitter.emit_current_tag(); + slf.emit_current_tag(); Ok(ControlToken::Continue) } Some('\0') => { @@ -867,7 +867,7 @@ pub fn consume<R: Reader, E: Emitter<R>>( } Some('>') => { slf.state = State::Data; - slf.emitter.emit_current_tag(); + slf.emit_current_tag(); Ok(ControlToken::Continue) } None => { @@ -885,7 +885,7 @@ pub fn consume<R: Reader, E: Emitter<R>>( Some('>') => { slf.emitter.set_self_closing(&slf.reader); slf.state = State::Data; - slf.emitter.emit_current_tag(); + slf.emit_current_tag(); Ok(ControlToken::Continue) } None => { |