Hello and welcome.
And in this lecture, we're going to implement the parsing of array brackets.
So what do I mean?
Let's say we have an array variable called ABC.
We can access it like this today.
We'll be making the parsing of this.
So it actually pauses this operation.
So let's head over to parsing dot C and here we're going to say void parse for array struct history.
History struck node left node equals node p called null.
And we haven't created that function yet.
So we are going to have to create that at some point if left node.
Then no pop expect op left bracket.
Expect same right bracket parse expression of route history.
So think of it like this.
If we do ABC 50.
What's going to happen is this ABC we won't see that right.
So we peak and we get the ABC from that.
What we do see is these brackets.
So we pop off the operator here, we parse what's inside, which is 50, and then we expect the right
bracket here that finishes the array operation.
So what we now do, we say struck node expression node equals no pop
which pops off that expression here.
Then we say make bracket node expression node and we can see we've already made this make bracket node
before for the actual parse array brackets function.
But it has a different use case here because this is mostly for accessing arrays in expressions.
And then we're going to say if left node, then we're going to pop off the bracket node
and we're going to make an expression node with the left node and the expression node and the bracket
node.
I mean,
and then we're going to put in the array brackets.
So we now need to make the node pick on null.
So head over to node C and we're going to just search for no peak or null.
We actually already have it.
Let's check if it's in compiler hedge.
So we're going to search for no peak and it is already there.
So I'm guessing the ID just struggle to resolve it at that point.
No problem.
So that's our parse for array function.
So now we're going to call it.
So we're going to say elseif s equal token peak next se file left array bracket pause for array history.
And now we're going to say make clean, make.
And we're going to say Maine and we can see everything works.
So we've successfully implemented the parsing of arrays.
Congratulations.