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

@ -70,10 +70,18 @@ pub fn parse_file_at_path(
let mut stdout = stdout.lock();
if let Some(mut tree) = tree {
for edit in edits {
if debug_graph && !edits.is_empty() {
println!("BEFORE:\n{}", String::from_utf8_lossy(&source_code));
}
for (i, edit) in edits.iter().enumerate() {
let edit = parse_edit_flag(&source_code, edit)?;
perform_edit(&mut tree, &mut source_code, &edit);
tree = parser.parse(&source_code, Some(&tree)).unwrap();
if debug_graph {
println!("AFTER {}:\n{}", i, String::from_utf8_lossy(&source_code));
}
}
let duration = time.elapsed();