| ... | @@ -1,5 +1,4 @@ | ... | @@ -1,5 +1,4 @@ |
| 1 | const std = @import("../std.zig"); | 1 | const std = @import("../std.zig"); |
| 2 | const mem = std.mem; | | |
| 3 | | 2 | |
| 4 | pub const Token = struct { | 3 | pub const Token = struct { |
| 5 | tag: Tag, | 4 | tag: Tag, |
| ... | @@ -350,7 +349,7 @@ pub const Tokenizer = struct { | ... | @@ -350,7 +349,7 @@ pub const Tokenizer = struct { |
| 350 | | 349 | |
| 351 | pub fn init(buffer: [:0]const u8) Tokenizer { | 350 | pub fn init(buffer: [:0]const u8) Tokenizer { |
| 352 | // Skip the UTF-8 BOM if present | 351 | // Skip the UTF-8 BOM if present |
| 353 | const src_start = if (mem.startsWith(u8, buffer, "\xEF\xBB\xBF")) 3 else @as(usize, 0); | 352 | const src_start: usize = if (std.mem.startsWith(u8, buffer, "\xEF\xBB\xBF")) 3 else 0; |
| 354 | return Tokenizer{ | 353 | return Tokenizer{ |
| 355 | .buffer = buffer, | 354 | .buffer = buffer, |
| 356 | .index = src_start, | 355 | .index = src_start, |
| ... | @@ -1433,8 +1432,8 @@ pub const Tokenizer = struct { | ... | @@ -1433,8 +1432,8 @@ pub const Tokenizer = struct { |
| 1433 | | 1432 | |
| 1434 | fn getInvalidCharacterLength(self: *Tokenizer) u3 { | 1433 | fn getInvalidCharacterLength(self: *Tokenizer) u3 { |
| 1435 | const c0 = self.buffer[self.index]; | 1434 | const c0 = self.buffer[self.index]; |
| 1436 | if (c0 < 0x80) { | 1435 | if (std.ascii.isASCII(c0)) { |
| 1437 | if (c0 < 0x20 or c0 == 0x7f) { | 1436 | if (std.ascii.isCntrl(c0)) { |
| 1438 | // ascii control codes are never allowed | 1437 | // ascii control codes are never allowed |
| 1439 | // (note that \n was checked before we got here) | 1438 | // (note that \n was checked before we got here) |
| 1440 | return 1; | 1439 | return 1; |