- 3m
- 9m
Creating a C Compiler From Scratch Video Course!
About this course
Learn to create your very own C compiler from scratch. In this course we develop a compiler that compiles a subset of the C Programming Language. By the time you finish all modules of this course you will be able to compile C programs that use pointers, structures, unions, arrays, functions, for loops, while loops. do while loops, if statements, switches and much more! This course includes all course modules!
Our compiler also has a preprocessor macro system allowing you to include header files and create definitions just like you would in any C file.
Your compiler is advanced enough to use the GCC standard library so we are able to call C functions from our compiler. Your compiler will be able to compile the C programming language.
This course does not rely on any frameworks we do everything from scratch to ensure the best possible learning experience for students
Module 1
In module 1 of this course we load our C source file that we wish to compile, into memory. We create a lexer to perform lexical analysis on the source input which will convert the source code into a bunch of tokens that our compiler can easily understand. We then pass the tokens through a parser to produce an abstract syntax tree. An AST describes the C program in a logical way that makes it easier for our compiler to understand. For example for the expression 50 + 20 you will end up with a root expression node that has a left operand that has a node of value 50 and a right operand that has a node of value 20. Breaking down problems in this way makes it much easier to create compilers.
Module 2 & 3
In module 2 and 3 of this course we create a code generator that produces 32 bit Intel assembly language that can then be passed through an assembler to produce a program binary that we can run. We also in this module create a resolver system which is responsible for taking a complicated expression such as "a->b.c.e[50] = 50" and breaking it down into simple steps and rules that our code generator can then easily follow. This abstraction is essential to ensure that the code generator does not become over complex. With the use of a resolver system we can ensure the code base remains clean.
Module 4
In module 4 of this course we create a preprocessor and macro system. This preprocessor system allows us to include header files in our C programs and also use a variety of macro keywords such as "#define" "#ifdef" , "sizeof" and many more.
Module 5
In module 5 we build a semantic validator which validates our C code. A semantic validator ensures that we are not setting variables that do not exist or accessing structures that aren't there.
This is the only video course in the world that shows you how to create a C compiler, come and learn today!
What you'll learn
- How to build a C compiler from scratch
- Full understanding of stackframes and how assembly language is generared for a C source file
- Complete Understanding of lexical analysis and parsing
- Stronger Assembly language skills will be gained
- Compiler Design
Who this course is for
- People with an interest in compiler design
- People who are interested in assembly language
- People who are interested in the C Programming language
Requirements
- You must have a basic experience of assembly language.
Curriculum
249 Lessons • 39h 50m estimated learning time- 2m
- 2. Preparing our Project 27m
- 1. What is Lexical Analysis 7m
- 2. Creating Our Token Structures 7m
- 3. Preparing Our Lexer 20m
- 4. Creating a number token 28m
- 5. Creating a string token 5m
- 6. Creating a operator token 29m
- 7. Creating a symbol token 5m
- 8. Creating a identifier token 6m
- 9. Creating a keyword token 6m
- 10. Creating a new line token 2m
- 11. Creating a comment token 8m
- 12. Handling quotes in the Lexer 6m
- 13. Implementing Hexadecimal Numbers 9m
- 14. Implementing Binary Numbers 5m
- 15. Dealing with the parentheses buffer 6m
- 16. Creating tokens outside of the input file 6m
- 17. Creating number types 4m
- 18. Finalizing the lexer 1m
- 1. What is parsing 6m
- 2. Creating our parser structures 7m
- 3. Writing our parser template 7m
- 4. Creating our node file 8m
- 5. Creating our first node 15m
- 6. Creating an expression node 23m
- 7. Dealing with precedence in expression - Part 1 13m
- 8. Dealing with precedence in expression - Part 2 22m
- 9. Dealing with precedence in expression - Part 3 3m
- 10. Creating an identifier node 2m
- 11. Implementing datatypes and keywords - Part 1 18m
- 12. Implementing datatypes and keywords - Part 2 18m
- 13. Implementing datatypes and keywords - Part 3 17m
- 14. Implementing datatypes and keywords - Part 4 8m
- 15. Understanding scopes 7m
- 16. Implementing the scopes 22m
- 17. Understanding Symbol Resolution 4m
- 18. Implementing The Symbol Resolver 18m
- 19. Implementing datatypes and keywords - Part 5 5m
- 20. Implementing Variables - Part 1 17m
- 21. Implementing Variables - Part 2 9m
- 22. Implementing Variables - Part 3 21m
- 23. Understanding Array Declarations 4m
- 24. Implementing the calculation of array sizes 6m
- 25. Implementing Structures - Part 1 11m
- 26. Implementing Structures - Part 2 2m
- 27. Implementing Body's - Part 1 20m
- 28. What is padding and alignment 5m
- 29. Implementing datatype size functions 7m
- 30. Implementing variable size functions 6m
- 31. Implementing Alignment and Padding Functions 15m
- 32. Implementing Body's - Part 2 13m
- 33. Implementing Body's - Part 3 9m
- 34. Scope offsets explained 12m
- 35. Implementing parser scope entities and functionalities 5m
- 36. Implementing the variable node scope offset - Part 1 17m
- 37. Implementing the variable node scope offset - Part 2 3m
- 38. Implementing the variable node scope offset - Part 3 8m
- 39. Pushing variables to the scope 2m
- 40. Implementing Body's - Part 4 16m
- 41. Implementing Body's - Part 5 6m
- 42. Implementing Structures - Part 3 18m
- 43. Implementing Structures - Part 4 9m
- 44. Initializing our symbol resolver 2m
- 45. Testing our structure functionality 3m
- 46. Error checking our structures 5m
- 47. Project cleanup 3m
- 48. Understanding Functions 8m
- 49. Implementing The Function Structures 5m
- 50. Parsing functions 23m
- 51. Parsing functions arguments 10m
- 52. Dealing with upward stacks 4m
- 53. Changing the parsing of identifiers 1m
- 54. Res = 0 is missing 1m
- 55. Implementing expression parentheses 15m
- 56. Implementing IF statement 10m
- 57. Implementing Else And Else If 7m
- 58. Fixing some compiler warnings 2m
- 59. Implementing the return statement 5m
- 60. Implementing for loops 12m
- 61. Implementing while loops 5m
- 62. Implementing Do While Loops 4m
- 63. Implementing switch statements 14m
- 64. Implementing continue and break 4m
- 65. Implementing labels 6m
- 66. Implementing goto 4m
- 67. Implementing switch cases 5m
- 68. Implementing tenaries 5m
- 69. Implementing commas 2m
- 70. Implementing array brackets 4m
- 71. Implementing casts 6m
- 72. Case indexes or our register case function 1m
- 73. Understanding Fixups 5m
- 74. Creating our fixup core functionality 15m
- 75. Integrating our fixup functionality into the parser 8m
- 76. Parsing forward declarations 3m
- 77. Parsing unions 9m
- 78. Adjusting the function stack size 1m
- 79. Additional recording for nodes 20m
- 1. Module 1 Summary 2m
- 2. Module 2 Information 1m
- 1. The Code generator 3m
- 2. Building the fundementals 8m
- 3. Beginning the iteration of the AST 11m
- 4. Generating global variables 9m
- 5. Understanding the label systems 10m
- 6. Building the label system 17m
- 7. Dealing with strings in the code generator 3m
- 8. Building our string registration system 15m
- 9. Implementing numerical values for global variables 3m
- 10. Implementing string values for global variables 3m
- 11. Fixing issue parsing strings 2m
- 12. Stackframes 17m
- 13. Building our stack frame functionality 20m
- 14. The resolver explained 14m
- 15. Creating the resolver - Part 1 30m
- 16. Creating the resolver - Part 2 21m
- 17. Creating the resolver - Part 3 12m
- 18. How array offsets are calculated 11m
- 19. Creating the resolver - Part 4 16m
- 20. Creating the resolver - Part 5 10m
- 21. Calculating structure and union offsets 11m
- 22. Implementing the struct_offset function 12m
- 23. Creating the resolver - Part 6 13m
- 24. Creating the resolver - Part 7 16m
- 25. Creating the resolver - Part 8 16m
- 26. Creating the resolver - Part 9 17m
- 27. Creating the resolver - Part 10 16m
- 28. Implementing unaries 19m
- 29. Creating the resolver - Part 11 8m
- 30. Creating the resolver - Part 12 9m
- 31. Creating the resolver - Part 13 7m
- 32. Creating the resolver - Part 14 10m
- 33. Creating the resolver - Part 15 20m
- 34. Creating the resolver default handler 38m
- 35. Starting to implement function code generation 34m
- 36. Implementing the foundation of scope variables 35m
- 37. Fixing the parser_scope_offset_for_stack function 3m
- 38. Assigning Variables 33m
- 39. Code generator response system 7m
- 40. Implementing the code generator response system and expressions Video
- 41. Running our first program 10m
- 42. Modifying our parser_datatype_init_type_and_size function 2m
- 43. Generating identifier variable access 12m
- 44. Handling pointer values in expressions 8m
- 45. Implementing logical operators 21m
- 46. Implementing function calls 18m
- 47. Generating structures 22m
- 48. Generating structures - Part 2 10m
- 49. Generating the get address operator 6m
- 50. Useful resources 2m
- 51. Finishing the codegen_resolve_node_for_value function 4m
- 52. Finishing unaries 24m
- 53. Generating unsupported entities 4m
- 54. Generating statement return 20m
- 55. Generating if statements 8m
- 56. Generating while loops 5m
- 57. Generating do while loops 4m
- 58. Generating for loops 9m
- 59. Generating break statements 2m
- 60. Generating continue statements 4m
- 61. Fixing bug in for statements 3m
- 62. Creating switch statements 10m
- 63. Creating switch statements Part 2 8m
- 64. Creating switch statements Part 3 7m
- 65. Generating goto statements 2m
- 66. Creating labels 2m
- 67. Creating strings and calling printf 5m
- 68. Generating expression parenthesis 3m
- 69. Creating tenary nodes 6m
- 70. Generating casts 6m
- 71. Generating array access 9m
- 72. Generating array access - Part 2 3m
- 73. Fixing a bug with indirection assignments 4m
- 74. Generating unions 3m
- 75. Generating array variables in the global scope 2m
- 76. Finishing the codegen_generate_global_variable function 1m
- 77. Generating variable lists 4m
- 78. Escaping characters 4m
- 79. Finishing our operators 16m
- 80. Implementing the ++ and -- operators 19m
- 81. Fixing a couple bugs 5m
- 82. Fixing a bug with the switch statements default case 6m
- 83. Fixing a bug with function calls within arguments 11m
- 1. The preprocessor brief introduction 4m
- 2. What is the expressionable system 5m
- 3. Creating our expressionable structures 16m
- 4. Creating our expressionable system - Part 1 17m
- 5. Creating our expressionable system - Part 2 14m
- 6. Creating our expressionable system - Part 3 17m
- 7. Creating our expressionable system - Part 4 13m
- 8. Creating our expressionable system - Part 5 8m
- 9. Creating our expressionable system - Part 6 13m
- 10. The Preprocessor Internal And Mechanics 16m
- 11. Creating the preprocessor structures 8m
- 12. Beginning the preprocessor logic 38m
- 13. Creating the preprocessor expressionable configuration 24m
- 14. Creating the define macro 26m
- 15. Creating macro arguments 12m
- 16. Implementing undef 3m
- 17. Implementing the macro warning 6m
- 18. Implementing the macro error 2m
- 19. Creating the ifdef macro 21m
- 20. Creating the ifndef macro 4m
- 21. Evaluating expressions in the preprocessor - Part 1 8m
- 22. Implementing the if macro 4m
- 23. Evaluating expressions in the preprocessor - Part 2 1m
- 24. Evaluating the expressions in the preprocessor part 3 16m
- 25. Evaluating the expressions in the preprocessor part 4 12m
- 26. Understanding macro functions 9m
- 27. Implementing macro functions - Part 1 38m
- 28. Getting the value of definitions from within source code 10m
- 29. Implementing macro functions part 2 16m
- 30. Implementing macro functions part 3 7m
- 31. Finishing the typedef directive - Part 1 30m
- 32. Finishing the typedef directive - Part 2 18m
- 33. Implementing macro strings - Part 1 8m
- 34. Implementing macro strings - Part 2 9m
- 35. Implementing preprocessor unary not 4m
- 36. Fixing a mistake with logical not in the code generator 4m
- 37. Implementing the parentheses node in the preprocessor 2m
- 38. Implementing joined nodes in the preprocessor 7m
- 39. Evaluating tenaries in the preprocessor 1m
- 40. Processing concat directive in the preprocessor 18m
- 41. Creating native definitions - Part 1 14m
- 42. Creating native definitions - Part 2 4m
- 43. Implementing includes - Part 1 19m
- 44. Implementing includes - Part 2 6m
- 45. Implementing includes - Part 3 18m
- 46. Implementing sizeof 3m
- 47. Fixing some issues with casting pointers 7m
- 48. Implementing offsetof 4m
- 49. Adding our source file as an included file 3m
- 50. Implementing Native Functions - Part 1 22m
- 51. Implementing Native Functions - Part 2 26m
- 52. Implementing VALIST - Part 1 15m
- 53. Implementing VALIST - Part 2 13m
- 54. Finishing some important header files 10m
- 55. Summary Module 4 1m
- 1. What is semantic validation? 7m
- 2. Building the foundations 4m
- 3. Implementing validator scopes 4m
- 4. Implementing validation of functions 11m
- 5. Implementing validation of variables 5m
- 6. Implementing the validation of statements 12m
- 7. Implementing the validation of structures and unions 4m
- 8. Continuing the validator 9m
- 0.00 instructor rating
- 1 courses
- Systems students worldwide
Daniel McCarthy
Learn from DragonZap instructors with practical, build-first lessons focused on systems, low-level programming, compilers, kernels, and real-world engineering fundamentals.
Student reviews
Really enjoyed this course. It was a long one, but good to go from the parser and lexer, all the way through to code generation. Was fascinating to see how it was all broken down and finally all came together.
NA
This course is intense!
Amazing course! Daniel explains everything clearly and in a straightforward manner. Professionally, I prefer more of a top-down approach, but a practical course like this requires more of a bottom-up approach. Daniel bal...
It would be of great value if the course had some theoretical background on compilers.
Excellent course
Very thorough explanation