Base error costs on top-level trees skipped and lines of text skipped
Rather than on the total number of tokens skipped
This commit is contained in:
parent
27c9cb4175
commit
31d1160e21
3 changed files with 10 additions and 22 deletions
10
spec/fixtures/error_corpus/javascript_errors.txt
vendored
10
spec/fixtures/error_corpus/javascript_errors.txt
vendored
|
|
@ -56,12 +56,12 @@ if ({a: 'b'} {c: 'd'}) {
|
|||
|
||||
(program
|
||||
(if_statement
|
||||
(object (pair (identifier) (string)))
|
||||
(ERROR (object (pair (identifier) (string))))
|
||||
(object (pair (identifier) (string)))
|
||||
(statement_block
|
||||
(ERROR (function
|
||||
(formal_parameters (identifier))
|
||||
(statement_block (expression_statement (identifier)))))
|
||||
(expression_statement (function
|
||||
(formal_parameters (identifier))
|
||||
(statement_block (expression_statement (identifier))))))))
|
||||
(statement_block (expression_statement (identifier))))
|
||||
(ERROR (function
|
||||
(formal_parameters (identifier))
|
||||
(statement_block (expression_statement (identifier)))))))))
|
||||
|
|
|
|||
|
|
@ -114,7 +114,7 @@ static StackNode *stack_node_new(StackNode *next, TSTree *tree, bool is_pending,
|
|||
ts_tree_retain(tree);
|
||||
if (state == TS_STATE_ERROR) {
|
||||
if (!tree->extra) {
|
||||
node->error_cost++;
|
||||
node->error_cost += 1 + tree->padding.rows + tree->size.rows;
|
||||
}
|
||||
} else {
|
||||
node->error_cost += tree->error_size;
|
||||
|
|
|
|||
|
|
@ -112,20 +112,6 @@ recur:
|
|||
}
|
||||
}
|
||||
|
||||
static void ts_tree_total_tokens(const TSTree *self, size_t *result) {
|
||||
recur:
|
||||
if (self->child_count == 0) {
|
||||
if (!self->extra) {
|
||||
(*result)++;
|
||||
}
|
||||
} else {
|
||||
for (size_t i = 1; i < self->child_count; i++)
|
||||
ts_tree_total_tokens(self->children[i], result);
|
||||
self = self->children[0];
|
||||
goto recur;
|
||||
}
|
||||
}
|
||||
|
||||
void ts_tree_set_children(TSTree *self, size_t child_count, TSTree **children) {
|
||||
if (self->child_count > 0)
|
||||
ts_free(self->children);
|
||||
|
|
@ -164,8 +150,10 @@ void ts_tree_set_children(TSTree *self, size_t child_count, TSTree **children) {
|
|||
}
|
||||
|
||||
if (self->symbol == ts_builtin_sym_error) {
|
||||
self->error_size = 0;
|
||||
ts_tree_total_tokens(self, &self->error_size);
|
||||
self->error_size = self->size.rows;
|
||||
for (size_t i = 0; i < child_count; i++)
|
||||
if (!self->children[i]->extra)
|
||||
self->error_size++;
|
||||
}
|
||||
|
||||
if (child_count > 0) {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue