tree-sitter / tree-sitter-julia

Julia grammar for Tree-sitter
MIT License
93 stars 32 forks source link

Improve module, type and function definitions #54

Closed savq closed 1 year ago

savq commented 1 year ago

Types and modules

Functions

Function parameters and scoped identifiers

Misc

Caveats:

Once assignment patterns are fixed, these conflicts could be removed (and _parameter could finally be added), but I think that belongs in another PR.


Closes #26 Closes #40 Closes #41 Closes #42 Closes #36, but the implementation is different from #43 Closes #57 Closes #60 Closes #61 Closes #63

ChrHorn commented 1 year ago

Very nice, I will close https://github.com/tree-sitter/tree-sitter-julia/pull/43 in favor of getting this one through.

Could you also add support for empty functions, for example function f end. These are often used to add docstrings.

ExpandingMan commented 1 year ago

This is awesome, thanks!

Just wanted to report a minor issue I found in which sometimes type assertions can be parsed as symbols, see this example image

ExpandingMan commented 1 year ago

Another minor issue, the ∈ character in for loops is not being recognized (should be @keyword.operator to match in).

image

savq commented 1 year ago

Just wanted to report a minor issue I found in which sometimes type assertions can be parsed as symbols, see this example

@ExpandingMan The PR fixes this πŸ‘

Another minor issue, the ∈ character in for loops is not being recognized (should be @keyword.operator to match in).

This can be fixed in either the grammar or the queries, and it's a bit unrelated to the rest of the PR. I'll add a fix for this in nvim-treesitter first.

savq commented 1 year ago

Ok. All the updated rules and their correspoding tests should be ready.

aviks commented 1 year ago

Should this be merged, @maxbrunsfeld ? Seems like a significant improvement.

tecosaur commented 1 year ago

Regarding slurp_expression, would splat_expression be more appropriate? I see ... described as the "splat operator" more than anything else. You'll also see it called the "splat operator" (but not the "slurp operator") in Python, Ruby, and other places.

savq commented 1 year ago

I wrote the wrong thing in the PR comment (I updated it). For future reference:

That's the "correct" naming convention in Julia. See What does the ... operator do?