In this course, we're going to create a compiler that can compile the C programming language.
Are you ready to prove that you're capable of creating such a project?
I am Daniel McCarthy, your teacher.
I will be here throughout the entire duration of this course to help you create your very own C compiler.
Your C compiler will compile a subset of the C programming language for loops will be supported while
loops do while loops break continue switch if else if all C statements are supported.
C structures c unions.
The macro system functions, function calls return, the list goes on.
Upon completing this course, your C compiler will compile the majority of the C programming language.
You'll be able to throw most C files at it, and it will compile it without any problems at all.
Majority of the C programming language can be compiled with our compiler.
By the end of this course, you'll be able to throw C files at your C compiler and watch them get compiled
into a beautiful executable binary that you can run.
The course is split into multiple modules.
In module one, this module you will learn how to create a lexer and a parser.
Alexa will take your C source file input and it will create token output.
We then have all these tokens, such as a keyword token and an operator token and identifier token.
And we can pass those into a parser.
And when it goes into the parser, out comes a tree a literal tree, abstract syntax tree with a node
going from node to going from node.
Going from node.
That is what we do in module one.
In module two, we take that tree and we pass it to the code generator.
And when it's being passed to the code generator, the code generator will go through all of the nodes
in the abstract syntax tree.
And it will create assembly language to do what you've asked it.
Okay.
The assembly language will do what the C program says to do.
Our code generator will output the assembly language that performs the same tasks as the source file
input.
In module two, during the code generation phase, you will learn all about what stack frames are,
why they're important.
Your assembly skills will drastically improve, although I do recommend coming to the course with some
assembly experience.
There is an assembly catchup section in module two.
In module two, we also create what I call the resolver.
The resolver is responsible for taking an advanced expression and splitting it up into rules that the
code generator can easily understand.
I believe this is important because it takes away the responsibility from the code generator, and abstracts
out some of the more complicated logic.
By the end of module two, you'll have a C compiler that can compile most C programs without problems,
including pointers, structure, pointers, function calls.
It's able to call printf.
It's able to call any C library function without any problems.
That's what you get by the end of module two.
Now in module three we implement the preprocessor and the semantic validator.
So Essentially, if we set a variable that doesn't exist, we want the compiler to say, you can't do
that.
The variable doesn't exist.
That's semantic validation.
So our semantic validator will will go through our tree and it will ensure that you're not doing anything
silly, like setting variables that don't exist, using structures that aren't declared, and so on.
Now the pre-processor, which will also be done in module three, is responsible for the C macro system.
So you know, when you do hashtag define hashtag include Stdio.h.
All of these are the responsibility of the macro system.
Okay.
The preprocessor.
So by the time you've finished module three your C compiler will essentially be able to run most C programs.
You'll be able to throw all sorts of programs at it, and it will be able to compile them at with ease
without any problems.
So these are the three modules in this course that will allow you to create your own C compiler.
This is module one.
Start today.