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

Put match inner block in a block node #226

Merged
merged 1 commit into from
Jul 12, 2023

Conversation

stsewd
Copy link
Contributor

@stsewd stsewd commented Jul 11, 2023

This matches the other block statements (with, try, if, etc), all of them have a body field with a block node that contains the body of the statement.

_suite: $ => choice(
alias($._simple_statements, $.block),
seq($._indent, $.block),
alias($._newline, $.block)
),
block: $ => seq(
repeat($._statement),
$._dedent
),

This was also allowing

match 1: case 1: pass

Which is invalid, match blocks need an indentation

This matches the other block statements (with, try, if, etc),
all of them have a body field with a block node that contains
the body of the statement.

https://github.com/tree-sitter/tree-sitter-python/blob/5a5455ef88ead370a9c7b93d8f55ea5a6b9127d7/grammar.js#L487-L496

This was also allowing

```python
match 1: case 1: pass
```

Which is invalid, match blocks need an indentation
@amaanq
Copy link
Member

amaanq commented Jul 12, 2023

Awesome

@amaanq amaanq merged commit 538a532 into tree-sitter:master Jul 12, 2023
3 checks passed
@stsewd stsewd deleted the match-block-node branch July 12, 2023 14:26
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.

2 participants