Skip to content
This repository was archived by the owner on Dec 23, 2022. It is now read-only.

Commit 6477a3a

Browse files
committed
nitc: test_parser use dump_tree instead of an adhoc treeprinter
Signed-off-by: Jean Privat <[email protected]>
1 parent d5ae43d commit 6477a3a

File tree

1 file changed

+2
-19
lines changed

1 file changed

+2
-19
lines changed

src/test_parser.nit

+2-19
Original file line numberDiff line numberDiff line change
@@ -21,23 +21,6 @@ import parser
2121
import parser_util
2222
import astutil
2323

24-
# A basic visitor that prints AST trees to the screen
25-
class PrintTreeVisitor
26-
super Visitor
27-
private var rank: Int = 0
28-
redef fun visit(n)
29-
do
30-
if n isa Token then
31-
printn(" " * rank, n.class_name, " \"", n.text.escape_to_c, "\" ", n.location, "\n")
32-
else
33-
printn(" " * rank, n.class_name, " ", n.location, "\n")
34-
end
35-
rank = rank + 1
36-
n.visit_all(self)
37-
rank = rank - 1
38-
end
39-
end
40-
4124
var no_print = false
4225
var only_lexer = false
4326
var need_help = false
@@ -112,7 +95,7 @@ else if interactive then
11295
end
11396

11497
if not no_print then
115-
(new PrintTreeVisitor).enter_visit(n)
98+
n.dump_tree
11699
end
117100
end
118101
else
@@ -148,7 +131,7 @@ else
148131
tree.parentize_tokens
149132
tree.to_xml.write_to(stdout)
150133
else if not no_print then
151-
(new PrintTreeVisitor).enter_visit(tree)
134+
tree.dump_tree
152135
end
153136
end
154137
end

0 commit comments

Comments
 (0)