tree-sitter / tree-sitter-julia

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

Unify `scoped_identifier` and `field_expression` #74

Open ChrHorn opened 1 year ago

ChrHorn commented 1 year ago

These are used in different places but represent nearly the same syntax. I don't think we need both.

scoped_identifier is also currently defined recursively. Recursive structures of arbitrary depth are very hard to query. A flat structure would be better.

savq commented 1 year ago

Scoped identifiers were originally only used for import statements. I added them to other places where I don't think it makes sense to have a field expression (like function signatures) for the same reason we distinguish between parameters and arguments. Parameters are restricted to symbol-like things, but arguments allow any primary expression.

There are a couple of things that do need to get fixed tho:

  1. There's two ways to call scoped macros, but only one is parsed correctly:

    @M.foo x y z    # ok
    M.@foo x y z    # not parsed correctly
  2. quoted operators like Base.:+ are not parsed correctly either.

scoped_identifier is also currently defined recursively

Yes, that needs to get fixed too.