Don't create error node in lexer unless token is completely invalid
Before, any syntax error would cause the lexer to create an error leaf node. This could happen even with a valid input, if the parse stack had split and one particular version of the parse stack failed to parse. Now, an error leaf node is only created when the lexer cannot understand part of the input stream at all. When a normal syntax error occurs, the lexer just returns a token that is outside of the expected token set, and the parser handles the unexpected token.
This commit is contained in:
parent
7c859a07bb
commit
1e353381ff
13 changed files with 225 additions and 148 deletions
|
|
@ -487,6 +487,21 @@ void ts_stack_merge_from(Stack *self, StackVersion start_version) {
|
|||
}
|
||||
}
|
||||
|
||||
void ts_stack_merge_new(Stack *self, StackVersion reference_version,
|
||||
StackVersion first_new_version) {
|
||||
StackNode *reference_node = self->heads.contents[reference_version].node;
|
||||
for (size_t i = first_new_version; i < self->heads.size; i++) {
|
||||
StackNode *node = self->heads.contents[i].node;
|
||||
if (reference_node->state == node->state &&
|
||||
reference_node->position.chars == node->position.chars) {
|
||||
for (size_t j = 0; j < node->link_count; j++)
|
||||
stack_node_add_link(reference_node, node->links[j]);
|
||||
ts_stack_remove_version(self, i);
|
||||
i--;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void ts_stack_merge(Stack *self) {
|
||||
ts_stack_merge_from(self, 0);
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue