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