 So we're kind of getting in midway into our discussion, but we've been talking about project 5 and we've been talking about how to structure this simple ish program we have a variable declaration of x and then we have a print x and so we talked about okay Then what should our parse function return? Right it should return a statement node pointer that points to a statement node structure That has a type of a print statement Has a next pointer of null because there's only one instruction and that print statement then points to a print statement Node which has an ID that points to a value node and that value node Should have because we know when we initialize x it should have the value zero and it also has a name That is a character pointer to the string x cool, so we've talked about that and now the question that we're talking about is What happens how does things change when we have let's say an assignment statement before this that says x is equal to 42 How does that change things? So first how would that change my statement node pointer anybody you can modulate your voice? Sound really do The type becomes an assignment statement, so is this going to actually change anything for this Assignment No, so everything As we'll see it should stay in place, but let's kind of step back start from here So we have the statement node that we return the pointer that we return. This is going to point to a Statement node structure and the type of that is going to be what? For the first line So and it's what a sign underscore statement is the field and what about next what is next going to point to? Next yeah, exactly that will point to the next one perfect. Okay, this assignment statement node. What does this point to? This field We'll call it an assignment node for now What fields does that have I'm gonna call that LHS Okay, so for a symbol assignment statement, what would op be so we don't have to offer and so what would op be? So op should be zero Cool, then op to should point where? Should be null exactly awesome, so what are the types of left-hand side and operand one? Pointers to value nodes perfect, so Where should the left-hand side point to it should point here and Where should operand 1.2? This one so if I do this What's the compiler going to do it? What's the execution engine going to do when it sees? I have an assignment statement I look I see that the operand is zero which means i'm assigning from the value in Op 1 into the left-hand side value So this is going to do what this is going to take? The value inside op 1 and copy that to the left-hand side value So it's not going to change anything it's still going to be zero So what's the problem there? You tell me For a value node is it required to have both name and value filled? What is the execution somebody look at execution and tell me does it ever use name? It's almost like you can make that be whatever you want, huh? You want the name to be null Let's call that 42 Right simple I to a integer to ascii That'll return a string from an integer so you can easily generate a string It's just nice for debugging purposes right that way you know So now The execution engine right and the really the key to success in this project is being able to draw these diagrams And then either by looking at the code of the execution engine Understanding how would this execution engine execute this so here we have the statement node We have seen that it's an assigned statement. So we go to the assigned statement node We see that the operand is zero which means it's just an assignment from op 1 to left-hand side So what do we do we go to op 1 we take the value in that value node? Which is 42 and we're going to copy it to the left-hand side's value node over here Then we say okay. I did the statement stuff now the program counter becomes the statement nodes next here Now I say what kind of statement is this? Oh, it's a print statement great So I go to the print statement node and I print out the id's value. So it's going to print out 42 So this is the key and this is why I'm recording this because Um a lot of so I actually talked about this earlier You should never You are writing the front end to this compiler, right? You should never be Calculating or executing anything When you see when you parse this assignment statement, you shouldn't change x to be 42 Because that's what the execution back end is supposed to do Right. All you're doing is setting up this intermediate representation So that everything can can execute Right and why this makes sense is eventually you'll have if branches and all this complicated structure, right? You won't know what this value of x is going to be Right, that's why you have to actually execute it to see which branch is going to go down So this is exactly how you want to set it up every instance of x in your program Should map to a value node the same value node And that way every assignment statement will update a value node and every print statement that prints out that value x Will reference that current value in that value node. So this is Absolutely how you want to do this Otherwise, you're not gonna you're never gonna finish. I've seen people do this is they try to Execute everything in here and try to fill it out and it just you can't do it when you kill this You