gleam-lang / tree-sitter-gleam

🌳 A tree-sitter grammar for the Gleam programming language
Apache License 2.0
71 stars 13 forks source link

Add support for v0.21.0 (aka add bang negation) #24

Closed J3RN closed 2 years ago

J3RN commented 2 years ago

A bit belated :sweat_smile:

From the diff of the Gleam parser, it appears that the only differences from 0.20.1 to 0.21.0 are

As such, this change just adds support for the negation operator.

cc @the-mikedavis

the-mikedavis commented 2 years ago

It may make sense to categorize this as a unary operator if there are many others. - as in -1 comes to mind from other languages. tree-sitter-elixir has a somewhat complicated unary operator rule helper function (complicated because of the precedence). I have a simpler version in tree-sitter-erlang that could be a good reference. It seems like unary operators are not (yet) common in gleam though so I don't think it's necessary - just something to keep in mind for later.

lpil commented 2 years ago

If it helps I've no plans to add any new unary operators

J3RN commented 2 years ago

@the-mikedavis You raise a good point! Having a clause/function for unary operators did cross my mind, but in general I try to hew as close to the Gleam parser as possible (makes updates like this one easier). Perhaps if more unary operators are added, we can reconsider.

Cheers all! :tada: