Skip to content

Commit

Permalink
build: update bindings and workflows
Browse files Browse the repository at this point in the history
  • Loading branch information
amaanq committed Apr 7, 2024
1 parent 2e5682b commit d6e8c6b
Show file tree
Hide file tree
Showing 41 changed files with 116,615 additions and 114,722 deletions.
39 changes: 39 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
root = true

[*]
charset = utf-8
end_of_line = lf
insert_final_newline = true
trim_trailing_whitespace = true

[*.{json,toml,yml,gyp}]
indent_style = space
indent_size = 2

[*.js]
indent_style = space
indent_size = 2

[*.rs]
indent_style = space
indent_size = 4

[*.{c,cc,h}]
indent_style = space
indent_size = 4

[*.{py,pyi}]
indent_style = space
indent_size = 4

[*.swift]
indent_style = space
indent_size = 4

[*.go]
indent_style = tab
indent_size = 8

[Makefile]
indent_style = tab
indent_size = 8
20 changes: 0 additions & 20 deletions .eslintrc.js

This file was deleted.

15 changes: 8 additions & 7 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
/src/** linguist-vendored
/examples/* linguist-vendored
* text eol=lf

src/grammar.json linguist-generated
src/node-types.json linguist-generated
src/*.json linguist-generated
src/parser.c linguist-generated
src/tree_sitter/* linguist-generated

src/grammar.json -diff
src/node-types.json -diff
src/parser.c -diff
bindings/** linguist-generated
binding.gyp linguist-generated
setup.py linguist-generated
Makefile linguist-generated
Package.swift linguist-generated
46 changes: 37 additions & 9 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,10 +1,38 @@
# Rust artifacts
Cargo.lock
node_modules
build
*.log
package-lock.json
/examples
!examples/ast.rs
!examples/weird-exprs.rs
/target/
/fuzzer/
target/

# Node artifacts
build/
prebuilds/
node_modules/
*.tgz

# Swift artifacts
.build/

# Go artifacts
go.sum
_obj/

# Python artifacts
.venv/
dist/
*.egg-info
*.whl

# C artifacts
*.a
*.so
*.so.*
*.dylib
*.dll
*.pc

# Example dirs
/examples/*/

# Grammar volatiles
*.wasm
*.obj
*.o
6 changes: 0 additions & 6 deletions .npmignore

This file was deleted.

14 changes: 8 additions & 6 deletions Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
[package]
name = "tree-sitter-rust"
description = "Rust grammar for tree-sitter"
version = "0.20.4"
authors = ["Max Brunsfeld <[email protected]>"]
version = "0.21.0"
authors = [
"Max Brunsfeld <[email protected]>",
"Amaan Qureshi <[email protected]>",
]
license = "MIT"
readme = "bindings/rust/README.md"
keywords = ["incremental", "parsing", "rust"]
keywords = ["incremental", "parsing", "tree-sitter", "rust"]
categories = ["parsing", "text-editors"]
repository = "https://github.com/tree-sitter/tree-sitter-rust"
edition = "2021"
Expand All @@ -18,7 +20,7 @@ include = ["bindings/rust/*", "grammar.js", "queries/*", "src/*"]
path = "bindings/rust/lib.rs"

[dependencies]
tree-sitter = "~0.20.10"
tree-sitter = ">=0.21.0"

[build-dependencies]
cc = "~1.0.82"
cc = "~1.0.90"
111 changes: 111 additions & 0 deletions Makefile

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

34 changes: 21 additions & 13 deletions Package.swift

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

23 changes: 10 additions & 13 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,44 +5,41 @@
[![matrix][matrix]](https://matrix.to/#/#tree-sitter-chat:matrix.org)
[![crates][crates]](https://crates.io/crates/tree-sitter-rust)
[![npm][npm]](https://www.npmjs.com/package/tree-sitter-rust)
[![pypi][pypi]](https://pypi.org/project/tree-sitter-rust)

Rust grammar for [tree-sitter](https://github.com/tree-sitter/tree-sitter)
Rust grammar for [tree-sitter](https://github.com/tree-sitter/tree-sitter).

## Features

- **Speed** — When initially parsing a file, `tree-sitter-rust` takes around twice
as long as Rustc's hand-coded parser.
- **Speed** — When initially parsing a file, `tree-sitter-rust` takes around two to three times
as long as rustc's hand-written parser.

```sh
$ wc -l examples/ast.rs
2157 examples/ast.rs

$ rustc -Z ast-json-noexpand -Z time-passes examples/ast.rs | head -n1
time: 0.007 parsing # (7 ms)
$ rustc -Z unpretty=ast-tree -Z time-passes examples/ast.rs | head -n0
time: 0.002; rss: 55MB -> 60MB ( +5MB) parse_crate

$ tree-sitter parse examples/ast.rs --quiet --time
examples/ast.rs 16 ms
examples/ast.rs 6.48 ms 9908 bytes/ms
```

But if you _edit_ the file after parsing it, this parser can generally _update_
But if you _edit_ the file after parsing it, tree-sitter can generally _update_
the previous existing syntax tree to reflect your edit in less than a millisecond,
thanks to Tree-sitter's incremental parsing system.
thanks to its incremental parsing system.

## References

- [The Rust Grammar Reference](https://doc.rust-lang.org/grammar.html) — The grammar
reference provides chapters that formally define the language grammar.
- [The Rust Reference](https://doc.rust-lang.org/reference/) — While Rust does
not have a specification, the reference tries to describe its working in detail.
It tends to be out of date.
- [Keywords](https://doc.rust-lang.org/stable/book/appendix-01-keywords.html) and
[Operators and Symbols](https://doc.rust-lang.org/stable/book/appendix-02-operators.html).
- Archive of the outdated [Syntax Index](https://web.mit.edu/rust-lang_v1.25/arch/amd64_ubuntu1404/share/doc/rust/html/book/first-edition/syntax-index.html)
that contains examples of all syntax in Rust cross-referenced with the section
of The Book that describes it.

[ci]: https://img.shields.io/github/actions/workflow/status/tree-sitter/tree-sitter-rust/ci.yml?logo=github&label=CI
[discord]: https://img.shields.io/discord/1063097320771698699?logo=discord&label=discord
[matrix]: https://img.shields.io/matrix/tree-sitter-chat%3Amatrix.org?logo=matrix&label=matrix
[npm]: https://img.shields.io/npm/v/tree-sitter-rust?logo=npm
[crates]: https://img.shields.io/crates/v/tree-sitter-rust?logo=rust
[pypi]: https://img.shields.io/pypi/v/tree-sitter-rust?logo=pypi&logoColor=ffd242
Loading

0 comments on commit d6e8c6b

Please sign in to comment.