Commit graph

93 commits

Author SHA1 Message Date
Max Brunsfeld
9e8bec458d Add ts_node_edit API 2018-07-11 16:17:46 -07:00
Max Brunsfeld
df3969e9d9 Invalidate tree's parent cache after an edit 2018-07-10 14:08:30 -07:00
Max Brunsfeld
83f88164aa Fix end positions of tokens at the end of included ranges
Co-Authored-By: Ashi Krishnan <queerviolet@github.com>
2018-07-09 10:23:25 -07:00
Max Brunsfeld
5ab6401478 Fix TreeCursor bugs
* ts_tree_cursor_goto_first_child_for_byte failed to find the child
  in some cases
* ts_tree_cursor_goto_parent did not handle aliased invisible parent
  nodes

Co-Authored-By: Ashi Krishnan <queerviolet@github.com>
2018-06-28 16:17:16 -07:00
Max Brunsfeld
80cab8fd8a Make the empty chunk 2 bytes long, for UTF16 support 2018-06-25 17:46:23 -07:00
Max Brunsfeld
89b6a14d9f Allow creating a tree cursor starting at any node, not just the root
Co-Authored-By: Ashi Krishnan <queerviolet@github.com>
2018-06-21 12:54:04 -07:00
Max Brunsfeld
a6451f9b4f Add ts_parser_set_include_ranges function
Co-Authored-By: Ashi Krishnan <queerviolet@github.com>
2018-06-20 13:37:43 -07:00
Max Brunsfeld
6632cb3d5c Include byte offsets in TSRange
Co-Authored-By: Ashi Krishnan <queerviolet@github.com>
2018-06-20 11:46:44 -07:00
Max Brunsfeld
d7c1f84d7b Remove resume method, make parse resume by default
Also, add a `reset` method to explicitly discard an outstanding parse.

Co-Authored-By: Ashi Krishnan <queerviolet@github.com>
2018-06-19 15:33:29 -07:00
Max Brunsfeld
b0b3b2e5f3 Consolidate TSInput interface down to one function 2018-06-19 09:34:40 -07:00
Max Brunsfeld
fb14cb0737
Merge pull request #172 from tree-sitter/cache-parent-nodes
Cache parent nodes to speed up `ts_node_parent` in common cases
2018-05-29 17:21:24 -07:00
Max Brunsfeld
f3014cb767 Cache parent nodes to speed up ts_node_parent in common cases 2018-05-29 16:00:32 -07:00
Max Brunsfeld
6fca8f2f4d Make ts_compile_grammar take an optional log file, start logging to it 2018-05-24 16:01:14 -07:00
Max Brunsfeld
69d8c6f5e6 Check that language is present in both parse() and resume() 2018-05-23 15:41:16 -07:00
Max Brunsfeld
e16f0338d6 Add APIs for pausing a parse after N operations and resuming later 2018-05-23 15:02:39 -07:00
Max Brunsfeld
c0763c69c4 Fix handling of aliases in TreeCursor 2018-05-22 14:43:21 -07:00
Max Brunsfeld
1fece241aa Add ts_parser_set_enabled API 2018-05-21 17:28:12 -07:00
Max Brunsfeld
78f28b14ce Remove unused field 2018-05-18 14:27:52 -07:00
Max Brunsfeld
074c051094 Change the TSInputEdit struct to work with old/new start and end positions 2018-05-17 11:14:51 -07:00
Max Brunsfeld
e3670be42f Avoid one heap allocation when instantiating a TSTreeCursor 2018-05-16 16:05:08 -07:00
Max Brunsfeld
6fc8d9871c Hide the details of TSNode's fields in the public API 2018-05-16 15:44:04 -07:00
Max Brunsfeld
ebddb1a0b5 Add ts_tree_cursor_goto_first_child_for_byte method
Atom needs this for efficiently seeking to the leaf node at a given position,
visiting all of its ancestors along the way.
2018-05-16 13:51:21 -07:00
Max Brunsfeld
32c06b9b59 Make multi-threaded test work on windows
Co-Authored-By: Rick Winfrey <rewinfrey@github.com>
2018-05-11 17:10:05 -07:00
Max Brunsfeld
043a2fc0d9 Assert absence of memory leaks in randomized multi-threaded tree test 2018-05-11 16:53:47 -07:00
Max Brunsfeld
a3e08e7c31 Add randomized multi-threaded tests on parse trees
Co-Authored-By: Rick Winfrey <rewinfrey@github.com>
2018-05-11 16:10:36 -07:00
Max Brunsfeld
fe53506175 Declare subtrees as const wherever possible
Co-Authored-By: Rick Winfrey <rewinfrey@github.com>
2018-05-11 15:06:13 -07:00
Max Brunsfeld
20c183b7cd Rename ts_subtree_make_* -> ts_subtree_new_* 2018-05-11 13:02:12 -07:00
Max Brunsfeld
bf1bb1604f Rename TSExternalTokenState -> ExternalScannerState 2018-05-11 12:57:41 -07:00
Max Brunsfeld
199a94cc26 Allow the parser to print dot graphs to any file 2018-05-11 12:48:51 -07:00
Max Brunsfeld
e75ecd1bb1 Rework API completely 2018-05-11 10:46:13 -07:00
Max Brunsfeld
35510a612d Rename Tree -> Subtree 2018-05-10 15:11:14 -07:00
Max Brunsfeld
61327b627a Add a unit test asserting that ts_tree_edit doesn't mutate the tree
Co-Authored-By: Rick Winfrey <rewinfrey@github.com>
2018-05-10 12:28:16 -07:00
Max Brunsfeld
09e663c7d1 Make ts_tree_edit return a new tree rather than mutating its argument
Co-Authored-By: Rick Winfrey <rewinfrey@github.com>
2018-05-10 12:23:05 -07:00
Max Brunsfeld
df79ff5997 Refactor ts_tree_edit
Co-Authored-By: Rick Winfrey <rewinfrey@github.com>
2018-05-10 12:04:18 -07:00
Max Brunsfeld
666dfb76d2 Remove document parameter from ts_node_type, ts_node_string
Co-Authored-By: Rick Winfrey <rewinfrey@github.com>
2018-05-09 16:47:47 -07:00
Max Brunsfeld
92255bbfdd Remove document parameter from ts_node_type, ts_node_string
Co-Authored-By: Rick Winfrey <rewinfrey@github.com>
2018-05-09 15:28:28 -07:00
Max Brunsfeld
b06747b6ca Remove stale unit tests
Co-Authored-By: Rick Winfrey <rewinfrey@github.com>
2018-05-09 14:14:42 -07:00
Max Brunsfeld
973e4a44f0 Start work on removing parent pointers
Co-Authored-By: Rick Winfrey <rewinfrey@github.com>
2018-05-09 12:22:19 -07:00
Max Brunsfeld
d5cfc06fa2 Fix unit test for invalid utf8 at EOF 2018-04-17 17:33:45 -07:00
Max Brunsfeld
09be0b6ef5 Store trees' children in TreeArrays, not w/ separate pointer and length 2018-04-06 13:26:18 -07:00
Max Brunsfeld
a6cf2e87e7 Fix halt_on_error tests 2018-04-06 13:26:18 -07:00
Max Brunsfeld
dbe77e7199 Simplify testing-only ts_stack_iterate function 2018-03-29 17:50:07 -07:00
Max Brunsfeld
5520983144 Clean up Stack API
* Remove StackPopResult
* Rename top_state() -> state()
* Rename top_position() -> position()
* Improve docs
2018-03-29 17:37:54 -07:00
Max Brunsfeld
ee995c3d6b Avoid redundant retains/releases by giving ts_stack_push move semantics 2018-03-29 17:18:43 -07:00
Max Brunsfeld
0810971f3e 🔥 symbol iterator API
This idea was never fully baked.
2018-03-08 14:16:37 -08:00
Max Brunsfeld
e927d02f43 Allow reusing leaf nodes unless the next leaf has changes 2018-03-07 17:44:54 -08:00
Max Brunsfeld
52087de4f0 Remove the concept of fragile reductions
They were a vestige of when Tree-sitter did sentential form-based
incremental parsing (as opposed to simply state matching). This was
elegant but not compatible with GLR as far as I could tell.
2018-03-02 14:51:54 -08:00
Max Brunsfeld
82c7e170b3 Fix case where loop was created in the parse stack
Fixes #133
2018-03-02 09:05:20 -08:00
Max Brunsfeld
46dcd53090 Do not insert missing tokens if halt_on_error option is passed 2018-01-24 14:04:55 -08:00
Max Brunsfeld
315dff3285 Add an API for getting a node's child index 2018-01-09 14:01:36 -08:00