Skip to content

Conversation

@mrdimidium
Copy link
Member

No description provided.

Copy link
Collaborator

@karlseguin karlseguin left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since it's still in draft, I figured I'd just comment on the superficial (but still important)

/// A `<function-token>`
///
/// The value (name) does not include the `(` marker.
Function: []const u8,
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We tend to follow Zig's naming guidelines, which has tag names as snake_case.


// If true, the input has at least `n` bytes left *after* the current one.
// That is, `Lexer.byte_at(n)` will not panic.
fn has_at_least(self: *const Tokenizer, n: usize) bool {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

And function names are camelCase

// start_pos is at code point boundary, after " or '
const start_pos = self.position;

while (self.is_eof()) {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this right? I think it shoud be while (!self.is_eof()) { good indication of a missing test.

};

self.advance(2);
} else if (self.has_at_least(1) and std.ascii.isDigit(self.byte_at(2))) {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If we're checking byte_at(2), should this be self.has_at_least(2) ?


var b = self.next_byte_unchecked();
if (b == '-') {
b = self.next_byte() orelse return false;
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Isn't b guaranteed to be '-' here?


fn consume_unquoted_url(self: *Tokenizer) ?Token {
_ = self;
@panic("unimplemented");
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If this isn't something we plan on implementing now, we should log, not panic.

// over ASCII bytes (excluding newlines), or UTF-8 sequence
// leaders (excluding leaders for 4-byte sequences).
fn advance(self: *Tokenizer, n: usize) void {
if (builtin.mode == .Debug) {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not sure this is super useful...It's not really adding checks in debug for our code, it's adding checks in debug for external code (css). If the assertion fails, what are we supposed to do about it?

}

return switch (b) {
'a'...'z', 'A'...'Z', '_', 0x0 => true,
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

is 0x0 really valid here (or anywhere else)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants