From ee46218a73dcffc02346e8f5ed87af93239df6e0 Mon Sep 17 00:00:00 2001 From: Max Brunsfeld Date: Mon, 2 Mar 2020 14:17:12 -0800 Subject: [PATCH] Fix incremental parsing problem with non-terminal extras Also add PHP grammar as a fixture to test against. --- cli/src/tests/corpus_test.rs | 1 + lib/src/parser.c | 2 ++ script/fetch-fixtures | 1 + script/fetch-fixtures.cmd | 1 + 4 files changed, 5 insertions(+) diff --git a/cli/src/tests/corpus_test.rs b/cli/src/tests/corpus_test.rs index af4bb6ba..fd2ed908 100644 --- a/cli/src/tests/corpus_test.rs +++ b/cli/src/tests/corpus_test.rs @@ -22,6 +22,7 @@ const LANGUAGES: &'static [&'static str] = &[ "html", "javascript", "json", + "php", "python", ]; diff --git a/lib/src/parser.c b/lib/src/parser.c index 0fa0c419..7ddccaba 100644 --- a/lib/src/parser.c +++ b/lib/src/parser.c @@ -324,6 +324,8 @@ static bool ts_parser__can_reuse_first_leaf( TSStateId leaf_state = ts_subtree_leaf_parse_state(tree); TSLexMode leaf_lex_mode = self->language->lex_modes[leaf_state]; + if (current_lex_mode.lex_state == (uint16_t)(-1)) return false; + // If the token was created in a state with the same set of lookaheads, it is reusable. if ( table_entry->action_count > 0 && diff --git a/script/fetch-fixtures b/script/fetch-fixtures index 2c26d5e6..96cee76e 100755 --- a/script/fetch-fixtures +++ b/script/fetch-fixtures @@ -30,6 +30,7 @@ fetch_grammar html master fetch_grammar javascript master fetch_grammar jsdoc master fetch_grammar json master +fetch_grammar php master fetch_grammar python master fetch_grammar ruby master fetch_grammar rust master diff --git a/script/fetch-fixtures.cmd b/script/fetch-fixtures.cmd index 48b9bfac..4b3bb562 100644 --- a/script/fetch-fixtures.cmd +++ b/script/fetch-fixtures.cmd @@ -9,6 +9,7 @@ call:fetch_grammar html master call:fetch_grammar javascript master call:fetch_grammar jsdoc master call:fetch_grammar json master +call:fetch_grammar php master call:fetch_grammar python master call:fetch_grammar ruby master call:fetch_grammar rust master