Requery the parse table when breaking down the parse stack on invalid lookahead (#636)

* Requery parse table after breaking down parse stack due to invalid lookahead

* Include Ruby parser in randomized test suite

Ruby and PHP are our only two languages that use non-terminal extras.
Adding Ruby uncovered some bugs.

* Print edited source code when running parse --edit w/ debug flag

* Recompute lookahead when breaking down stack on invalid lookahead

* Fix stack summary leak when there are two discontinuities on a stack version
This commit is contained in:
Max Brunsfeld 2020-06-04 13:40:04 -07:00 committed by GitHub
parent 81d533d2d1
commit 0e5ff14976
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 25 additions and 2 deletions

View file

@ -1339,6 +1339,7 @@ static bool ts_parser__advance(
);
}
lex:
// Otherwise, re-run the lexer.
if (!lookahead.ptr) {
lookahead = ts_parser__lex(self, version, state);
@ -1500,6 +1501,10 @@ static bool ts_parser__advance(
// push each of its children. Then try again to process the current
// lookahead.
if (ts_parser__breakdown_top_of_stack(self, version)) {
state = ts_stack_state(self->stack, version);
ts_subtree_release(&self->tree_pool, lookahead);
lookahead = NULL_SUBTREE;
goto lex;
continue;
}