So to have reached this point in the course, you should now have a fully functioning Lexa.
Congratulations.
We're now going to begin programming our paths.
And in this lecture, we're going to make some essential structures, such as the structure for nodes.
I just want you to go to compiler dot hedge and under compile process.
I just want you to do struct node.
And then here we're going to say init type and it flags.
So nodes will have types and flags.
So what are the types of node types we can have?
We can have no type number, no type variable node, no type function.
So as you can see, the node represents a different part of the input source file.
When nodes are grouped together, that becomes an abstract syntax tree.
So nodes will also have positions.
So what are positions?
What do I mean by that?
Well, if we go to test out C, we can see this is a variable node once it's been parsed.
Right.
And what line is this variable on line to column one?
So the pass will be set to line to column one.
So yeah, we need a position structure there.
So before we continue implementing our node structure, I just want to create a enumeration of the different
node types just so you can get a better idea of the different node types that are going to be in our
compiler.
So just create a new enum and we're going to go, no type expression.
Node type expression.
Parenthesis.
Node type number.
No type identifier.
No type.
String node type variable.
No type variable list.
And don't worry if you don't understand what all of these are.
They'll be explained to you as we go through the course.
We're just getting all the structures done now so everything's ready for us.
No type function, no type body, no type statement.
Return.
So that's like return statements, node type statement.
If so, that's for like if statements, right?
If X is equal one no type statement else no type statement while no type statement do while no type
statement for no type statement break no type statement continue.
Node type statements switch no type statement case no type statement.
The false default is for like the default case in a switch, right?
No type statement go to.
So that's it for our statements.
So now we're going to say no type unitary node type, ternary node type label nodes type struct node
type union, no type bracket sets for like array brackets, no type casts as for like casting to char
and stuff like that.
And finally, a no type blank, which is basically a node, that doesn't really mean anything.
It's kind of like void.
And whenever a blank node is encountered, it can be ignored as if it didn't even exist.
Okay, so there they are, all of our different node types.
So you can see there is a fair few to implement, but once we've implemented all of these, we will
actually have a functioning parser that can parse most C files.
Okay.
So now just go back down to our node and we're going to continue implementing it.
So we're just going to go struct node, bind it, bind it and we're going to say struct node owner.
So this is a pointer to the body node that this node is in pointer to our body node and we're going
to say struck node function.
And once again, this is a pointer to the function.
This node is in pointer to the function this node is in.
So it's pointed to the function node and this node structure will be huge when we're done.
I'm not going to do it all in this lecture because you're just going to be confused, right?
It makes sense for us to work on this as we go along rather than blind you with all of this right now.
So we're just doing the essential stuff right here.
Okay.
So nodes sometimes have literal values, much like the tokens do.
So we're going to create that here.
So just create a union.
And just like we did with the token values, we're going to do the same for the nodes.
Char civil const char asphalt unsigned init enum unsigned long
album unsigned.
Long long lx num.
And that's for things when the node has a literal value, like no type string, no type number, stuff
like that.
Right?
So number, identifier and string will all have literal values, right?
It makes sense for them to have literal values.
So they will use this union here.
So I think that about covers this lecture, you can see all the different node types.
So you know what you're going to be expecting when we go through this parsing section.
This is quite a lot of work to make the parser, but don't worry because once it's done, it's done
and we can finally move on to code generation and the preprocessor and of course validation.
So that concludes this lecture and thank you for watching.