Lezer incorrectly highlighting keyword

I’m writing a Lezer grammar for GraphQL, mostly copying over from the spec. I’m having the issue that enum is being highlighted as a keyword in places it shouldn’t be:

image

GraphQL .grammar file

Repository with full repro

This is probably a bug in my Lezer code. I don’t understand how that line can be parsed as an EnumTypeDefinition / EnumTypeExtension (especially since the latter requires enum to be preceded by extend) rather than an Argument. Am I misunderstanding how @specialize works, or do I need to add precedence markers somewhere?

Likely. @specialize<name, "enum"> means any name token whose content is "enum" will be parsed as a specialized token, and not a name.

If property names and regular keywords don’t occur in the same contexts, you might be able to do what the JavaScript grammar does and use two separate identifier tokens (word and identifier in that grammar) that for those different contexts, relying on contextual tokenization to distinguish them, and specialize only one of them for keywords.