Skip to content

parser: simplify {# comment #} parsing#488

Merged
Kijewski merged 1 commit intoaskama-rs:masterfrom
Kijewski:pr-no-memchr
Jun 16, 2025
Merged

parser: simplify {# comment #} parsing#488
Kijewski merged 1 commit intoaskama-rs:masterfrom
Kijewski:pr-no-memchr

Conversation

@Kijewski
Copy link
Copy Markdown
Member

winnow's take_until with feature simd enabled is implemented like our "optimized" skip_till. There is no need to reinvent the wheel.

I intend to remove our home-grown skip_till / memchr_splitter.rs in subsequent PRs.

Comment on lines +66 to +91
--> <source attribute>:1:0
"{# comment"
--> tests/ui/unclosed-nodes.rs:36:21
|
36 | #[template(source = "{# comment", ext = "txt")]
| ^^^^^^^^^^^^

error: unclosed comment, missing "#}"
--> <source attribute>:1:2
" comment "
--> <source attribute>:1:0
"{# comment "
--> tests/ui/unclosed-nodes.rs:40:21
|
40 | #[template(source = "{# comment ", ext = "txt")]
| ^^^^^^^^^^^^^

error: unclosed comment, missing "#}"
--> <source attribute>:1:2
" comment -"
--> <source attribute>:1:0
"{# comment -"
--> tests/ui/unclosed-nodes.rs:44:21
|
44 | #[template(source = "{# comment -", ext = "txt")]
| ^^^^^^^^^^^^^^

error: unclosed comment, missing "#}"
--> <source attribute>:1:2
" comment -#"
--> <source attribute>:1:0
"{# comment -#"
Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

I think the span is more correct this way.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Indeed, at least if it's a big file it'll not take the whole remaining content. :)

`winnow`'s `take_until` with feature `simd` enabled is implemented like
our "optimized" `skip_till`. There is no need to reinvent the wheel.
@GuillaumeGomez
Copy link
Copy Markdown
Collaborator

Nice cleanup, thanks!

@Kijewski Kijewski merged commit b6acf7b into askama-rs:master Jun 16, 2025
42 checks passed
@Kijewski Kijewski deleted the pr-no-memchr branch June 16, 2025 21:50
@Kijewski Kijewski mentioned this pull request Jun 16, 2025
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