Skip to content

Trigger errors without macros, remove unwrap_or_else! and go_match! #600

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 4 commits into from
Apr 14, 2025

Conversation

simonwuelker
Copy link
Contributor

@simonwuelker simonwuelker commented Apr 13, 2025

This change is the first step in gradually removing the go! macro that is currently used to implement the tokenizer-DSL.

When this macro was first introduced it might have made sense to have it - some quality-of-life rust syntax did not exist back then.

But I think it's not necessary anymore and I'm certain that it's possible to remove the DSL without compromising on performance or readability (like this).

Comment on lines +376 to +377
#[cfg(feature = "trace_tokenizer")]
trace!(" error");
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think the usefulness of the trace_tokenizer feature is a bit questionable, but I didn't want to touch it for now. This matches what the sh_trace! macro would log before.

@@ -1565,7 +1578,10 @@ impl<Sink: TokenSink> Tokenizer<Sink> {

states::MarkupDeclarationOpen => go!(self: error; to BogusComment),

states::CdataSection => go!(self: emit_temp; error_eof; to Data),
states::CdataSection => {
self.bad_eof_error();
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This reorders the eof and emit_tmp. Is that a problem?

Copy link
Contributor Author

@simonwuelker simonwuelker Apr 14, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Any user that relies on this ordering is doing silly things, but it is observable I think. Nice catch!

@simonwuelker simonwuelker enabled auto-merge April 14, 2025 01:33
@simonwuelker simonwuelker added this pull request to the merge queue Apr 14, 2025
Merged via the queue into servo:main with commit a1486b0 Apr 14, 2025
6 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants