Hello and welcome, everybody.
And in this lecture, we're going to implement labels.
So what do I mean by labels?
Well, in see, you can do something like this and then you can have a go to that jumps to that label.
Okay.
So in this lecture, we're going to actually be making the labels themselves.
The go to will come on another lecture.
Okay.
So what are you going to want to do?
You're going to want to go to puzzle C and just below pause break.
We're going to say void pause label.
It's going to accept the history.
So at this point in time, we've already passed an identifier, which is the label name.
So all that we need to do is essentially pop off the colon.
So we're going to say expects colon, we're now going to pop off the label nodes because it's on the
stack at this point because it's an identifier.
Label name?
Nope, or call it.
We're now going to make sure that the label name node type is equal to an identifier.
Because if it isn't, then someone's put some numbers and a colon or something else and we can't handle
that.
We're going to show a simple error.
Expecting an identifier for labels.
Something else was provided.
Okay, now we're just going to say make label note, label name note.
Now, we haven't made this method yet, so we're going to make that now.
So before we do that, it had to compile.
RH because we need to make some room in our structure to hold this label.
So I struck nodes.
We have to go to it.
And inside our union, we'll be adding it there.
It's right at the bottom.
So labels aren't statements.
So it'll be after this structure, this statement structure.
So we're just going to say struct node label, struct node name.
Okay.
So this name variable will contain the identifier node that represents the name of the label.
So let's head back to POSIX.
See, I can see the name of the function is make label.
No, we're going to copy and paste that into Node C.
So we're just going to say void and we're going to paste that in and that accepts a name node and we're
going to say no, create ampersand struct node dot type equals no type label dot label dot name equals
name node.
And wait a minute.
What's this?
Something's wrong here.
Have back to compiler h.
I forgot to name this so we need to name that structure.
So it's the label by there and that makes sure it's declared in that sub in that structure as a sub
structure.
Nice.
So if we now go back to Node C, we can copy and paste make label node into compiler H.
So we're going to search for make and we're going to just paste it above there.
Nice and simple have backed parsed c can see that now everything works as expected.
So we now need to do we need to call parse label.
So to do this we're going to search for parse symbol.
And then just by here we're going to say elseif token.
Next is symbol and we're going to look for a column and then we're going to say parse, label history
begin and the flags will be zero.
Then we're just going to return and we're going to actually have an error by here.
Compiler error, current process and valid symbol was provided OC.
So that is all fine.
And let's check where Parse label is.
It's much, much higher.
OC So for that reason we're going to copy and paste the prototype parse label.
And I'm just going to paste it by there so that it's resolvable.
So now we're going to try and make clean.
And I make.
We can see that everything is fine.
Head over to test start.
See, we can see that we have our label there.
Let's see if this works.
And we can see everything is fine.
Perfect.
You've now implemented labels.
If you do get a compiler, ever try and make cleaning to make again just to make sure everything works
okay?
Thanks for watching.