Skip to content

Simplify try statement, accept missing else/except/finally #304

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

Open
wants to merge 8 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion .gitattributes
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ src/parser.c linguist-generated
src/tree_sitter/* linguist-generated

# C bindings
bindings/c/* linguist-generated
bindings/c/** linguist-generated
CMakeLists.txt linguist-generated
Makefile linguist-generated

Expand Down Expand Up @@ -35,3 +35,7 @@ go.sum linguist-generated
bindings/swift/** linguist-generated
Package.swift linguist-generated
Package.resolved linguist-generated

# Zig bindings
build.zig linguist-generated
build.zig.zon linguist-generated
3 changes: 2 additions & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,9 @@ jobs:
git clone https://github.com/pallets/flask examples/flask --single-branch --depth=1 --filter=blob:none
git clone https://github.com/python/cpython examples/cpython --single-branch --depth=1 --filter=blob:none
- name: Run tests
uses: tree-sitter/parser-test-action@v2
uses: tree-sitter/parser-test-action@v3-pre
with:
generate: false
test-rust: true
test-node: true
test-python: true
Expand Down
10 changes: 10 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,13 +1,16 @@
# Rust artifacts
target/
Cargo.lock

# Node artifacts
build/
prebuilds/
node_modules/
package-lock.json

# Swift artifacts
.build/
Package.resolved

# Go artifacts
_obj/
Expand All @@ -25,6 +28,13 @@ dist/
*.dylib
*.dll
*.pc
*.exp
*.lib

# Zig artifacts
.zig-cache/
zig-cache/
zig-out/

# Example dirs
/examples/*/
Expand Down
11 changes: 8 additions & 3 deletions CMakeLists.txt

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

96 changes: 0 additions & 96 deletions Cargo.lock

This file was deleted.

2 changes: 1 addition & 1 deletion Makefile

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

16 changes: 0 additions & 16 deletions Package.resolved

This file was deleted.

2 changes: 1 addition & 1 deletion Package.swift

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

14 changes: 11 additions & 3 deletions bindings/python/tree_sitter_python/binding.c

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

16 changes: 3 additions & 13 deletions grammar.js
Original file line number Diff line number Diff line change
Expand Up @@ -341,19 +341,9 @@ module.exports = grammar({
'try',
':',
field('body', $._suite),
choice(
seq(
repeat1($.except_clause),
optional($.else_clause),
optional($.finally_clause),
),
seq(
repeat1($.except_group_clause),
optional($.else_clause),
optional($.finally_clause),
),
$.finally_clause,
),
repeat(choice($.except_clause, $.except_group_clause)),
optional($.else_clause),
optional($.finally_clause),
),

except_clause: $ => seq(
Expand Down
Loading
Loading