Merge: improve AST dump
authorJean Privat <jean@pryen.org>
Fri, 10 Feb 2017 16:00:07 +0000 (11:00 -0500)
committerJean Privat <jean@pryen.org>
Fri, 10 Feb 2017 16:00:07 +0000 (11:00 -0500)
commitcc71a3c14f550b727696b6b48c3706f39bc75b59
treedc22bf8db17126d6c4b70e04005b92230c68cb26
parentd481273a5f4f42e9c2e709a9e9aef76c1d7c68cc
parent1caa1ed5c0e31e55a38fbf428c3eea47afcfd11c
Merge: improve AST dump

The debug method `ANode.dump_tree` is now more versatile and powerful:

* it can hide tokens (and others non useful nodes)
* it can display code line along with the AST
* it can display model information (through refinement in modelize and semantize modules)
* it uses some color so the output is more readable

Eg: for the code

~~~nit
var a: nullable Object = "Hello".substring(1,3)
print "{a or else "?"}"
~~~

the AST dumped is

~~~
1 var a: nullable Object = "Hello".substring(1,3)
AMainMethPropdef  @test_expr.nit:1,1--2,23
`--ABlockExpr  @test_expr.nit:1,1--2,23
   |--AVardeclExpr :nullable Object @test_expr.nit:1,1--47
   |  |--AType :nullable Object @test_expr.nit:1,8--22
   |  `--ACallExpr :String call=String.abstract_text$Text$substring(from: Int, count: Int): String @test_expr.nit:1,26--47
   |     |--AStringExpr :String @test_expr.nit:1,26--32
   |     `--AParExprs  @test_expr.nit:1,43--47
   |        |--AIntegerExpr :Int @test_expr.nit:1,44
   |        `--AIntegerExpr :Int @test_expr.nit:1,46
2 print "{a or else "?"}"
   `--ACallExpr  call=Sys.file$Sys$print(object: Object) @test_expr.nit:2,1--23
      |--AImplicitSelfExpr :Sys @test_expr.nit:2,1
      `--AListExprs  @test_expr.nit:2,7--23
         `--ASuperstringExpr :String @test_expr.nit:2,7--23
            |--AStartStringExpr :String @test_expr.nit:2,7--8
            |--AOrElseExpr :Object @test_expr.nit:2,9--21
            |  |--AVarExpr :nullable Object @test_expr.nit:2,9
            |  `--AStringExpr :String @test_expr.nit:2,19--21
            `--AEndStringExpr :String @test_expr.nit:2,22--23
~~~

Pull-Request: #2364