Don't mutate shared lookahead nodes when setting the extra flag

This commit is contained in:
Max Brunsfeld 2015-12-15 22:28:50 -08:00
parent 71059f1d66
commit 3c3d95345f
3 changed files with 10 additions and 0 deletions

View file

@ -221,6 +221,9 @@ static bool ts_parser__shift(TSParser *self, int head,
static bool ts_parser__shift_extra(TSParser *self, int head, TSStateId state,
TSTree *lookahead) {
TSSymbolMetadata metadata = self->language->symbol_metadata[lookahead->symbol];
if (!metadata.extra && ts_stack_head_count(self->stack) > 1)
lookahead = ts_tree_make_copy(lookahead);
ts_tree_set_extra(lookahead);
return ts_parser__shift(self, head, state, lookahead);
}