Commit graph

206 commits

Author SHA1 Message Date
Max Brunsfeld
af01846fd7 Add ts_tree_cursor_reset function 2018-10-21 10:39:05 -07:00
Max Brunsfeld
b29d0f622f Cram terminal subtree data into a 64-bit integer when possible 2018-09-17 18:52:34 -07:00
Max Brunsfeld
df3969e9d9 Invalidate tree's parent cache after an edit 2018-07-10 14:08:30 -07:00
Max Brunsfeld
fae7460541 Add ts_tree_language function
Co-Authored-By: Ashi Krishnan <queerviolet@github.com>
2018-06-21 12:54:19 -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
f3014cb767 Cache parent nodes to speed up ts_node_parent in common cases 2018-05-29 16:00:32 -07:00
Max Brunsfeld
80630ce504 Store nodes' public-facing positions, not pre-padding positions 2018-05-22 08:50:04 -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
043a2fc0d9 Assert absence of memory leaks in randomized multi-threaded tree test 2018-05-11 16:53:47 -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
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
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
eff7283325 Add assertion to satisfy clang static analyzer
Co-Authored-By: Rick Winfrey <rewinfrey@github.com>
2018-05-10 09:48:50 -07:00
Max Brunsfeld
59694e60fa Rename ts_tree_assign_parents -> ts_tree_balance 2018-05-10 09:13:46 -07:00
Max Brunsfeld
78d158899e Use atomic operations for updating syntax tree reference counts
Co-Authored-By: Rick Winfrey <rewinfrey@github.com>
2018-05-09 17:36:03 -07:00
Max Brunsfeld
5fa6d39578 Fix alias handling in ts_tree_string
Co-Authored-By: Rick Winfrey <rewinfrey@github.com>
2018-05-09 14:14:56 -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
f00d2ade46 Remove unused function 2018-04-09 19:37:53 -07:00
Max Brunsfeld
b0b8279c14 Preallocate tree arrays when popping from the stack 2018-04-09 18:14:17 -07:00
Max Brunsfeld
3672a8ad87 Remove unused tree method 2018-04-09 12:29:22 -07:00
Max Brunsfeld
33820253e8 Make stack_print_dot_graph function take a language as an argument 2018-04-09 12:29:22 -07:00
Max Brunsfeld
379a2fd121 Incrementally build a tree of skipped tokens
Rather than pushing them to the stack individually
2018-04-09 12:29:22 -07:00
Max Brunsfeld
94ed1b6964 Make array_splice take an array, not a pointer and length 2018-04-06 13:29:43 -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
1d9d6f37ad Introduce an error cost per error instance to favor fewer errors 2018-04-06 13:26:18 -07:00
Max Brunsfeld
80f856cef5 Maintain a total node count on every tree
This simplifies (and fixes bugs in) the parse stack's tracking of its
total node count since the last error, which is needed for error
recovery.
2018-04-06 13:26:18 -07:00
Max Brunsfeld
16a45d4aa4 Fix hole in logic for terminating tree balancing
It's important that the repetition nodes have a child count of 2,
because we assign to their second child. We could maybe generalize
this to allow balancing in the presence of 'extra' nodes like comments
and errors, but this might be complicated.
2018-02-16 12:44:30 -08:00
Max Brunsfeld
134c455b80 Simplify logic for terminating tree balancing 2018-02-12 12:13:21 -08:00
Max Brunsfeld
299a146b66 Balance repetition trees after parsing 2018-02-12 11:41:56 -08:00
Max Brunsfeld
919c9d8715 Ensure root node has a null parent 2018-01-23 17:20:15 -08:00
Max Brunsfeld
d3c85f288d Start work on repairing errors by inserting missing tokens 2017-12-29 15:11:00 -08:00
Max Brunsfeld
addeb6c4c1 Allocate and free trees using an object pool 2017-12-27 10:34:29 -08:00
Max Brunsfeld
0e69da37a5 Return a character count from the lexer's get_column method 2017-12-20 16:26:38 -08:00
Max Brunsfeld
a2670a39dc Avoid empty initializer list in global constant 2017-08-07 14:46:23 -07:00
Max Brunsfeld
89e250cd63 Avoid the name 'min' for a helper function
Windows automatically defines min or something.
2017-08-07 12:44:33 -07:00
Max Brunsfeld
b98669c7e6 Replace general array_reverse with ts_tree_array_reverse 2017-08-07 12:44:33 -07:00
Max Brunsfeld
ed11ddbd38 Explicitly compare regions between subtrees in get_changed_ranges 2017-08-06 17:16:29 -07:00
Max Brunsfeld
09f4796f6b Get tests passing w/ new alias API 2017-08-01 14:35:34 -07:00
Max Brunsfeld
cb5fe80348 Rename RENAME rule to ALIAS, allow it to create anonymous nodes 2017-07-31 16:41:11 -07:00
Max Brunsfeld
2437287e3e Remove rename symbol when reusing a previously-renamed tree 2017-07-21 16:24:33 -07:00
Max Brunsfeld
cf445da253 Allow renaming hidden rules 2017-07-21 15:58:01 -07:00
Max Brunsfeld
f33421c53e Fix incorrect node renames in the presence of extra tokens 2017-07-18 21:24:34 -07:00
Max Brunsfeld
9a04231ab1 Remove length restriction in external scanner serialization API 2017-07-17 17:12:36 -07:00
Max Brunsfeld
4b40a1ed6c Support anonymous tokens inside of RENAME rules 2017-07-14 10:19:58 -07:00
Max Brunsfeld
b3a72954ff Introduce RENAME rule type 2017-07-13 17:17:22 -07:00
Max Brunsfeld
d8e9d04fe7 Add PREC_DYNAMIC rule for resolving runtime ambiguities 2017-07-06 15:24:45 -07:00
Max Brunsfeld
009d6d1534 Improve heuristics for pruning parse versions based on errors
* Rewrite the error cost comparison in terms of explicit, discrete
conditions.
* Allow merging versions have different error costs.
* Store the depth of each stack version since the last error. Use this
state to prevent incorrect merging.
* Sort the stack versions in order of preference and put a hard limit on
the version count.
2017-06-29 15:00:20 -07:00