Commit graph

47 commits

Author SHA1 Message Date
Max Brunsfeld
64fc944202 Fix missing criteria for leaf node reuse 2019-06-20 15:02:20 -07:00
Max Brunsfeld
28011b1e60 Add ts_node_is_extra API 2019-06-19 15:58:29 -07:00
Andrey Zaytsev
7f2233ddaf Ts tree cursor copy (#363)
* add ts_tree_cursor_copy fn

* indentation
2019-06-16 10:52:37 -07:00
Max Brunsfeld
0e046fc6c0 Fix bug when the assert macro is disabled
Fixes #364
2019-06-14 14:23:38 -07:00
Max Brunsfeld
80b785daee Improve behavior of node descendant queries with single positions 2019-06-13 10:53:59 -07:00
Antonio Scandurra
25b0fbd679 Don't use clock_gettime on macOS
This commit stops using the monotonic clock API on macOS because it is 
supported only on macOS >= 10.12. Instead, it uses the fallback clock 
APIs for platforms without monotonic clock support.

The use of `clock_gettime` was causing issues on Atom because, even 
though we build it on a new macOS version supporting such API, some 
users may run Atom on older versions of macOS. On those platforms, Atom 
would crash whenever opening a file parsed with a tree-sitter grammar.
2019-06-12 19:03:46 +02:00
Patrick Thomson
6e2a60629c Make ts_tree_delete and ts_parser_delete NULL-safe.
Historically, `free(3)`-style functions have been NULL-safe, to make
resource handling functions more robust. This doesn't seem to be the
case with tree-sitter's `ts_tree_delete` and `ts_parser_delete` C
functions, which immediately dereference the passed pointer. This
leads to complexity in client libraries that have to ensure that trees
and parsers are cleaned up correctly.

This patch adds NULL checks to `parse_delete` and `tree_delete`. They
should have negligable performance impacts, since null checks are fast.

I didn't change the internal _delete functions, as arguably those
being NULL-unsafe is a feature, not a bug.
2019-05-30 11:47:56 -04:00
Max Brunsfeld
58e1a0fee7 In node range queries, treat the end coordinate as exclusive 2019-04-26 13:36:28 -07:00
Max Brunsfeld
bc5e71bcc2 Fix handling of zero-width external tokens at beginning of document
Fixes #316
2019-04-08 15:01:52 -07:00
Max Brunsfeld
5035e194ff Merge branch 'master' into node-fields 2019-03-26 11:58:21 -07:00
Marijn Haverbeke
fe5aa46d8d Swap two incorrectly placed comments 2019-03-26 16:53:35 +01:00
Max Brunsfeld
82358d3f2f
Merge pull request #307 from tree-sitter/pointer-sized-cancellation-flag
Make the cancellation flag a size_t, not a uint32_t
2019-03-22 12:30:39 -07:00
Max Brunsfeld
5a59f19b69 Use explicit syntax for functions with no parameters 2019-03-21 16:06:06 -07:00
Max Brunsfeld
74d154c706 Use CLOCK_MONOTONIC on platforms that support it
This way, timeouts will apply even if the current process
is starved for CPU.
2019-03-21 14:13:42 -07:00
Max Brunsfeld
0ccb910922 Use a size_t instead of a uint32_t for cancellation flag 2019-03-21 11:26:05 -07:00
Max Brunsfeld
2fd9ffa8e5 Add --cancel flag to parse command to allow command-line testing 2019-03-21 10:56:32 -07:00
Max Brunsfeld
3340168097 Fix backwards logic for cancellation flag 2019-03-20 17:02:07 -07:00
Max Brunsfeld
0ae304f582 Lib: Rework the API for cancelling a parse
Also, use beta on CI until atomic::AtomicU32 lands in stable.
2019-03-18 09:51:21 -07:00
Jacob Mitchell
c8d040ca26 Use 1-indexed rows in CLI and log output (resolves #287) 2019-03-14 22:21:19 -07:00
Max Brunsfeld
1aaad66a03
Merge pull request #301 from tree-sitter/clock-based-timeouts
Replace operation limit API with a clock-based timeout API
2019-03-14 16:50:44 -07:00
Max Brunsfeld
23dfde067e Get disabled debugging code compiling again
Fixes #303
2019-03-14 16:50:10 -07:00
Max Brunsfeld
59fd8528d4 Avoid division rounding errors w/ clock counts 2019-03-14 15:53:45 -07:00
Max Brunsfeld
006a931ab8 Tests: Prevent array reallocations during ts_stack_print_dot_graph
When debugging a test with 'script/test -D', the DOT-graph generation
code was sometimes causing reallocations that were not captured by the
allocation tracker, because we explicitly disable allocation-tracking
for that method in order to reduce noise when debugging memory leaks.

By growing the relevant array *prior* to turning off allocation
tracking, we can ensure that it is not reallocated within that function,
avoiding false positive memory leak errors.

Fixes #302
2019-03-14 13:59:12 -07:00
Max Brunsfeld
88e3907cc0 Use QueryPerformanceFrequency as clock on windows 2019-03-14 13:42:31 -07:00
Max Brunsfeld
430f8874ea Lib: reduce frequency of clock calls during parsing 2019-03-14 11:52:25 -07:00
Max Brunsfeld
cddb3e416d Replace operation limit API with a clock-based timeout API 2019-03-14 11:13:38 -07:00
Joshua Warner
6f71b8840b Fix warning about undefined snprintf 2019-03-08 21:22:13 -08:00
Max Brunsfeld
65d1ce8593 lib: Include fields in ts_node_string output
This allows you to assert about fields in tests. But if your test 
s-expression does *not* include fields, the fields will be stripped from 
the regexp before comparison.
2019-02-13 09:47:21 -08:00
Max Brunsfeld
9f608435ee Fix errors in when languages have no fields 2019-02-12 17:20:12 -08:00
Max Brunsfeld
56309a1c28 Generate node-fields.json file 2019-02-12 11:06:18 -08:00
Max Brunsfeld
79d90f0d3e Restore naming of alias sequence lengths
Fields aren't stored in sequences now, so the max length
is back to being just for aliases.
2019-02-08 16:14:18 -08:00
Max Brunsfeld
d8a2c0dda2 Use a separate type for storing field map headers 2019-02-08 16:06:29 -08:00
Max Brunsfeld
1d1674811c Fully implement ts_node_child_by_field_id 2019-02-08 15:16:56 -08:00
Max Brunsfeld
18a13b457d Get basic field API working 2019-02-08 15:16:56 -08:00
Max Brunsfeld
bf4e1304f8 Start work on new ref API, for giving names to nodes' children
Co-Authored-By: Ayman Nadeem <aymannadeem@gmail.com>
2019-02-08 15:16:56 -08:00
Max Brunsfeld
a85ed086cc Define UTF8PROC_STATIC macro in the source
This way, there's one less flag you have to pass when building the
library on windows.
2019-02-06 10:42:29 -08:00
Max Brunsfeld
b925f6e136 Avoid using fall-through in get_changed_ranges
Also, clean up the that function a bit and add a few comments.
2019-02-06 10:24:15 -08:00
Vicent Marti
9a951c859d lib: Fix importing fdopen in parser.c 2019-02-06 10:10:38 +01:00
Vicent Marti
02bc9b5829 lib: Silence explicit fallthrough warning in GCC 2019-02-06 10:10:18 +01:00
Max Brunsfeld
d192eda9cf Remove stray word 'runtime' from comment 2019-01-30 21:43:44 -08:00
Max Brunsfeld
213ccfd3a4 Update trees' metadata bits when setting symbol back to word token 2019-01-29 15:30:13 -08:00
Max Brunsfeld
233d616ebf Add random mutation tests 2019-01-25 12:05:21 -08:00
Max Brunsfeld
196339aaa9 Assert no memory leaks by stubbing malloc/free in the test suite 2019-01-21 14:22:35 -08:00
Max Brunsfeld
0f2347b318 Just call the C lib 'the library' everywhere, don't call it a 'runtime' 2019-01-10 15:22:39 -08:00
Max Brunsfeld
98807d2053 Add debug and debug-graph flags to parse and test commands 2019-01-08 21:03:51 -08:00
Max Brunsfeld
dd416b0955 Update include paths to not reference 'runtime' directory 2019-01-04 17:33:34 -08:00
Max Brunsfeld
47607cecf4 Reorganize repo, add rust CLI and binding code, 2019-01-04 17:31:49 -08:00