Skip to content
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

std.zig.tokenizer: simplify line-based tokens #21371

Merged
merged 1 commit into from
Sep 10, 2024

Conversation

ianprime0509
Copy link
Contributor

Closes #21358
Closes #21360

This commit modifies the multiline_string_literal_line, doc_comment, and container_doc_comment tokens to no longer include the line ending as part of the token. This makes it easier to handle line endings (which may be LF, CRLF, or in edge cases possibly nonexistent) consistently.

In the two issues linked above, Autodoc was already assuming this for doc comments, and yielding incorrect results when handling files with CRLF line endings (both in Markdown parsing and source rendering).

Applying the same simplification for multiline string literals also brings zig fmt into conformance with
ziglang/zig-spec#38 regarding formatting of multiline strings with CRLF line endings: the spec says that zig fmt should remove the CR from such line endings, but this was not previously the case.

Closes ziglang#21358
Closes ziglang#21360

This commit modifies the `multiline_string_literal_line`, `doc_comment`,
and `container_doc_comment` tokens to no longer include the line ending
as part of the token. This makes it easier to handle line endings (which
may be LF, CRLF, or in edge cases possibly nonexistent) consistently.

In the two issues linked above, Autodoc was already assuming this for
doc comments, and yielding incorrect results when handling files with
CRLF line endings (both in Markdown parsing and source rendering).

Applying the same simplification for multiline string literals also
brings `zig fmt` into conformance with
ziglang/zig-spec#38 regarding formatting of
multiline strings with CRLF line endings: the spec says that `zig fmt`
should remove the CR from such line endings, but this was not previously
the case.
@Vexu Vexu merged commit 9007534 into ziglang:master Sep 10, 2024
10 checks passed
@alexrp alexrp mentioned this pull request Sep 10, 2024
RetroDev256 added a commit to RetroDev256/zig that referenced this pull request Sep 10, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
2 participants