Commit graph

1651 commits

Author SHA1 Message Date
Amaan Qureshi 0a85744eba fix(lib): peek at the next sibling when iterating to find the child that contains a given descendant
Some checks failed
CI / checks (push) Waiting to run
CI / sanitize (push) Failing after 12s
CI / build (push) Failing after 13s
This issue shows up when we have a zero-width token that is the target
descendant node, previously the previous sibling would be returned as
the child that contains the descendant, which is incorrect.
2024-09-17 04:37:43 +02:00
ObserverOfTime 6e19fccf39 chore(bindings): update rust lib docs 2024-09-17 03:40:48 +02:00
Dave Abrahams 112acd5b93
fix(generate): remove excludes in Package.swift 2024-09-16 21:40:21 -04:00
Hanlu ff813a311b
fix: correct comment quote 2024-09-16 21:39:49 -04:00
Will Lillis b0e8e50a19
fix(cli): remove duplicate short options from fuzz command (#3635)
Some checks failed
CI / sanitize (push) Failing after 13s
CI / build (push) Failing after 13s
CI / checks (push) Has been cancelled
- Remove short option from fuzz command edits option
- Remove short option from fuzz command iterations option
2024-09-15 11:04:12 +03:00
Amaan Qureshi 7e3f572655 feat: add field_name_for_named_child
Some checks failed
CI / sanitize (push) Failing after 12s
CI / build (push) Failing after 12s
CI / checks (push) Has been cancelled
2024-09-09 11:05:29 -04:00
Amaan Qureshi d8ab779df4 fix(generate): do not generate large character sets for unused variables 2024-09-08 15:42:18 -04:00
Amaan Qureshi cbd3bb5b9a feat!: remove the build-wasm subcommand
Some checks failed
CI / checks (push) Waiting to run
CI / sanitize (push) Failing after 11s
CI / build (push) Failing after 11s
`build --wasm` should be used instead
2024-09-08 13:41:26 -04:00
Amaan Qureshi 10e474f488 feat!: remove filter flag from commands in favor of include and exclude
Some checks failed
CI / checks (push) Waiting to run
CI / sanitize (push) Failing after 11s
CI / build (push) Failing after 12s
2024-09-07 20:53:04 -04:00
Amaan Qureshi 5e46fef0d7 chore: clippy lints 2024-09-07 20:31:20 -04:00
Amaan Qureshi 9301d38b77 feat!: remove C++ support for external scanners 2024-09-07 20:14:36 -04:00
Jinser Kafka fd190f1d9d fix(cli): keep skipped tests unchanged in the test/corpus 2024-09-07 18:55:49 -04:00
Amaan Qureshi 4d3d1f0df2 fix(generate): add tree-sitter to the dev-dependencies of the Cargo.toml 2024-09-07 17:46:09 -04:00
Amaan Qureshi 272ebf77b9 fix(test): retain attributes when running test -u
Some checks failed
CI / checks (push) Waiting to run
CI / sanitize (push) Failing after 13s
CI / build (push) Failing after 13s
2024-09-01 06:18:55 -04:00
Amaan Qureshi 0a486d508f fix(test): exit with an error if a test marked with :error has no error 2024-09-01 06:18:55 -04:00
Amaan Qureshi ee06325f67 fix(lib): correct extra node creation from non-zero root-alias cursors
Some checks failed
CI / checks (push) Waiting to run
CI / sanitize (push) Failing after 12s
CI / build (push) Failing after 13s
2024-08-31 23:58:19 -04:00
Amaan Qureshi 53cc93c267 fix(generate): disallow inline variables referencing themselves
Some checks failed
CI / checks (push) Waiting to run
CI / sanitize (push) Failing after 12s
CI / build (push) Failing after 13s
This fixes an infinite loop bug
2024-08-31 16:57:23 -04:00
Amaan Qureshi 3f424c0121 feat: add an API to time out query executions
Currently, if a predicate is hard to match on the Rust side, a sizable
query against a very large file can take forever, and ends up hanging.
This commit adds an API function `ts_query_cursor_set_timeout_micros` to
limit how long query execution is allowed to take, thereby negating the
chance of a hang to occur.
2024-08-31 14:33:28 -04:00
Amaan Qureshi d0125ef387 feat(bindings): bump go-tree-sitter version 2024-08-29 22:50:27 -04:00
Amaan Qureshi 278526ef75 fix(cli): remove conflicting short flags in the fuzz subcommand 2024-08-29 22:07:41 -04:00
Amaan Qureshi b5a91a4a85 feat(generate): bump tree-sitter dev dependency to 0.23 2024-08-29 22:07:33 -04:00
Amaan Qureshi 253a112dd4 fix(generate): remove necessary files from gitignore template 2024-08-29 21:50:20 -04:00
Amaan Qureshi 12fb31826b
0.23.0
Some checks failed
CI / sanitize (push) Failing after 12s
CI / build (push) Failing after 13s
CI / checks (push) Has been cancelled
2024-08-26 09:07:00 -04:00
Amaan Qureshi fc4d7bd995 fix(cli): dedup preceding_auxiliary_symbols 2024-08-26 09:03:08 -04:00
ObserverOfTime ff8b50caa6 build(bindings): use language version in soname
Some checks failed
CI / checks (push) Waiting to run
CI / sanitize (push) Failing after 12s
CI / build (push) Failing after 12s
2024-08-25 15:03:13 -04:00
Amaan Qureshi 6ef76858c0 fix!: revert interning of a sequence or choice of a single rule
Some checks failed
CI / checks (push) Waiting to run
CI / sanitize (push) Failing after 12s
CI / build (push) Failing after 12s
This reverts commit 252e2a4bc0
2024-08-24 19:43:04 -04:00
Amaan Qureshi 973b01071e fix(go): update parser name in binding files, add to docs 2024-08-24 19:24:06 -04:00
Amaan Qureshi 2150c91114 fix(bindings): update go bindings
Some checks failed
CI / checks (push) Waiting to run
CI / sanitize (push) Failing after 12s
CI / build (push) Failing after 12s
2024-08-23 23:51:04 -04:00
Ryan Patterson b5e4ef6d9a
clone wasm store engine (#3542)
Some checks failed
CI / checks (push) Waiting to run
CI / sanitize (push) Failing after 12s
CI / build (push) Failing after 13s
This resolves https://github.com/tree-sitter/tree-sitter/issues/3454.

This brings the usage of wasmtime::Engine in line with how wasmtime
intends it to be used. All wasmtime functions that receive an Engine
always receive an `&Engine`, never an owned `Engine`.  They are always
responsible for cloning the reference if they need it.

This brings the usage of wasmtime::Engine in line with how TSParser
treats TSLanguages: when setting a language to the parser, the parser is
responsible for cloning the reference to the TSLanguage. It is
counterintuitive for TSParser to have different behavior when receiving
wasmtime_engine_t.

C API users also expect this behavior, see "Memory Management"
[here](https://docs.wasmtime.dev/c-api/wasm_8h.html). Talking about the
C API: without this change, failing to clone the `wasmtime_engine_t`
(which, again, is never something API users need to do in wasmtime) and
then reusing the engine in multiple TSLanguages results in a use after
free. With this change, failing to call `wasm_engine_delete` on your
owned Engine results in a memory leak. Memory leaks are safer than
use-after-free.
2024-08-22 08:01:37 -07:00
ObserverOfTime f459c3d872 feat(bindings)!: use capsules in python 2024-08-20 12:33:11 +03:00
Amaan Qureshi 6dd459b4ab fix(lib): an empty root node should not precede an empty range
Some checks failed
CI / checks (push) Waiting to run
CI / sanitize (push) Failing after 12s
CI / build (push) Failing after 13s
The problem is, given an empty file, the root node of this file spans 0
bytes. As such, the logic for determining whether or not the node
precedes the range fails, and is true when it should be false.
2024-08-17 17:05:26 -04:00
Ron Panduwana 2bb20fe2fe
feat: allow external scanners to use the logger
Co-authored-by: Amaan Qureshi <amaanq12@gmail.com>
2024-08-17 14:46:28 -04:00
Amaan Qureshi fec6c77da8 fix(generate): rename cargo.toml template
Some checks failed
CI / checks (push) Waiting to run
CI / sanitize (push) Failing after 11s
CI / build (push) Failing after 12s
This fixes issues with vendoring on case-insensitive file systems
2024-08-17 01:39:52 -04:00
ObserverOfTime 2eeeed0f2a fix(make): fail properly on Windows 2024-08-17 00:51:27 -04:00
buckynbrocko 7583d394b4
feat(cli): add --show-fields flag to test command (#3502)
Some checks failed
CI / sanitize (push) Failing after 13s
CI / build (push) Failing after 13s
CI / checks (push) Has been cancelled
2024-08-03 21:54:18 +03:00
Ryan Patterson 779566f588
Reset language when resetting wasm store (#3495)
Some checks failed
CI / sanitize (push) Failing after 12s
CI / build (push) Failing after 12s
CI / checks (push) Has been cancelled
* Reset language when resetting wasm store

* test behavior of language copying
2024-07-31 10:30:58 -07:00
ObserverOfTime ce37b112dc build(wasm): bump emscripten to 3.1.64 2024-07-29 15:59:56 +03:00
Guillaume Bertholon 1c7b518b9d
build(loader): make dependencies optional (#1638)
The `tree-sitter-loader` crate currently always pulls
`tree-sitter-highlight` and `tree-sitter-tags` as dependencies.
However, apart from the tree-sitter CLI, most clients will not need both
of these libraries.

This commit makes the dependencies optional, but still includes them by
default in order not to break the backward compatibility.
2024-07-28 10:59:21 +03:00
ObserverOfTime 3950dddfde fix(rust): fix new clippy warnings 2024-07-28 10:12:32 +03:00
Amaan Qureshi 25c7189180 feat(lib): add ts_query_end_byte_for_pattern 2024-07-07 20:29:09 -04:00
阿良仔 9e0c922b3f
feat(cli): attach helpful context when grammar.json cannot be found
Co-authored-by: Amaan Qureshi <amaanq12@gmail.com>
2024-07-05 19:53:47 -04:00
Unicatevn c185170936 fix(cli): installation via authenticated proxy 2024-07-05 19:50:31 -04:00
Amaan Qureshi a59a530049 fix(dsl): improve error message when a rule function returns undefined 2024-07-05 19:11:01 -04:00
dependabot[bot] 12bd194937 build(deps): bump the cargo group across 1 directory with 9 updates
Bumps the cargo group with 9 updates in the / directory:

| Package | From | To |
| --- | --- | --- |
| [cc](https://github.com/rust-lang/cc-rs) | `1.0.99` | `1.0.104` |
| [clap](https://github.com/clap-rs/clap) | `4.5.7` | `4.5.8` |
| [fs4](https://github.com/al8n/fs4-rs) | `0.8.3` | `0.8.4` |
| [lazy_static](https://github.com/rust-lang-nursery/lazy-static.rs) | `1.4.0` | `1.5.0` |
| [libloading](https://github.com/nagisa/rust_libloading) | `0.8.3` | `0.8.4` |
| [log](https://github.com/rust-lang/log) | `0.4.21` | `0.4.22` |
| [memchr](https://github.com/BurntSushi/memchr) | `2.7.2` | `2.7.4` |
| [serde_json](https://github.com/serde-rs/json) | `1.0.117` | `1.0.120` |
| [url](https://github.com/servo/rust-url) | `2.5.1` | `2.5.2` |



Updates `cc` from 1.0.99 to 1.0.104
- [Release notes](https://github.com/rust-lang/cc-rs/releases)
- [Changelog](https://github.com/rust-lang/cc-rs/blob/main/CHANGELOG.md)
- [Commits](https://github.com/rust-lang/cc-rs/compare/1.0.99...cc-v1.0.104)

Updates `clap` from 4.5.7 to 4.5.8
- [Release notes](https://github.com/clap-rs/clap/releases)
- [Changelog](https://github.com/clap-rs/clap/blob/master/CHANGELOG.md)
- [Commits](https://github.com/clap-rs/clap/compare/clap_complete-v4.5.7...v4.5.8)

Updates `fs4` from 0.8.3 to 0.8.4
- [Release notes](https://github.com/al8n/fs4-rs/releases)
- [Commits](https://github.com/al8n/fs4-rs/commits)

Updates `lazy_static` from 1.4.0 to 1.5.0
- [Release notes](https://github.com/rust-lang-nursery/lazy-static.rs/releases)
- [Commits](https://github.com/rust-lang-nursery/lazy-static.rs/compare/1.4.0...1.5.0)

Updates `libloading` from 0.8.3 to 0.8.4
- [Commits](https://github.com/nagisa/rust_libloading/compare/0.8.3...0.8.4)

Updates `log` from 0.4.21 to 0.4.22
- [Release notes](https://github.com/rust-lang/log/releases)
- [Changelog](https://github.com/rust-lang/log/blob/master/CHANGELOG.md)
- [Commits](https://github.com/rust-lang/log/compare/0.4.21...0.4.22)

Updates `memchr` from 2.7.2 to 2.7.4
- [Commits](https://github.com/BurntSushi/memchr/compare/2.7.2...2.7.4)

Updates `serde_json` from 1.0.117 to 1.0.120
- [Release notes](https://github.com/serde-rs/json/releases)
- [Commits](https://github.com/serde-rs/json/compare/v1.0.117...v1.0.120)

Updates `url` from 2.5.1 to 2.5.2
- [Release notes](https://github.com/servo/rust-url/releases)
- [Commits](https://github.com/servo/rust-url/compare/v2.5.1...v2.5.2)

---
updated-dependencies:
- dependency-name: cc
  dependency-type: direct:production
  update-type: version-update:semver-patch
  dependency-group: cargo
- dependency-name: clap
  dependency-type: direct:production
  update-type: version-update:semver-patch
  dependency-group: cargo
- dependency-name: fs4
  dependency-type: direct:production
  update-type: version-update:semver-patch
  dependency-group: cargo
- dependency-name: lazy_static
  dependency-type: direct:production
  update-type: version-update:semver-minor
  dependency-group: cargo
- dependency-name: libloading
  dependency-type: direct:production
  update-type: version-update:semver-patch
  dependency-group: cargo
- dependency-name: log
  dependency-type: direct:production
  update-type: version-update:semver-patch
  dependency-group: cargo
- dependency-name: memchr
  dependency-type: direct:production
  update-type: version-update:semver-patch
  dependency-group: cargo
- dependency-name: serde_json
  dependency-type: direct:production
  update-type: version-update:semver-patch
  dependency-group: cargo
- dependency-name: url
  dependency-type: direct:production
  update-type: version-update:semver-patch
  dependency-group: cargo
...

Signed-off-by: dependabot[bot] <support@github.com>
2024-07-05 03:36:02 -04:00
Quentin LE DILAVREC 9610a84600
fix(lib): restrict pattern_map optimization when a wildcard step has an immediate first child
Co-authored-by: Amaan Qureshi <amaanq12@gmail.com>
2024-07-05 03:35:24 -04:00
Amaan Qureshi 6ec478c1e9 fix: do not "absorb" rules that consist of a single terminal if the rule is hidden 2024-06-21 20:20:02 -04:00
Amaan Qureshi 252e2a4bc0 fix: intern a sequence or choice of a single element the same as the element itself 2024-06-21 20:20:02 -04:00
dependabot[bot] 87baf5b689 build(deps): bump the cargo group with 5 updates
Bumps the cargo group with 5 updates:

| Package | From | To |
| --- | --- | --- |
| [cc](https://github.com/rust-lang/cc-rs) | `1.0.98` | `1.0.99` |
| [clap](https://github.com/clap-rs/clap) | `4.5.4` | `4.5.7` |
| [regex](https://github.com/rust-lang/regex) | `1.10.4` | `1.10.5` |
| [regex-syntax](https://github.com/rust-lang/regex) | `0.8.3` | `0.8.4` |
| [url](https://github.com/servo/rust-url) | `2.5.0` | `2.5.1` |


Updates `cc` from 1.0.98 to 1.0.99
- [Release notes](https://github.com/rust-lang/cc-rs/releases)
- [Commits](https://github.com/rust-lang/cc-rs/compare/1.0.98...1.0.99)

Updates `clap` from 4.5.4 to 4.5.7
- [Release notes](https://github.com/clap-rs/clap/releases)
- [Changelog](https://github.com/clap-rs/clap/blob/master/CHANGELOG.md)
- [Commits](https://github.com/clap-rs/clap/compare/clap_complete-v4.5.4...v4.5.7)

Updates `regex` from 1.10.4 to 1.10.5
- [Release notes](https://github.com/rust-lang/regex/releases)
- [Changelog](https://github.com/rust-lang/regex/blob/master/CHANGELOG.md)
- [Commits](https://github.com/rust-lang/regex/compare/1.10.4...1.10.5)

Updates `regex-syntax` from 0.8.3 to 0.8.4
- [Release notes](https://github.com/rust-lang/regex/releases)
- [Changelog](https://github.com/rust-lang/regex/blob/master/CHANGELOG.md)
- [Commits](https://github.com/rust-lang/regex/compare/regex-syntax-0.8.3...regex-syntax-0.8.4)

Updates `url` from 2.5.0 to 2.5.1
- [Release notes](https://github.com/servo/rust-url/releases)
- [Commits](https://github.com/servo/rust-url/compare/v2.5.0...v2.5.1)

---
updated-dependencies:
- dependency-name: cc
  dependency-type: direct:production
  update-type: version-update:semver-patch
  dependency-group: cargo
- dependency-name: clap
  dependency-type: direct:production
  update-type: version-update:semver-patch
  dependency-group: cargo
- dependency-name: regex
  dependency-type: direct:production
  update-type: version-update:semver-patch
  dependency-group: cargo
- dependency-name: regex-syntax
  dependency-type: direct:production
  update-type: version-update:semver-patch
  dependency-group: cargo
- dependency-name: url
  dependency-type: direct:production
  update-type: version-update:semver-patch
  dependency-group: cargo
...

Signed-off-by: dependabot[bot] <support@github.com>
2024-06-10 22:15:09 -04:00
Amaan Qureshi a73191bf0e fix: better error when a supertype rule is invalid 2024-06-03 06:35:27 -04:00
Amaan Qureshi e553578696 feat: add fuzz subcommand 2024-05-30 23:00:45 -04:00
Amaan Qureshi fc146ad510 refactor: remove difference dependency 2024-05-25 23:04:28 -04:00
Amaan Qureshi c440f2a7c6 refactor: remove ansi_term dependency 2024-05-25 21:09:28 -04:00
Max Brunsfeld 38137c71b2 feat!: introduce tree-sitter-language crate for grammar crates to depend on
Co-authored-by: Conrad <conrad@zed.dev>
Co-authored-by: Marshall <marshall@zed.dev>
Co-authored-by: Amaan Qureshi <amaanq12@gmail.com>
2024-05-24 21:54:07 -04:00
ObserverOfTime 04b9eb5700 feat(bindings): update npm scripts 2024-05-24 17:35:12 -04:00
ObserverOfTime 629395fd58 feat(bindings): add node, python, swift tests 2024-05-24 16:55:05 -04:00
ObserverOfTime 055d0cbd34
feat(dsl)!: support other JS runtimes 2024-05-24 16:53:33 -04:00
ObserverOfTime d77279d2e3 style(bindings): fix indent & line endings
- Use 2 spaces for parser.c
- Don't force LF line endings
2024-05-24 15:45:48 -04:00
ObserverOfTime fd0e1c7b5b
feat(bindings): add query constants to python 2024-05-24 15:31:38 -04:00
Amaan Qureshi a88fc9cf63 fix: always reset to the first language when iterating over language attributes 2024-05-19 19:40:47 -04:00
ObserverOfTime 636801770e feat(cli): add debug build flag 2024-05-17 16:12:56 -04:00
Amaan Qureshi 8e8648afa9 fix(test): multi-grammar corpus tests are now in the repo root 2024-05-06 15:25:42 -04:00
Amaan Qureshi b1fd3214db feat(cli): bump unicode data to v15.1.0 2024-05-06 15:25:42 -04:00
Amaan Qureshi b40f342067
0.22.6 2024-05-05 16:47:18 -04:00
WillLillis 577d333849 feat(cli): add test listing and allow users to parse a specific test number 2024-05-05 16:35:17 -04:00
Amaan Qureshi 33045ee898
fix(test): allow newlines in between test name and attribute 2024-05-05 15:19:42 -04:00
Amaan Qureshi 1e219ff9eb fix(cli): properly account for multi-grammar repos when using docker to build a wasm parser 2024-05-05 14:56:42 -04:00
ObserverOfTime 572cdaa7c0 ci: fix address sanitizer step 2024-05-05 13:06:45 -04:00
ObserverOfTime a2d2da314d fix(cli): keep default cc flags in build 2024-05-05 13:06:45 -04:00
Amaan Qureshi 67a043911c
test: temporarily disable php test 2024-05-04 03:05:58 -04:00
Amaan Qureshi 4c083252ec fix(lib): advance the lookahead end byte by 4 when there's an invalid code point
This helps in the case where an edit was made in the middle of a code
point, but bytes 1-3 are valid, thus we could advance by at most 4 bytes
2024-04-30 20:55:43 -04:00
Amaan Qureshi 61d0395543 fix(lib): do not return field names for extras 2024-04-30 19:23:11 -04:00
WillLillis 946acfd70f feat(cli): support NO_COLOR
Co-authored-by: Amaan Qureshi <amaanq12@gmail.com>

This allows users to avoid colored output when NO_COLOR is set to 1.
2024-04-29 20:25:41 -04:00
Amaan Qureshi 627617edb4 refactor(tests): migrate remaining grammar.json tests to grammar.js 2024-04-29 00:01:35 -04:00
Amaan Qureshi 26fa3a76a5 fix(generate): take AsRef<Path> for the path parameter to avoid clones 2024-04-27 17:09:36 -04:00
ObserverOfTime 5aad87a74c fix(generate): don't check arbitrarily named dirs
i.e. check `bindings/swift` rather than `bindings/swift/TreeSitterFoo`
since the dir name may have different casing (e.g. `TreeSitterFOO`)
2024-04-27 17:09:36 -04:00
Amaan Qureshi 41308888fc fix: don't error out on package.json lookup errors if --no-bindings is passed 2024-04-27 16:29:26 -04:00
Amaan Qureshi 517e61b3e6 fix: improve error message when the tree-sitter field is malformed 2024-04-27 16:29:26 -04:00
vanaigr 90e0e28b95
feat: reverse iteration through node parents (#3214) 2024-04-23 15:19:57 +01:00
ObserverOfTime 83b6010461 feat(grammar): add "inherits" field if available 2024-04-14 15:59:01 -04:00
Max Brunsfeld cdd4688860 0.22.5 2024-04-14 10:17:04 -07:00
Max Brunsfeld 295344b142 fix: Avoid generating unused character set constants 2024-04-14 09:57:10 -07:00
Amaan Qureshi 9ba8f6dfe6 fix(cli): test parsing on windows 2024-04-12 21:09:28 -04:00
Max Brunsfeld 285257998c 0.22.4 2024-04-12 17:03:02 -07:00
Max Brunsfeld 63fa0f23f2 Include 2-character ranges in array-based state transitions 2024-04-12 16:40:04 -07:00
Max Brunsfeld 056237f18b Fix sorting of transitions within a lex state 2024-04-12 16:21:57 -07:00
Max Brunsfeld a3d338781b 0.22.3 2024-04-12 15:10:49 -07:00
Max Brunsfeld 7ec40b0ab4 Implement single-char state transitions using a static array and for loop
This reduces compile time, compared to generating many individual if statements.
2024-04-12 14:40:11 -07:00
Max Brunsfeld 3210c7e21f Avoid using a large character set constant when it doesn't reduce code size 2024-04-12 12:01:23 -07:00
Max Brunsfeld 3498498449 Merge branch 'master' into simpler-large-char-set-code 2024-04-12 10:03:46 -07:00
Max Brunsfeld 15fe07a20e Clean up code generation for lexer state transitions 2024-04-12 09:02:33 -07:00
Amaan Qureshi dcb7acede4 build: update emscripten version 2024-04-11 22:35:43 -04:00
Amaan Qureshi 96d18408a3 refactor(js): misc fixes & tidying 2024-04-11 22:35:43 -04:00
Amaan Qureshi abc7910381 refactor(rust): misc fixes & tidying 2024-04-11 22:35:43 -04:00
Amaan Qureshi 5825e24d56 style: wrap comments 2024-04-11 22:35:43 -04:00
Amaan Qureshi b35efa8f33 style: format imports 2024-04-11 22:35:43 -04:00
Amaan Qureshi a48054f1ae
fix: wrong flag check in build.rs 2024-04-11 22:31:10 -04:00
Max Brunsfeld 1f0707e1ac Fix clippy warnings 2024-04-11 16:29:59 -07:00
Max Brunsfeld b8701fcf18 Check EOF when checking a large char set that contains the null character 2024-04-11 16:19:21 -07:00
Max Brunsfeld be6e6d3708 Merge branch 'master' into simpler-large-char-set-code 2024-04-11 16:03:20 -07:00
Max Brunsfeld 18ea74ee12
Merge pull request #3280 from ObserverOfTime/reduce
refactor(parser): make REDUCE macro non-variadic
2024-04-11 15:39:28 -07:00
Ron Panduwana c051a90ac5 fix: insert "tree-sitter" section in current directory's package.json if it exists
Co-authored-by: ObserverOfTime <chronobserver@disroot.org>
2024-04-11 17:09:35 -04:00
ObserverOfTime 63babea301 fix: proper function prototypes 2024-04-11 16:28:21 -04:00
ObserverOfTime 50dfd409f6 fix(bindings): generate parser.c if missing 2024-04-11 16:28:21 -04:00
ObserverOfTime 7830877f63 fix(bindings): add utf-8 flag to python & node 2024-04-11 16:27:50 -04:00
ObserverOfTime 818cd8c291
refactor(parser): make REDUCE macro non-variadic 2024-04-11 20:47:08 +03:00
Amaan Qureshi 8bfe4e1f6b fix: add back build-wasm temporarily 2024-04-11 10:48:30 -04:00
Ron Panduwana 33de5ef849 fix: default output directory for build --wasm should use current_dir 2024-04-11 10:48:30 -04:00
Amaan Qureshi 895c7680e7 fix(windows): add /utf-8 flag for parsers using unicode symbols 2024-04-11 09:44:51 -04:00
Sebastian Lackner 5dc62cc828
fix(cli): fix mismatched parenthesis when accounting for && 2024-04-11 09:01:56 -04:00
Max Brunsfeld 3d088888f5 Derive large character sets from lex states for individual tokens 2024-04-10 16:53:39 -07:00
Max Brunsfeld be34bc9430 Identify large char sets for lexer using NFA transitions 2024-04-09 17:53:37 -07:00
Amaan Qureshi 21c06101aa fix(bindings): remove required platforms for swift 2024-04-08 17:56:05 -04:00
Amaan Qureshi 0d2dea9e0e fix(test): allow colons in test names 2024-04-08 17:56:05 -04:00
Amaan Qureshi a9172e0caa fix: add a semicolon after SKIP macros 2024-04-08 17:56:05 -04:00
Amaan Qureshi abed43a169 chore: clippy fix 2024-04-08 17:56:05 -04:00
ObserverOfTime 78b6067a5d fix(parser): fix variadic macro 2024-04-02 03:18:05 -04:00
Max Brunsfeld 39be6972fe Use static arrays and a fixed binary search for large char set checks 2024-03-29 23:00:48 -07:00
Amaan Qureshi 62cd13a3de test: add regression test for node parent + string bug 2024-03-20 19:23:08 -04:00
Max Brunsfeld 09b18fad5b
Merge pull request #3181 from tree-sitter/handle-wasm-oom
When loading languages via WASM, gracefully handle memory errors and leaks in external scanners
2024-03-18 13:15:06 -07:00
Max Brunsfeld fed9b98d6c Clean up wasm store construction, avoid hard-coding initial memory size
Retrieve the initial memory size from the stdlib's memory import type.
2024-03-17 10:20:18 -07:00
Max Brunsfeld 7a9b3076ef Handle memory errors occurring in wasm scanners
* In WASM, use a custom, simple malloc implementation that lets us
  expicitly reset the heap with a new start location.
* When a WASM call traps or errors, propagate that as a parse failure.
* Reset the WASM heap after every parse.

Co-authored-by: Conrad <conrad@zed.dev>
2024-03-17 10:19:42 -07:00
Amaan Qureshi fc15f62133
0.22.2 2024-03-17 07:31:58 -04:00
ObserverOfTime 4bbaee2f56 fix(lib): allow hiding symbols 2024-03-17 07:21:06 -04:00
ObserverOfTime 4b12eab927 feat(lib): implement Display for Node 2024-03-17 06:12:28 -04:00
Amaan Qureshi e8dbe011d3 test: fix header writes 2024-03-17 05:36:30 -04:00
Amaan Qureshi 754aa62e89 chore: turbofish styling 2024-03-17 05:36:30 -04:00
Amaan Qureshi 99b93d83a1 feat(cli)!: add a separate build command to compile parsers
This allows users to build parsers without having to run `test` or
`parse` to invoke the compilation process, and allows them to output the
object file to wherever they like. The `build-wasm` command was merged
into this by just specifying the `--wasm` flag.
2024-03-17 05:36:30 -04:00
ObserverOfTime 1ff40f5571 fix(lib): makefile installation 2024-03-12 18:14:58 -04:00
Amaan Qureshi 81d90c7cd8 fix(lib): makefile installation on macOS 2024-03-12 15:53:31 -04:00
Max Brunsfeld 2ff746742f
Merge pull request #3172 from tree-sitter/remove-which-crate
Remove dependency on which crate
2024-03-12 12:38:48 -07:00
Max Brunsfeld 99a720c968 Remove dependency on which crate 2024-03-12 12:19:27 -07:00
Amaan Qureshi ad07fa8a9e feat(bindings/rust): expose Parser::included_ranges 2024-03-12 02:29:35 -04:00
Amaan Qureshi 1c38d34dea
0.22.1 2024-03-10 17:59:12 -04:00
Amaan Qureshi cdc9fbb240
fix: cli build script behavior on release 2024-03-10 17:53:35 -04:00
Amaan Qureshi 0a5a564ea7
0.22.0 2024-03-10 17:15:08 -04:00
ObserverOfTime e9b3f65ceb fix(bindings): fix template oversights 2024-03-10 15:48:23 -04:00
Christopher Durham 78cc77e7b2 refactor!: remove redundant escape regex & curly brace regex preprocessing
The regex-syntax crate now natively supports literal escapes for all
ASCII characters except those in [0-9A-Za-z<>].
2024-03-10 14:47:11 -04:00
ObserverOfTime b60b2489aa feat(bindings): remove dsl types file 2024-03-10 10:06:17 -04:00
ObserverOfTime 072865e450 feat(bindings): add prebuildify to node
Co-Authored-By: Amaan Qureshi <amaanq12@gmail.com>
2024-03-10 10:06:17 -04:00
ObserverOfTime 69cf13bc05 feat(bindings): add peerDependencies for npm 2024-03-10 10:06:17 -04:00
Amaan Qureshi 17e50c4c57 fix: allow the regex v flag 2024-03-10 09:50:29 -04:00
Amaan Qureshi 2e56e94648 build: remove unused deps, bump deps, and bump MSRV to 1.74.1 2024-03-10 09:47:39 -04:00
Amaan Qureshi 4b578a3649 fix(generate): camel case name in Cargo.toml description 2024-03-06 19:53:51 -05:00
ObserverOfTime 2d652c90a7 fix(cli): only output the sources with --no-bindings 2024-03-06 13:56:40 -05:00
Amaan Qureshi 92675117a6 fix(generate): extern allocator functions for the template don't need to be "exported" 2024-03-05 11:19:06 -05:00
Amaan Qureshi 54a31069af fix: parsers should export the language function on windows 2024-03-05 11:19:06 -05:00
Amaan Qureshi 304f8b7c04 fix: don't use __declspec(dllexport) on windows 2024-03-04 13:23:06 -05:00
Amaan Qureshi f8c41f74f8 fix(bindings): insert types after main if it exists 2024-03-03 11:17:30 -05:00
Amaan Qureshi 57d01335c0 chore: delete binding_files.rs 2024-03-03 10:46:37 -05:00
Amaan Qureshi 27f52266ac feat: replace nan with node-addon-api and conditionally print logs 2024-03-03 10:46:37 -05:00
Segev Finer 30bb44f48a feat: add typings for the node bindings
Fixes #3072
2024-03-03 10:46:37 -05:00
geekvest b43e8ce902
docs: remove duplicate the's
Signed-off-by: geekvest <cuimoman@sohu.com>
2024-03-03 10:30:21 -05:00
Segev Finer 1dd35fe0e0
feat(node): type tag the language
Co-authored-by: ObserverOfTime <chronobserver@disroot.org>
2024-03-02 20:59:20 -05:00
ObserverOfTime 924c2b4425 chore(bindings): ignore more artifacts 2024-03-02 20:13:39 -05:00
ObserverOfTime f7c6dcadaa feat(bindings): add more make targets 2024-03-02 20:13:39 -05:00
Amaan Qureshi c66ed6a141
fix: and binding.gyp... 2024-03-01 11:02:33 -05:00
Amaan Qureshi 274d0cda0a fix: binding.cc overwrite should replace PARSER_NAME 2024-03-01 10:59:25 -05:00
Amaan Qureshi 6b2879144f build(deps): bump deps & lockfile 2024-02-29 02:17:30 -05:00
Amaan Qureshi 5a4765ca01 style: clippy lints 2024-02-29 02:17:30 -05:00
Amaan Qureshi 60a935139b refactor!: remove top-level corpus dir for tests
It's confusing to have tests in two different top-level directories when working between different grammars, and most of them use `test/corpus` which is more fitting, so time to go.
2024-02-29 02:17:30 -05:00
Amaan Qureshi 4ff33e81bb fix(assertions): case shouldn't matter for comment node detection 2024-02-29 02:17:30 -05:00
Amaan Qureshi 8c4861c186 feat(test): add attributes for corpus tests 2024-02-29 02:17:30 -05:00
ObserverOfTime b3c14c9295 build(bindings): make everything c11 2024-02-29 01:50:04 -05:00
ObserverOfTime b4b2d9cecc refactor: remove extern/const where possible 2024-02-29 01:50:04 -05:00
Amaan Qureshi d92a7a9690 test: add test case for parse stack merging with incorrect error cost bug 2024-02-28 08:51:28 -05:00
Segev Finer e87cf7ef15
refactor(bindings)!: convert node bindings to NAPI
Co-authored-by: Boris Verkhovskiy <boris.verk@gmail.com>
Co-authored-by: Amaan Qureshi <amaanq12@gmail.com>
Co-authored-by: ObserverOfTime <chronobserver@disroot.org>
2024-02-27 17:06:25 -05:00
Amaan Qureshi eb332ffa4d style(bindings): consistent wording 2024-02-27 16:07:38 -05:00
ObserverOfTime 502dacf220 refactor: rename TS_REUSE_ALLOCATOR flag
TREE_SITTER_REUSE_ALLOCATOR is more consistent
2024-02-27 15:54:38 -05:00
ObserverOfTime 46520eda58 build(bindings): metadata improvements 2024-02-27 15:54:38 -05:00
Amaan Qureshi f7c13406c9 build: add uninstall command 2024-02-27 15:54:38 -05:00
ObserverOfTime 799833f9cf build: use c11 everywhere
And improve the makefiles
2024-02-27 15:54:38 -05:00
ObserverOfTime 412a6a774e refactor(bindings): remove npmignore
Replace with package.json files
2024-02-27 06:22:00 -05:00
Amaan Qureshi eb35502f06 test: don't use TS_REUSE_ALLOCATOR on Darwin systems
For some reason, the linker seems to behave a bit differently with `-exported_symbols_list` on macOS vs other operating systems, so we'll disable this for now
2024-02-26 20:15:36 -05:00
Amaan Qureshi 8ae3870b51 fix(generate): add .npmignore, populate Swift's exclude list 2024-02-26 14:30:48 -05:00
ObserverOfTime 721eca2394 fix(bindings): editorconfig and setup.py fixes 2024-02-26 12:00:16 -05:00
Amaan Qureshi f1eecf9786 feat: expose the allocator and array header files for external scanners 2024-02-26 09:43:13 -05:00
Amaan Qureshi 9e5bf6591f feat: improve language bindings
Co-authored-by: ObserverOfTime <chronobserver@disroot.org>
2024-02-25 19:06:01 -05:00
Max Brunsfeld 29d3583bdf Use workspace dependencies for internal crates 2024-02-25 11:14:29 -08:00
Amaan Qureshi 068e29c265 build: unify crate versions via workspace 2024-02-24 18:30:04 -05:00
Amaan Qureshi 32c23b6c90 fix: wrap || comparison in parenthesis when && is used 2024-02-24 01:35:40 -05:00
Max Brunsfeld 1f751bbd5f
Merge pull request #2841 from segevfiner/patch-1
Make Node.js language bindings context aware
2024-02-23 11:23:11 -08:00
Amaan Qureshi f6b46440c2
fix: bump config 2024-02-21 15:26:25 -05:00
Amaan Qureshi 4408c1570e
fix: publish in the right order now 2024-02-21 15:24:47 -05:00
Amaan Qureshi a5b7c2a584
fix: publish 0.21.0 to registries 2024-02-21 15:11:37 -05:00
Max Brunsfeld 1c55abb530 0.21.0 2024-02-21 10:32:29 -08:00
Will Lillis f894a5350c
feat(cli): add optional config-path argument 2024-02-21 12:02:12 -05:00
Amaan Qureshi 58a4fcc792 chore: get rid of github_issue_test file 2024-02-21 12:01:25 -05:00
Amaan Qureshi 38efefd8bd style: cleaner cast 2024-02-21 12:01:25 -05:00
Amaan Qureshi 62578b8c6e feat(loader): add more commonly used default parser directories 2024-02-21 12:01:25 -05:00
Amaan Qureshi 167855b289 fix(test): edge case when parsing UNEXPECTED/MISSING nodes with an indentation level greater than 0 2024-02-21 12:01:25 -05:00
Amaan Qureshi a1a3903c10 fix(test): allow writing updates to tests without erroneous nodes instead of denying all of them if a single error is found 2024-02-21 12:01:25 -05:00
Amaan Qureshi b97208704b
fix(cli): don't use long for grammar_path
Co-authored-by: buckynbrocko <77247638+buckynbrocko@users.noreply.github.com>
2024-02-19 16:05:08 -05:00
Amaan Qureshi b40839cd72 style: prefer turbofish syntax where possible 2024-02-19 16:00:50 -05:00
Amaan Qureshi fd91404ab0 style: tidying 2024-02-19 16:00:50 -05:00
Amaan Qureshi d95fcc83b9 fix: remove redundant imports 2024-02-19 06:36:48 -05:00
Amaan Qureshi f526be8061 test: update html tests 2024-02-19 06:36:48 -05:00
Amaan Qureshi 5b299eafe5
fix: don't throw an error if the user uses map in the grammar 2024-02-18 00:26:14 -05:00
Amaan Qureshi da1f890752 chore: error out when multiple arguments are passed to token/token.immediate 2024-02-17 01:26:44 -05:00
Amaan Qureshi 8dd65ccbc0 refactor: &PathBuf -> &Path 2024-02-17 00:45:28 -05:00
Amaan Qureshi 03c5a8540d feat: better error info when a scanner is missing required symbols 2024-02-17 00:45:28 -05:00
Amaan Qureshi 6c0643f295
fix: always push the default files if there's no externals 2024-02-16 22:42:40 -05:00
Amaan Qureshi ef1b714e08 fix(cli): don't update tests automatically if parse errors are detected 2024-02-16 20:23:39 -05:00
Amaan Qureshi e32a7f3998 chore: clippy lints 2024-02-16 16:32:07 -05:00
Amaan Qureshi 4342efd57e feat: allow specifying an external scanner's files 2024-02-16 16:31:56 -05:00
Amaan Qureshi b6c75ccec1 chore: update relevant rust tests 2024-02-16 12:34:12 -05:00
Amaan Qureshi e996c32108 refactor!: remove the apply-all-captures flag, make last-wins precedence the default 2024-02-16 12:34:12 -05:00
Nickolay 6895b7a1e1
Add some documentation to the playground page
The minimal UI of the Playground could benefit from some documentation to make it easier for the newer users to understand what's going on. Also added a link to the new documentation from the local playground.

Closes https://github.com/tree-sitter/tree-sitter/issues/1305
2024-02-15 16:24:21 +01:00
Amaan Qureshi 74812ced1b chore: deprecate C++ scanners
C++ has been a headache to deal with throughout the ecosystem and for
several downstream projects. It is difficult to get working with WASM,
and induces potential issues with compilation on Windows. It has been
proven that writing scanners in C is a much better alternative, and is
the recommended way to write scanners now. C++ support will likely be
removed in 0.21.0
2024-02-14 15:43:53 -05:00
Amaan Qureshi d80d101e34 build: move common Cargo.toml keys into the workspace and inherit them 2024-02-14 14:56:23 -05:00
Amaan Qureshi d989b26587 chore: print out full compiler arguments ran when it fails 2024-02-14 13:19:06 -05:00
Amaan Qureshi 73f56bffa9 fix: sexp format edge case with quoted closed parenthesis 2024-02-13 18:31:28 -05:00
Amaan Qureshi 4303ab99c9 fix: properly handle Query.matches when filtering out results 2024-02-13 16:40:05 -05:00
Amaan Qureshi 7e0dd7b9c1 feat(cli): add an optional grammar-path argument for the playground 2024-02-13 16:28:54 -05:00
Amin Yahyaabadi 51c147053e
feat: error out if an empty string is in the extras array
This prevents never-ending loops in the parser
2024-02-13 15:00:48 -05:00
Amaan Qureshi 5ea0dbf77a chore: some more clippy lints 2024-02-13 03:33:07 -05:00
Amaan Qureshi a07f988905 refactor: extract regex check into a function and lower its precedence 2024-02-13 03:33:07 -05:00
Bedis Nbiba 7dd096c5f7
feat: implement first-line-regex 2024-02-13 01:51:41 -05:00
Amaan Qureshi 21f25a5305 feat: improve error message for files with an unknown grammar path 2024-02-12 17:17:37 -05:00
Amaan Qureshi 48deb309db chore(cli): warn users when a query path needed for a subcommand isn't specified in a grammar's package.json 2024-02-12 17:17:37 -05:00
Amaan Qureshi 3da79ba2b6 fix: update schema for regex flags 2024-02-12 15:39:14 -05:00
Amaan Qureshi 39df8e2833 chore(test): use different languages for async tests 2024-02-12 06:30:36 -05:00
Amaan Qureshi 7233c2f26f feat: use lockfiles to dedup recompilation 2024-02-12 06:30:36 -05:00
Amaan Qureshi e6d67ecde0 chore(wasm): use SIDE_MODULE=2 to silence warning 2024-02-11 20:18:30 -05:00
Yingdong Yang 0b7fc43828
fix(cli): installation via a HTTP tunnel proxy 2024-02-11 03:58:14 -05:00
Amaan Qureshi 4149ed4149 chore: provide a CLI flag to open log.html
On macOS, this was done by default regardless of what the user wants.
This was also not done on Windows or Linux. Instead, we now provide a
`--open-log` flag to open the log file in the default browser, and it
works on all platforms.
2024-02-11 02:28:34 -05:00
Amaan Qureshi ce5f5fffc1 chore(generate): dedup and warn about duplicate or invalid rules 2024-02-11 01:28:31 -05:00
Amaan Qureshi 78ccc39ca9
fix: properly error out when the word property is an invalid rule 2024-02-11 00:37:23 -05:00
Amaan Qureshi cca814afd2 chore: add java and tsx to corpus tests 2024-02-10 18:25:35 -05:00
Amaan Qureshi 3d68ca4583 fix: inherited grammar generation 2024-02-10 18:25:35 -05:00
Amaan Qureshi e4894ac8b4 chore(cli): use spawn to display emcc's stdout and stderr
Co-authored-by: Nbiba Bedis <bedisnbiba@gmail.com>
2024-02-09 14:17:34 +01:00
Amaan Qureshi dcb34b25ec fix: prettify xml output and add node position info 2024-02-08 18:09:10 -05:00
Amaan Qureshi a969fc428c chore: move dependencies into the workspace and inherit from there 2024-02-08 15:24:09 -05:00
Amaan Qureshi 7980669267 feat: support dot graph output on windows 2024-02-08 15:21:47 -05:00
Amaan Qureshi 214e27083a feat(cli): upgrade to clap v4 2024-02-08 05:39:41 -05:00
dundargoc df1fe842eb docs: various fixes
Closes https://github.com/tree-sitter/tree-sitter/issues/1317.
Closes https://github.com/tree-sitter/tree-sitter/issues/1752.
Closes https://github.com/tree-sitter/tree-sitter/issues/2439.

Co-authored-by: Simon Hengel <sol@typeful.net>
Co-authored-by: Akash Yadav <itsaky01@gmail.com>
Co-authored-by: Sebastiaan Speck <12570668+sebastiaanspeck@users.noreply.github.com>
Co-authored-by: Laytan Laats <laytanlaats@hotmail.com>
2024-02-08 00:08:59 +01:00
Amaan Qureshi 767db31114
fix: remove redundant code 2024-02-07 07:13:03 -05:00
Amaan Qureshi 993ee75d8c
fix: don't add extraneous exports to the json and add missing rules to the schema 2024-02-07 07:10:51 -05:00
Daumantas Kavolis 08d211a546
feat: improve time reports 2024-02-07 03:19:02 -05:00
Amaan Qureshi 59be1edaa1
refactor: swap &Vec[T] with &[T] where appropriate 2024-02-07 02:50:31 -05:00
buckynbrocko 8b38ab67de
chore(cli): reword test diff legend 2024-02-07 01:33:06 -05:00
buckynbrocko a4a7edc5af
feat(cli): add include/exclude options to the test subcommand 2024-02-07 01:04:54 -05:00
dundargoc c8bd6705cf
chore: clippy 2024-02-06 23:34:14 -05:00
Amaan Qureshi f601c87091
fix: do not skip over spaces that are surrounded by quotes 2024-02-06 19:00:43 -05:00
Amaan Qureshi a0ddae9d1a
Merge pull request #2724 from plugwash/master
cli - update to regex-syntax 0.8
2024-02-06 19:00:11 -05:00
dependabot[bot] e592833ea3
build(deps): bump which from 4.4.2 to 6.0.0
Bumps [which](https://github.com/harryfei/which-rs) from 4.4.2 to 6.0.0.
- [Release notes](https://github.com/harryfei/which-rs/releases)
- [Changelog](https://github.com/harryfei/which-rs/blob/master/CHANGELOG.md)
- [Commits](https://github.com/harryfei/which-rs/compare/4.4.2...6.0.0)

---
updated-dependencies:
- dependency-name: which
  dependency-type: direct:production
  update-type: version-update:semver-major
...

Signed-off-by: dependabot[bot] <support@github.com>
2024-02-05 21:53:01 +00:00
Amaan Qureshi 4153a1beaa
Merge pull request #2929 from tree-sitter/dependabot/cargo/toml-0.8.9
build(deps): bump toml from 0.7.8 to 0.8.9
2024-02-05 16:04:02 -05:00
Amaan Qureshi d86d4bb33b
Merge pull request #2930 from tree-sitter/dependabot/cargo/memchr-2.7.1
build(deps): bump memchr from 2.6.4 to 2.7.1
2024-02-05 16:03:29 -05:00
dependabot[bot] 65137d62e5
build(deps): bump memchr from 2.6.4 to 2.7.1
Bumps [memchr](https://github.com/BurntSushi/memchr) from 2.6.4 to 2.7.1.
- [Commits](https://github.com/BurntSushi/memchr/compare/2.6.4...2.7.1)

---
updated-dependencies:
- dependency-name: memchr
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
2024-02-05 19:59:19 +00:00
dependabot[bot] 86e522aa43
build(deps): bump toml from 0.7.8 to 0.8.9
Bumps [toml](https://github.com/toml-rs/toml) from 0.7.8 to 0.8.9.
- [Commits](https://github.com/toml-rs/toml/compare/toml-v0.7.8...toml-v0.8.9)

---
updated-dependencies:
- dependency-name: toml
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
2024-02-05 19:59:08 +00:00
Max Brunsfeld f4788b49c0 Merge branch 'master' into wasm-stdlib 2024-02-05 11:55:58 -08:00
Max Brunsfeld ad9091afe0 Fix wasm build errors due to builtin symbols 2024-02-05 10:19:34 -08:00
root b7d48b48fd
chore(cli): update to regex-syntax 0.8
regex-syntax has restructured the Ast enum a bit, rather than having a Class
member it now has seperate members for different types of Class.
2024-02-05 01:22:09 -05:00
Amaan Qureshi 5e8885ff11
chore(deps): remove atty 2024-02-05 00:46:38 -05:00
Amaan Qureshi 000c2f4dec
feat: allow the grammar to log to stdout 2024-02-05 00:46:34 -05:00
Amaan Qureshi 55afb4efaf
ci: remove unnecessary targets 2024-02-04 04:19:09 -05:00
Amaan Qureshi 04ff704bca
chore(cli): apply clippy fixes 2024-02-04 04:18:48 -05:00
Amaan Qureshi 1fb16a72ac
chore(loader): apply clippy fixes 2024-02-03 19:38:37 -05:00
Amaan Qureshi 1b44a6f912
chore(config): apply clippy fixes 2024-02-03 19:38:30 -05:00
Max Brunsfeld e054de4191 Return an error from build-wasm if scanner uses unavailable functions 2024-02-02 12:04:49 -08:00
Amaan Qureshi 9f2dc9d6b5
fix: rework parser.h includes for test grammars and multi-grammar repos 2024-02-02 10:42:39 -05:00
Amaan Qureshi 422e74fbdb
chore: update javascript-relevant tests 2024-02-02 08:58:22 -05:00
Max Brunsfeld 1d8975319c
Merge pull request #2840 from tree-sitter/language-reference-count
Introduce APIs for managing the lifetimes of languages, allow WASM languages to be deleted
2024-01-30 10:24:37 -08:00
Max Brunsfeld d351f81b4a Release stale instances from wasm store when languages are dropped 2024-01-29 10:17:49 -08:00
Steven Kalt d35efd4608
feat(cli): support building WASM via podman
Previously, `tree-sitter build-wasm` had the ability to build WASM
by using docker to pull in an image with a complete emscripten toolchain.
This commit adds the ability to use podman to do the same thing.

Using podman requires two notable changes:
1. Using the fully-qualified image name. Docker defaults to prepending
    `docker.io` to the image name, but podman does not.
2. Podman will mount the `/src/` volume as belonging to root unless
  `--userns=keep-id` is passed. I think podman's different
  volume-ownership is related to podman's daemonless execution and
  `--uidmap` functionality, but I'm not 100% sure.

To test, I ran
```sh
script/fetch-fixtures
script/generate-fixtures
script/generate-fixtures-wasm # <- the important one!
```

which worked as well as the docker version.
2024-01-29 00:50:32 -05:00
Max Brunsfeld c4142737ec Merge branch 'master' into language-reference-count 2024-01-25 12:43:56 -08:00
Amaan Qureshi 98be227227
0.20.9 2024-01-25 15:05:17 -05:00
Max Brunsfeld 3c66dd2d6c Add missing language return in ts_query_new
Co-authored-by: Antonio <antonio@zed.dev>
Co-authored-by: Mikayla <mikayla@zed.dev>
Co-authored-by: Joseph <joseph@zed.dev>
2024-01-25 11:06:54 -08:00
Amaan Qureshi b26e0a8ec0
fix: account for grammars in subdirectories, add typescript to test corpus 2024-01-25 14:02:12 -05:00
Max Brunsfeld 3139760fa9 Record allocations in wasm language error test 2023-12-31 10:05:06 -08:00
Segev Finer 4a42c6d5f1
Make Node.js language bindings context aware
They don't have any dynamic global data, so all it takes is just declaring them as such
2023-12-28 16:39:19 +02:00
Max Brunsfeld 82c1b5ead3 Fix compile error in parser hang test 2023-12-27 15:10:52 -08:00
Max Brunsfeld 4a8e4b1963 Allow wasm languages to be deleted 2023-12-27 15:00:16 -08:00
Max Brunsfeld da16cb1459 Introduce language ref-count management C APIs, remove Copy impl for Language in Rust 2023-12-27 14:59:16 -08:00
Andrew Hlynskyi d56b51a11d
Revert "Alt #2454" 2023-11-29 11:20:05 +02:00
Max Brunsfeld 034f0d0280
Merge pull request #1864 from tree-sitter/wasm-language
Add optional WASM feature to the native library, allowing it to run wasm-compiled parsers via wasmtime
2023-11-28 12:08:47 -08:00
Max Brunsfeld 13dd76e444 Return an informative error on failing to construct a WasmStore 2023-11-27 17:48:29 -08:00
Max Brunsfeld ac29eab5f9 Remove tests for LookaheadIterator compilation failures
These add noise when running tests. Let's not add unit tests for
compilation failurs.
2023-11-27 10:32:25 -08:00
Max Brunsfeld 6fd7a1e44e Return informative error when load_language fails 2023-11-26 12:15:05 -08:00
Max Brunsfeld e9289d3b30 Fix error when wrong language name is passed to load_language 2023-11-24 20:25:28 -08:00
Max Brunsfeld b59716600a Add a test that loads multiple languages in a wasm store 2023-11-24 20:03:54 -08:00
Amaan Qureshi 0ff28346be
Merge pull request #2714 from MrPrezident/test_point_range_captures_fix
fix "test_point_range_captures not working"
2023-11-12 21:09:09 -08:00
MrPrezident 3c4957e940 fix "test_point_range_captures not working"
Fix for https://github.com/tree-sitter/py-tree-sitter/issues/105
2023-11-12 20:58:51 -06:00
Max Brunsfeld d56d1a32ac Fix test grammar loading in unit test 2023-11-04 12:26:00 -07:00
Max Brunsfeld 473b3c8208 Add a CLI feature flag for wasm runtime support 2023-10-31 16:56:11 -07:00
Max Brunsfeld 3380e0eed7 Fix hang when printing dot graphs from the CLI 2023-10-31 15:59:37 -07:00
Max Brunsfeld 091652721e Use upstream wasmtime 2023-10-27 12:43:16 +01:00
Max Brunsfeld f4e2f68f14 Merge branch 'master' into wasm-language 2023-10-27 12:11:43 +01:00
Daumantas Kavolis e26e23fd0e
Fix formatting 2023-10-25 10:24:35 +03:00
Daumantas Kavolis e265929f90
Fix goto_previous_sibling with padded first children 2023-10-25 10:19:03 +03:00
Andrew Hlynskyi a5a7564818 chore(rust): add error reporting for position funcs 2023-10-05 17:24:01 +03:00
Andrew Hlynskyi c63f1680ad chore(rust): improve perf for position funcs 2023-10-05 17:24:01 +03:00
Andrew Hlynskyi d95836eb35 cicd: add en extra check for non matchable skips 2023-10-05 14:39:36 +03:00
Andrew Hlynskyi 82ddb3ddcc cicd: add skips for fragile corpus tests 2023-10-05 07:59:35 +03:00
Amaan Qureshi cc66895343
perf: cache the current language configuration to lookup later on 2023-09-21 00:52:50 -04:00
Amaan Qureshi ef9cabd4b5
fix: update javascript tests and use cpp/javascript master for fixtures 2023-09-20 11:31:53 -04:00
Andrew Hlynskyi 524bf7e2c6
Merge pull request #2607 from ahlinc/fix-zero-deallocs
fix: `dealloc` calls on zero pointers
2023-09-03 09:45:52 +03:00
Andrew Hlynskyi 9cc1daafca chore(ffi): remove enum name prefixes from all C enum values 2023-09-03 07:38:27 +03:00
Andrew Hlynskyi 7f7084c2cb chore(test): panic on zero pointer deallocs for alloc tracked scopes 2023-09-03 07:12:11 +03:00
Andrew Hlynskyi 67a5dbdd93 fix: dealloc calls on zero pointers 2023-09-03 06:53:18 +03:00
Andrew Hlynskyi 08ac19086b chore: simplify test case after query state improvements 2023-09-02 23:12:28 +03:00
Andrew Hlynskyi 52f7eaff31 chore(rust): make Query extra predicates state fully immutable 2023-09-02 23:12:28 +03:00
Amaan Qureshi dc5ec1cf53
refactor: remove &Option<T> where used 2023-09-01 17:23:39 -04:00
Amaan Qureshi c5cb27e522
docs: improve predicate docs 2023-08-31 16:01:37 -04:00
Amaan Qureshi 09ac28c77d
feat!: properly handle predicates used on quantified captures 2023-08-31 16:01:36 -04:00
Andrew Hlynskyi 756e51867d doc: fix cargo doc warnings 2023-08-28 23:09:37 +03:00
Andrew Hlynskyi 0862921537 doc: Include README as top-level module documentation for all crates 2023-08-28 23:09:37 +03:00
Andrew Hlynskyi cbce87dab1 chore: add an extra notes for hang tests 2023-08-28 14:16:36 +03:00
Andrew Hlynskyi a9c4965dd6 cicd: exclude hang tests for exotic arches and ASAN 2023-08-28 05:39:57 +03:00
Andrew Hlynskyi b205a1f5a2 Run parser hang test in a killable subprocess 2023-08-27 21:00:26 +03:00
Amaan Qureshi a4ea4737ac fix: do not increment current_included_range_index past included_range_count in __do_advance 2023-08-27 14:16:18 +03:00
Andrew Hlynskyi 60779cc1ac fix(gen): parser.c should include parser.h relatively 2023-08-26 20:57:08 +03:00
Amaan Qureshi 6d41d99990
Merge pull request #2559 from amaanq/silent-ignore-u
fix: ignore regex u flag
2023-08-25 19:25:15 -04:00
Amaan Qureshi 6969766664 fix: ignore regex u flag
It's needed for certain regex patterns in JS, and we can just silently ignore it.
2023-08-25 19:23:08 +03:00
Andrew Hlynskyi b3fef28a10 chore(gen): add parser.c enum names to be better discoverable 2023-08-25 19:11:42 +03:00
Andrew Hlynskyi fbfa58edc8 chore(gen): move external scanner stuff closer to the end of parser.c 2023-08-25 19:11:42 +03:00
Amaan Qureshi 1dbb986515 chore: add a test for an aliased anonymous symbol with flags 2023-08-23 16:55:12 +03:00
Andrew Hlynskyi 683fe442e4 fix(gen): cycle between aliases and anonymous symbols
An example of an error cycle in a `parser.c`:

```
static const TSSymbol ts_symbol_map[] = {
  ...
  [anon_sym_RBRACE] = anon_sym_RBRACE2,
  [anon_sym_RBRACE2] = anon_sym_RBRACE,
  ...
};
```
2023-08-23 16:51:05 +03:00
Amaan Qureshi e3a5863287
feat: add @injection.parent to inject an injection's node with the parent language 2023-08-21 01:08:17 -04:00
Andrew Hlynskyi ffae7d6115 fix: mark helper Rust funcs that receive raw pointers as unsafe 2023-08-20 02:12:51 +03:00
Amaan Qureshi ac579be788
fix(safety): mark functions that potentially deref a raw pointer as unsafe 2023-08-19 18:59:11 -04:00
Amaan Qureshi c37dd2458b
Merge pull request #2529 from amaanq/injection-self
feat: add `injection.self` to inject a node with itself
2023-08-19 12:43:10 -04:00
Andrew Hlynskyi 59b8eaf911 rust: pin serde version on 1.0.171 due to serde-rs/serde#2538 2023-08-19 16:15:47 +03:00
Amaan Qureshi 45313e0dfb
feat: add injection.self to inject a node with itself 2023-08-18 18:37:57 -04:00
Amaan Qureshi ce4a9ef4de
feat: allow specifying an input query-paths argument 2023-08-17 22:21:20 -04:00
Amaan Qureshi 9971e5d5f5
feat: allow specifying an input captures-path argument 2023-08-17 22:20:57 -04:00
Amaan Qureshi 458b5de0fc
feat: add any-of predicate 2023-08-17 22:20:57 -04:00
Amaan Qureshi 8eb92d1c64
feat: add an --apply-all-captures argument to highlight & test 2023-08-17 22:20:57 -04:00
Andrew Hlynskyi 6616d7deeb Change edit dumps format and add indexes for all corpus tests
The new dumped edits format is `edit.<SEED>.<TEST_INDEX>.<SEED_INDEX>.<TEST_NAME>`

To cleanup edits:
- Instead of the standard:
    > rm target/scratch/edit.*

- Use the following shell command:
    > find target/scratch/ -name 'edit.*' -delete
2023-08-18 00:02:21 +03:00
Andrew Hlynskyi caaa533b8d test: add TREE_SITTER_DUMP_EDITS env var to dump corpus edits
It dumps edits to the `target/scratch` folder in a format like `<SEED>.edit`
2023-08-17 20:55:28 +03:00
Andrew Hlynskyi 0dd85c8452 Add TREE_SITTER_GRAMMAR_DEBUG env var to use debug grammars in tests 2023-08-17 18:16:41 +03:00
Amaan Qureshi e0434327d0
fix(render): only output SPACE for strings that are just a space 2023-08-16 13:44:44 -04:00
Amaan Qureshi 28b831456e
Merge pull request #2500 from amaanq/dsl-update
feat: improve dsl definitions
2023-08-16 02:58:41 -04:00
Amaan Qureshi c008005f9a
feat: improve dsl definitions 2023-08-16 02:24:33 -04:00
Amaan Qureshi ece1060d2c
feat: warn users when using non-static functions that aren't needed for tree-sitter 2023-08-16 01:59:03 -04:00
Andrew Hlynskyi 029899f719 fix: dsl.d.ts - define previous param in rule callbacks 2023-08-15 23:28:54 +03:00
Amaan Qureshi 2d0a3d647b
Merge pull request #2491 from amaanq/sanitize
fix: replace & sanitize more characters
2023-08-13 20:15:20 -04:00
Amaan Qureshi 0b1b0d2fb7
fix: replace & sanitize more characters 2023-08-13 19:29:37 -04:00
Amaan Qureshi 318d4a705a fix: don't add flags if they're not present 2023-08-13 16:28:03 -04:00
Amaan Qureshi dee98e06e9
Merge pull request #2474 from amaanq/case-insensitive
feat!: support the case-insensitive regex flag
2023-08-11 23:12:15 -04:00
Andrew Hlynskyi 4a007259fc Fix warning from #2454 in more clear way 2023-08-10 03:59:34 +03:00
Brian Strauch d0afe1ad0a fix: pad hex numbers with zeros when writing colors
This solves a bug where a hex color with a zero can get truncated
2023-08-08 09:04:15 -04:00
Amaan Qureshi f35752e3ac
feat!: support the case-insensitive regex flag 2023-08-06 23:40:29 -04:00
Amaan Qureshi 96919cae5d
fix(generate): add Vertical Tab and Form Feed to the whitespace class 2023-08-06 20:41:09 -04:00
Andrew Hlynskyi e024653cb0
Merge pull request #2403 from jakesarjeant/master
feat(cli): add option to select JS runtime other than node
2023-08-03 22:29:22 +03:00
Jake Sarjeant 61b70943b1 feat(cli): add option to select JS runtime other than node 2023-08-03 21:34:47 +03:00
Eddie Hatfield 14aa23b1e1 feat: run highlight tests in subdirectories 2023-08-03 19:11:28 +01:00
Andrew Hlynskyi 485d192880 binding_rust: set_max_start_depth accepts optional to reset limit 2023-08-03 11:45:36 +03:00
Samuel Moelius 7b01d8ee05 Add test_query_max_start_depth_more 2023-08-03 11:45:34 +03:00
Samuel Moelius 41ec8b4166 Partially revert d4d5e29 2023-08-03 11:41:50 +03:00
Andrew Hlynskyi 7816397026 Add compile fail tests for LookaheadIterator 2023-08-03 03:49:57 +03:00