Skip to content

Add bracket forms #170

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 11 commits into from
Apr 16, 2025
Merged

Add bracket forms #170

merged 11 commits into from
Apr 16, 2025

Conversation

savq
Copy link
Collaborator

@savq savq commented Feb 18, 2025

  • Rename _top_level to _block_form.
    • Top level was never a very accurate name.
  • Add _bracket_form.
    • Many rules already had a pattern like choice(expression, closed_assignment).
  • Remove let_binding and do_parameter_list.
    • let and do use lists of _bracket_form now.
  • Remove argument_list, and use tuple_expression instead.
    • Julia doesn't distinguish between the two. In most places (x) is a parenthesized expression, but in signatures it's a tuple. Giving a greater dynamic precedence to parentheses solves this problem (same as in lezer-julia).
    • This causes a regression in test performance?
  • Remove named_argument and named_field.
    • Any = inside brackets is parsed as _closed_assignment now.
  • Allow _block_form in const_statement.
  • Refactor macro_identifier and _scoped_identifier.
    • _scoped_identifier is only used in import paths and inside macro identifiers, so it makes sense to just hide it. If @Foo.bar ever becomes illegal syntax, then we can just remove it.
    • Use an alias to fake the field expression in scoped macrocalls better (Foo.@bar).
    • See Unify scoped_identifier and field_expression #74
  • Replace _comprehension_clause with generator
    • Place the _bracket_form inside the generator, instead of having the comprehension clause as a sibling in the parse tree.

Note for editors:

  • Any query that uses named_field, named_argument or let_binding can use assignment instead.

Notes for semgrep:

  • Since there's no pattern/expression distinction, parsing everything in function parameters, let bindings and do bindings the same way is easier than having separate rules for each. In all cases we need to extract a "pattern" from a _bracket_form.

savq added 9 commits February 17, 2025 23:06
Use the simpler definition of argument_list for tuple_expression and
remove argument_list.

Don't alias closed_assignment to either named_field or named_argument.
Use _bracket_form to simplify the definition of:
- Bindings: `let` and `do`.
- Collections: vectors, tuples and parens.
- Expressions: ternary and arrow function expressions.
- Remove `call` precedence
- Remove `postfix` precedence
- Add `_qualified_macro_identifier` rule.
- Rename `scoped_identifier` to `_scoped_identifier`, and alias it to
  `field_expression` or `import_path` where appropiate.
- Refactor `_scoped_identifier` to not be recursive.
@savq savq marked this pull request as ready for review February 27, 2025 03:43
@savq savq force-pushed the bracket-form branch 2 times, most recently from c3ea5e1 to ef837f8 Compare March 18, 2025 15:47
@savq
Copy link
Collaborator Author

savq commented Mar 18, 2025

Hi @amaanq, I'm getting a failure on test_can_load_grammar. I thought this was a bindings issue, but updating the bindings (running tree-sitter version 0.25.0) didn't seem to work. Do you know what might be the issue here?

(Running the tests locally also works fine)

EDIT: Generating with 0.24 works fine, so I'm keeping that version.

@savq savq requested a review from amaanq March 18, 2025 16:21
- Replace `_comprehension_clause` with `generator`
- Place the _bracket_form inside the generator (instead of having the
  comprehension clause as a sibling in the parse tree).
tree-sitter 0.24.7
@savq savq merged commit 18b739c into tree-sitter:master Apr 16, 2025
3 checks passed
@savq savq mentioned this pull request Apr 16, 2025
Closed
aviatesk added a commit to aviatesk/zed-julia that referenced this pull request May 28, 2025
`scoped_identifier` has been removed within
tree-sitter/tree-sitter-julia#170.

Also tweaks multiline comment ending pattern
so that it does not insert unnecessary extra
whitespace.
aviatesk added a commit to aviatesk/zed-julia that referenced this pull request May 29, 2025
`scoped_identifier` has been removed within
tree-sitter/tree-sitter-julia#170.

Also tweaks multiline comment ending pattern
so that it does not insert unnecessary extra
whitespace.
piechologist added a commit to JuliaEditorSupport/zed-julia that referenced this pull request May 29, 2025
Update tree-sitter-julia. The new version allows `const` in `structs` among other improvements. See tree-sitter/tree-sitter-julia#170.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

bug: error parsing const struct fields
1 participant