remove dead code shebang support from self-hosted tokenizer

master
Andrew Kelley 2019-11-20 20:18:19 -05:00
parent ad77e93415
commit ed619245e9
No known key found for this signature in database
GPG Key ID: 7C5F548F728501A9
1 changed files with 7 additions and 20 deletions

View File

@ -338,26 +338,13 @@ pub const Tokenizer = struct {
} }
pub fn init(buffer: []const u8) Tokenizer { pub fn init(buffer: []const u8) Tokenizer {
if (mem.startsWith(u8, buffer, "#!")) { // Skip the UTF-8 BOM if present
const src_start = if (mem.indexOfScalar(u8, buffer, '\n')) |i| i + 1 else buffer.len; const src_start = if (mem.startsWith(u8, buffer, "\xEF\xBB\xBF")) 3 else @as(usize, 0);
return Tokenizer{ return Tokenizer{
.buffer = buffer, .buffer = buffer,
.index = src_start, .index = src_start,
.pending_invalid_token = Token{ .pending_invalid_token = null,
.id = Token.Id.ShebangLine, };
.start = 0,
.end = src_start,
},
};
} else {
// Skip the UTF-8 BOM if present
const src_start = if (mem.startsWith(u8, buffer, "\xEF\xBB\xBF")) 3 else @as(usize, 0);
return Tokenizer{
.buffer = buffer,
.index = src_start,
.pending_invalid_token = null,
};
}
} }
const State = enum { const State = enum {