stackless traversal

This commit is contained in:
Aleksey Kladov
2018-07-30 23:45:10 +03:00
parent 70b3372921
commit aea86d154e
9 changed files with 86 additions and 16 deletions

View File

@@ -3,7 +3,7 @@ use {SyntaxError, SyntaxNode, SyntaxNodeRef};
/// Parse a file and create a string representation of the resulting parse tree.
pub fn dump_tree(syntax: &SyntaxNode) -> String {
let syntax = syntax.borrow();
let syntax = syntax.as_ref();
let mut errors: BTreeSet<_> = syntax.root.errors.iter().cloned().collect();
let mut result = String::new();
go(syntax, &mut result, 0, &mut errors);