Should `[*c]` be a token?

It’s a little weird that [ * c ]u8 leads to a different parse tree than [ * d ]u8.

This is code from the parser that deals with it - it’s the only code that needs to look at the actual token text instead of its tag.

const ident_slice = p.source[p.token_starts[ident]..p.token_starts[ident + 1]];
if (!std.mem.eql(u8, std.mem.trimRight(u8, ident_slice, &std.ascii.whitespace), "c")) {
    p.tok_i -= 1;
}

(source)

Does this make c a sort of contextual keyword? Does it matter? Making [*c] be an indivisible token seems like it’d help.

1 Like