Commit graph

540 commits

Author SHA1 Message Date
Max Brunsfeld
e01ea9ff51
Merge pull request #1544 from mkvoya/dynamic-allocator
Allow to change the allocator dynamically
2021-12-28 13:39:11 -08:00
Florian Märkl
d5d99e0bfb Address feedback 2021-12-24 17:07:32 +01:00
Florian Märkl
2024f27534 Make SubtreeInlineData work on Big-Endian 2021-12-24 16:47:10 +01:00
Mingkai Dong
8e4d4ef8b9 Replace allocator struct with function pointers 2021-12-24 09:28:23 +08:00
Max Brunsfeld
ddeaa0c7f5
Merge pull request #1483 from furunkel/patch-1
Don't use zero maxlen for snprintf in ts_subtree__write_to_string
2021-12-23 10:52:20 -08:00
Mingkai Dong
486ea2569d Avoid allocator from being switched more than once 2021-12-18 16:45:18 +08:00
Mingkai Dong
b9b051e933 Remove ts_allocator from api.h
Since we have exposed the function to set allocator, we don't need to
expose the global variable in `api.h`.
2021-12-18 11:26:37 +08:00
Mingkai Dong
578bf74bf3 Add TSAllocator and ts_set_allocator in api.h 2021-12-18 09:53:58 +08:00
Mingkai Dong
b516f96f37 Fix declaration of ts_toggle_allocation_recording 2021-12-18 00:33:49 +08:00
Mingkai Dong
e742186c25 Allow to change the allocator dynamically 2021-12-17 20:16:20 +08:00
Max Brunsfeld
25f64e1eb6 Place tighter limits on the work done during query analysis 2021-12-09 22:18:21 -08:00
Max Brunsfeld
8de8c64c95 Remove unnecessary types from binding.rs 2021-12-09 21:02:15 -08:00
Max Brunsfeld
224e79ca27 web: Fix script directory that's passed to locateFile 2021-11-22 15:56:26 -08:00
Max Brunsfeld
42360fc003 Bump library versions to 0.20.1 2021-11-21 12:33:12 -08:00
Max Brunsfeld
26dac9b2dd Fix query bugs revealed by randomized tests
* Fix bugs related to named wildcard patterns vs regular wildcard patterns.
* Fix handling of extra nodes during query analysis. Previously, the
expected child_index was updated incorrectly after an extra node,
leading to false "impossible pattern" errors.
* Refine logic for avoiding unnecessary state-splitting due to fallible steps.
Compute *two* different analysis results related to step fallibility:
  * `root_pattern_guaranteed` which, like before, summarizes whether the
    entire pattern is guaranteed to match once this step is reached.
  * `parent_pattern_guaranteed` - which just indicates whether the
    immediate parent pattern is guaranteed. This is now used when
    deciding whether it's necessary to split a match state.
2021-11-21 12:02:58 -08:00
Max Brunsfeld
fea3eca312 Improve query execution logging 2021-11-21 11:39:29 -08:00
Max Brunsfeld
142f4b6438 Rename Query::step_is_definite -> is_pattern_guaranteed_at_step 2021-11-21 11:37:52 -08:00
Max Brunsfeld
4e2e059865 Ensure 'extra' bit is set correctly when reusing a node
Fixes #1444
2021-11-19 12:43:55 -08:00
Max Brunsfeld
1fe0420f0f Avoid unnecessary stack entries in query analysis
When descending into a hidden child rule, the current stack entry
can be reused if it is currently at the end of its rule.

This fixes a test failure when analyzing a Ruby query. The
failure was introduced due to some changes to the Ruby grammar.
This optimization allows us to impose a _smaller_ limit on
the stack size, which should make query analysis faster and
more memory-efficient.
2021-11-19 11:04:36 -08:00
furunkel
f78ad7162f
Don't use zero maxlen for snprintf in ts_subtree__write_to_string
It seems that (some implementations of?) `snprintf` returns -1 and sets `errno` to `EINVAL` if a `maxlen` of zero is passed. This causes the count to underflow and `ts_subtree__write_to_string` returns a gigantic size which the succeeding malloc will refuse to allocate.
2021-11-12 20:52:15 +01:00
Max Brunsfeld
ddb12dc0c6 query: Return error on unclosed tree pattern in alternation
Fixes #1436
2021-10-12 09:20:43 -07:00
Max Brunsfeld
e78413832b Restructure test suite's allocation recording so that tests can run in parallel 2021-10-11 17:24:37 -07:00
Max Brunsfeld
fe29bc8c19 Tweak comment formatting in api.h so bindgen doesn't create a doctest 2021-10-11 17:23:44 -07:00
Wilfred Hughes
f17f08bbef Add missing word in doc comment 2021-09-30 21:53:41 -07:00
Max Brunsfeld
561dfe3a2d
Merge pull request #1394 from tree-sitter/fix/query-predicates-with-alternations
fix(cli): Panic on queries containing alternation with predicates
2021-09-24 08:56:23 -07:00
Andrew Hlynskyi
d973527964 binding(rust): Mark set_cancellation_flag self as mutable 2021-09-21 23:03:50 +03:00
Andrew Hlynskyi
79b2bf1c30 fix(wasm): Fix predicates in alternations, resolves #1392 2021-09-21 21:13:41 +03:00
Andrew Hlynskyi
b324d0802a fix(cli): Panic on queries containing alternation with predicates
`QuearyMatch::satisfies_text_predicates()` was changed to pass
captures that don't relate to a checked predicate. This allows
predicates in inner alternations for queries.

Refs #1392
2021-09-21 19:51:30 +03:00
Andrew Hlynskyi
ae12ff81b5 feat(rust): Add an id() method for QueryMatch
Refs #1372
2021-09-14 19:08:29 +03:00
Max Brunsfeld
22a5cfbe10 Assign ids to query matches only when the matches are returned
Refs #1372
2021-09-13 12:39:48 -07:00
Max Brunsfeld
5c2ebf093b Include memmove symbol in wasm build 2021-09-10 15:21:55 -07:00
Alon Hershenhorn
b239583510 Fix typo in API documentation
Fix small typo in ts_tree_cursor_current_field_id documentation.
2021-09-10 12:28:23 -07:00
Andrew Hlynskyi
52e6c900c3 fix(lib): fix segfault on ts_query_new with incompatible grammar version, close #1318 2021-09-03 14:24:18 +03:00
Max Brunsfeld
0e26fbe5e6
Merge pull request #1367 from jrieken/moduleInit
Allow to pass Module object to init-function
2021-08-30 09:32:43 -07:00
Max Brunsfeld
eeda44d837
Merge pull request #1368 from jrieken/dtsTweaks
Fixes and additions to tree-sitter-web.d.ts
2021-08-30 09:17:53 -07:00
Johannes Rieken
3e9874df7f Don't confuse terser with object spread 2021-08-30 14:56:28 +02:00
Johannes Rieken
e7a8e73bbf fixes and additions to tree-sitter-web.d.ts 2021-08-30 14:47:47 +02:00
Johannes Rieken
12d727fd49 mix init options in the Module-global 2021-08-30 14:16:41 +02:00
Andrew Hlynskyi
f15700c6bd chore(web): Add the LICENSE file to the web-tree-sitter npm package 2021-08-22 03:13:46 +03:00
Andrew Hlynskyi
7f538170bf fix(parser): count rows in the debug log from 0 2021-07-15 11:47:14 +03:00
Max Brunsfeld
190fee3625
Merge pull request #1177 from forbisc/master
update set_included_ranges to modify extent if the current position is at the very beginning of the range.
2021-06-30 08:38:59 -07:00
Max Brunsfeld
be69777350 libs: 0.20.0 2021-06-29 17:18:22 -07:00
Andrew Hlynskyi
a286f831c7 Bump Emscripten version to 2.0.24 2021-06-30 01:06:33 +03:00
Cameron Forbis
9182ebef86 update set_included_ranges to modify extent if the current position is at the very beginning of the included range 2021-06-17 16:42:25 -07:00
Max Brunsfeld
ad8bd3c3f5
Merge pull request #1120 from claudi/cast-printed-pointers
Fix: cast pointers to `void *` when printing
2021-06-07 09:09:54 -07:00
Max Brunsfeld
f3ea60e23f Merge branch 'master' into query-cursor-api 2021-06-02 11:51:26 -07:00
Douglas Creager
cc20708a33 query: Minor cleanups 2021-06-02 14:16:04 -04:00
Douglas Creager
47f1af818a query: Remove bits.h 2021-06-02 14:14:57 -04:00
Douglas Creager
ad3907c2a6 wasm: Add matchLimit option to query methods
This exposes the new configurable match limits for query cursors.
2021-06-02 13:51:00 -04:00
Douglas Creager
1f6eac555c query: Use uint32_t for capture list IDs 2021-06-02 13:19:52 -04:00