Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit fd960f9

Browse files
committedAug 30, 2022
Fix CR being rejected when used as whitespace
Missed this comment from ziglang/zig-spec#83: > CR used as whitespace, whether directly preceding NL or stray, is still unambiguously whitespace. It is accepted by the grammar and replaced by the canonical whitespace by zig fmt.
1 parent 22be9b8 commit fd960f9

File tree

1 file changed

+1
-13
lines changed

1 file changed

+1
-13
lines changed
 

Diff for: ‎lib/std/zig/tokenizer.zig

+1-13
Original file line numberDiff line numberDiff line change
@@ -469,7 +469,7 @@ pub const Tokenizer = struct {
469469
switch (state) {
470470
.start => switch (c) {
471471
0 => break,
472-
' ', '\n', '\t' => {
472+
' ', '\n', '\t', '\r' => {
473473
result.loc.start = self.index + 1;
474474
},
475475
'"' => {
@@ -592,18 +592,6 @@ pub const Tokenizer = struct {
592592
state = .int_literal_dec;
593593
result.tag = .integer_literal;
594594
},
595-
'\r' => {
596-
// Carriage returns are *only* allowed just before a linefeed as part of a CRLF pair, otherwise
597-
// they constitute an illegal byte!
598-
if (self.index + 1 < self.buffer.len and self.buffer[self.index + 1] == '\n') {
599-
result.loc.start = self.index + 1;
600-
} else {
601-
result.tag = .invalid;
602-
result.loc.end = self.index;
603-
self.index += 1;
604-
return result;
605-
}
606-
},
607595
else => {
608596
result.tag = .invalid;
609597
result.loc.end = self.index;

0 commit comments

Comments
 (0)
Please sign in to comment.