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.
This commit is contained in:
Max Brunsfeld 2017-06-29 14:58:20 -07:00
parent 445be0736a
commit 009d6d1534
9 changed files with 237 additions and 145 deletions

View file

@ -304,16 +304,6 @@ bool ts_tree_eq(const Tree *self, const Tree *other) {
return true;
}
bool ts_tree_tokens_eq(const Tree *self, const Tree *other) {
if (self->child_count > 0 || other->child_count > 0) return false;
if (self->symbol != other->symbol) return false;
if (self->padding.bytes != other->padding.bytes) return false;
if (self->size.bytes != other->size.bytes) return false;
if (self->extra != other->extra) return false;
if (!ts_tree_external_token_state_eq(self, other)) return false;
return true;
}
int ts_tree_compare(const Tree *left, const Tree *right) {
if (left->symbol < right->symbol)
return -1;