Skip to content
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

Afroozeh/add fields for navigation suffix #149

Closed

Conversation

afroozeh
Copy link
Contributor

No description provided.

afroozeh and others added 18 commits August 3, 2024 22:00
We need to expose null literals in parse trees, otherwise, it will not
be possible to syntactically differentiate between some constructs.
Example: currently, these two functions yield the same parse tree:
```
fun f() = null
fun f() { }
```
```
source_file
  function_declaration
    simple_identifier
    function_value_parameters
    function_body
```

With the changes in this PR, the first function will have a
`null_literal` in the tree:
```
source_file
  function_declaration
    simple_identifier
    function_value_parameters
    function_body
      null_literal
```
Currently, it is rather cumbersome to detect the 'else' part of an 'if-else' construct in the parse tree because the 'else' part is flattened. This PR makes the parse tree more explicit by having nested else nodes. This would simplify matching the 'else' part.
## Description

This PR adds fields for property_declaration

## Test Plan

passes existing tests

## Revert Plan

revert diff
This PR exposes the `block` node as a visible node in the parse tree.
Without that, we need to rely on `statements` and some other checks to
find blocks which is very cumbersome and error-prone.
## Description

Add more fields to the grammar

## Test Plan

Added modifiers to the tests

## Revert Plan

revert diff
This PR expose 'function_value_parameter' as a grammar node, as it was
originally in the reference grammar.
Otherwise, translating the parameters is difficult because the default
value initializer is in `function_value_parameter`.
Add fields for class_parameters
Merge upstream main

The only real change is 
```    
null_literal: $ => seq(
      "null"
    ),
```
became:
```
null_literal: $ => "null",
```
## Description

- Upgrades to tree-sitter 0.23.0 and regenerates the bindings.
- Shows fields by default in tests (new feature in tree-sitter 0.23.0).
- Uses standard CI actions and adds the Kotlin compiler repo for testing
samples.

## Test Plan

unit tests

## Revert Plan

None, forward fix.
Cherry-pick of
8c7c0ca
from upstream.

Before, I made `else` a nonterminal (grammar rule) but it turned out
that fields are a better way to do that without altering the grammar. As
a bonus, the updated grammar is in line with Java and other grammars.
Cherry-pick of #142 which
fixes #127.

Fixes the priority of arguments in calls. `with(s) { length }` should be
parsed as `with ((s), { length })

```
(source_file
  (call_expression
    (simple_identifier)
    (call_suffix
      (value_arguments
        (value_argument
          (simple_identifier)))
      (annotated_lambda
        (lambda_literal
          (statements
            (simple_identifier)))))))
```

And not as `(with (s)) { length})`
```
(source_file
  (call_expression
    (call_expression
      (simple_identifier)
      (call_suffix
        (value_arguments
          (value_argument
            (simple_identifier)))))
     (call_suffix       
        (annotated_lambda
          (lambda_literal
            (statements
              (simple_identifier)))))))
```
Fields for `catch_block` and `for_statement`.
@github-actions github-actions bot added ci-cd CI/CD-related grammar Related to the grammar bindings Related to the Node.js/Rust/C bindings labels Sep 18, 2024
@afroozeh afroozeh closed this Sep 18, 2024
@afroozeh
Copy link
Contributor Author

This was opened up by mistake, sorry.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bindings Related to the Node.js/Rust/C bindings ci-cd CI/CD-related grammar Related to the grammar
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants