Hi Daniel - I'm just going over some stuff & wonder if you could please give me...

Timothy Morgan Answered 2 answers
Question by Timothy Morgan 3 years ago

Question

Hi Daniel - I'm just going over some stuff & wonder if you could please give me recap of the uses & differences between the compile_process vectors: node_vec & node_tree_vec ? Cheers, Tim.

Answers

Answered by Daniel McCarthy

Instructor

Hi Tim,
Yes sure, node_tree_vec is the root of our tree, so you can imagine C functions being in here, C global variables and so on. What it wont contain are things like if statements because if statements have a parent node right. Anything that cant have a parent node you can expect to end up in the node_tree_vec.

node_vec is used during the parsing process as a way to push and pop things, so if we find 50 we push to the node_vec we find + we push to the node vec, we find 20 we push to the node vec. Pop it all off and then create an expression node then push that back to the node_vec. So that is what the node_vec is used for, to assist during the parsing operation. When parsing is done we iterate through the node_tree_vec which contains everything we care about.

Follow-up by Timothy Morgan

Question author

That's great - Thanks Daniel.