parser: fix and add tests to test_parser.nit
[nit.git] / src / test_parser.nit
similarity index 91%
rename from src/parser/test_parser.nit
rename to src/test_parser.nit
index fd53079..8824764 100644 (file)
@@ -25,7 +25,11 @@ class PrintTreeVisitor
        redef fun visit(n: nullable ANode)
        do
                if n == null then return
-               printn("  " * _rank, n.to_s, " ... ", n.location, "\n")
+               if n isa Token then
+                       printn("  " * _rank, n.to_s, " ... ", n.location, "\n")
+               else
+                       printn("  " * _rank, n.location, "\n")
+               end
                _rank = _rank + 1
                n.visit_all(self)
                _rank = _rank - 1
@@ -68,7 +72,7 @@ if args.is_empty or need_help then
 else
        for a in args do
                var f = new IFStream.open(a)
-               var lexer = new Lexer(f, a)
+               var lexer = new Lexer(new SourceFile(a, f))
                if only_lexer then
                        var token = lexer.next
                        while not token isa EOF do