rta: add `live_methods_to_tree` to provide human-readable infos on methods
[nit.git] / src / test_parser.nit
index f19857d..674753c 100644 (file)
 # limitations under the License.
 
 # Program used to test the NIT parser
-package test_parser
+module test_parser
 
 import parser
 
 class PrintTreeVisitor
        super Visitor
        var _rank: Int
-       redef fun visit(n: nullable ANode)
+       redef fun visit(n)
        do
-               if n == null then return
                if n isa Token then
-                       printn("  " * _rank, n.to_s, " ... ", n.location, "\n")
+                       printn("  " * _rank, n.class_name, " \"", n.text.escape_to_c, "\" ", n.location, "\n")
                else
-                       printn("  " * _rank, n.location, "\n")
+                       printn("  " * _rank, n.class_name, " ", n.location, "\n")
                end
                _rank = _rank + 1
                n.visit_all(self)
@@ -46,7 +45,7 @@ var only_lexer = false
 var need_help = false
 var no_file = false
 
-while not args.is_empty and args.first.first == '-' do
+while not args.is_empty and args.first.chars.first == '-' do
        if args.first == "-n" then
                no_print = true
        else if args.first == "-l" then