tree-sitter / tree-sitter-go

Go grammar for tree-sitter
MIT License
317 stars 63 forks source link

Add missing fields in keyed_element #149

Closed wetneb closed 2 months ago

wetneb commented 2 months ago

In struct instantiations, such as:

MyStruct {
    foo: 2,
    bar: 3,
}

the keyed elements are currently parsed as seq($.literal_element, ':', $.literal_element), meaning that as a consumer it is difficult to to distinguish the key from the value (given that they have the same type).

This PR proposes to add field names to this part of the grammar, so that they can be told apart.

aryx commented 2 months ago

LGTM

wetneb commented 2 months ago

Thanks for the lightning-fast review! I have fixed the linting error.