Okay, everybody, in this lecture, we're going to just complete the data types for now, the perimeter
data types, I should say, and we're going to test them.
Okay.
So just go to parse next and down here, we're going to say case token type keyword.
Now, this is for global keywords, okay?
Things that are outside of functions.
And we're just going to call parse keyword for global.
Okay.
And just by here, we're going to say void, pass keyword for global.
So now we're just going to go pause, keyword history, begin zero, and now we're just going to pop
off the node.
Now I know our past keyword doesn't yet push anything to the stack.
So this this isn't going to work just yet.
There will be a problem.
So I know that our paths keyword doesn't yet push anything to the stack.
So that means our no pup here will actually cause an error.
But that's absolutely fine because we're just interested in testing our paths data type functionality.
Right now, we're not actually pushing any nodes to the stack.
We haven't quite got to that point yet for creating nodes for keywords.
But this is for later on what we've written on five, three, eight here.
So now that you've written this function, we're now going to try and build this project.
So just to make clean, make you see that everything works fine, we're going to go to test C and we're
just going to remove this expression.
We're just going to put in it because that's the init data type.
Yeah, we're going to parse that.
So just in it on its own like that.
Right.
Got to start C and we're going to launch the debugger J to be main break parse keyword.
We're going to do run and do nex next.
We can just print out that token.
I can see that's the init token.
No problem.
We're going do next.
We're going to do step to step into that function next.
And now we're going to do next.
And what's this?
We've sag faults.
That's not good.
Our program crashed, so that's okay.
This is all a learning process for you all.
I'm token.
See?
Line 32.
That's where the problem was.
So let's go to token C.
Line 32 and I see the problem.
If the token is null, return false.
We try to access a null pointer there, basically.
Right.
That's why it's folded.
So we're going to try that again.
So we're now we're going to do a make clean and make.
Which to be.
Main break.
Pause.
Keywords.
Run.
Next.
Step.
Next.
And once again, we crash the program.
This is absolutely fine.
This is all part of programming.
You know, bugs are natural.
So we can see on line 19.
We also SAG fault.
So go to line 19.
And we can see what the problem is here.
The token is basically null again.
So for all of these, we're going to check that there's a token first.
So we're going to go token and and token end.
And so then it'll only continue if it's true.
Token and and.
And then here we're going to say if the tokens false return false.
Okay.
Now that that that looks okay now.
So now we can try and rebuild that again.
We're going to go and save that.
We're going to say make clean, make.
Shadi.
Main break paths.
Keyword run.
Next.
Step.
Next.
And there we go.
Now it parsed it.
We're going to do print type.
And what do we see here?
We see that it's worked.
We've got a type of three for our D type.
It's type string is integer, its size is four.
It's not a pointer.
So the point of death is depth is zero.
It's not a structural union.
So those are also no.
So that's perfect.
We've gone and taken a complicated token which would require us to say, is it a long is it an integer,
is it this, is it that?
And we converted it into something that just makes sense.
And we even have a flag set that lets us know that this variable is signed.
So let's make the sun sign then, because there's our flag there to say this is signed, let's make
the sun signed.
Yeah.
Unsigned in it.
Okay.
So now what we're going to do, we're going to run that again.
And we're going to break on my one line 481.
Yours might be different.
Okay, check the check the stack trace and I'm going to do break passed out, see for one run and now
I'm going to print D type again and watch this.
The flag is off.
So now we easily know that this data type is unsigned and it's an integer and it sizes four bytes.
So we no longer have to say this is in it.
No, this is a long yes.
We don't have to worry about any of that.
We've parsed it into a really nice, easy to understand structure.
We don't even have to check the type string half of the time because we can just rely on the size by
here.
Okay.
So this is really, really useful if you change that to an unsigned char and we run that again j to
B main break paths dot C for a one run print D type.
Now you see the size is one, so that's perfect.
So we've now implemented data types.
We will be improving this later on in the course when we've created structures and unions because obviously
we don't support those types yet, but we do now support primitive data types.
Now if you went main, it's going to crash, right?
The vector is going to fail because it tries to pop that node that I mentioned earlier on, which is
by here.
By here and obviously there is no node because parse keyword it currently doesn't make nodes.
Okay.
We will have to change this soon so that it also makes nodes.
So essentially keywords can keywords can represent a lot more than just variables, functions, you
know, something like return, that's a keyword, right?
So that will be handled here too.
And when we say is this a keyword, variable modifier or a data type, that will obviously be false.
So it will not it will not parse it as a variable function or structure or union and instead run down
here on line for nine to where we'll have some code that checks if it's a return statement.
Suppose he was going to do a lot more than just dealing with data types.
The data type bit is kind of handled more online for eight here where we then go in here and parse data
type.
So we'll always pause the data type here because variables, functions and structures and unions, they
all have data types, functions return data types variables have data types, structures and unions
they are data types.
So yeah, that's why we'll always pass the data type here.
So thanks for watching.
I hope that was eventful for you.
I know that was quite a long, a long part series just to implement data types, but it is quite a big
task and we will have a part five, part six maybe down the line when we implement structures and unions
and our parser.
So thanks for watching.