Skip to content

Compiler: print out sub_nodes if the a ast node contains Vec<AstNode>. - #75

Open
WindSoilder wants to merge 3 commits into
nushell:mainfrom
WindSoilder:push-mmrvtkqvqrss
Open

Compiler: print out sub_nodes if the a ast node contains Vec<AstNode>.#75
WindSoilder wants to merge 3 commits into
nushell:mainfrom
WindSoilder:push-mmrvtkqvqrss

Conversation

@WindSoilder

Copy link
Copy Markdown
Contributor

After this pr #70, some ast nodes' like List are saved behind a Vec, which makes it hard to see what it actually contains, for example:

# list.nu
[1,2,3]

The compilder session outputs:

0: Int (11 to 12) "1"
1: Int (13 to 14) "2"
2: Int (15 to 16) "3"
3: List(ListId(0)) (10 to 16) 
4: Block(BlockId(0)) (0 to 18)

This pr is going to make it outputs one level detail:

0: Int (11 to 12) "1"
1: Int (13 to 14) "2"
2: Int (15 to 16) "3"
3: List(ListId(0)) (10 to 16) - sub_nodes: 0,1,2
4: Block(BlockId(0)) (0 to 18) - sub_nodes: 3

So it's easy to see that List contains node 0, 1, 2.

Avoid too verbosing

If one node contains too many(7) sub nodes, it replaces some nodes with ..., for example:

# list2.nu
[1,2,3,4,5,6,7,8]

It outputs:

0: Int (12 to 13) "1"
1: Int (14 to 15) "2"
2: Int (16 to 17) "3"
3: Int (18 to 19) "4"
4: Int (20 to 21) "5"
5: Int (22 to 23) "6"
6: Int (24 to 25) "7"
7: Int (26 to 27) "8"
8: List(ListId(0)) (11 to 27) - sub_nodes: 0,1,...,6,7
9: Block(BlockId(0)) (0 to 29) - sub_nodes: 8

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant