Developing a C Compiler From Scratch - Module 1

Compiler Design, Compiler Development, Lexical Analysis, Parsing, Code Generation, Abstract Syntax Trees

  • 0.0 (0 Reviews)
  • 0 Students
  • 103 Lessons
  • Daniel McCarthy

Course Overview

Are you ready to learn compiler design and compiler development and prove your a master programmer?

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!

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 preform 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.


Throughout the whole course series you will learn to create a fully functioning C compiler.

See more

FAQ

FAQ area empty

Course curriculum

5 chương 103 bài học 14 giờ 20 phút 7 bài học thử miễn phí
Chương 1 Course Overview
Chương 2 Installation And Setup
Chương 3 Lexical Analysis
Chương 4 Parsing The C Programming Language
  • What is parsing? 5:01
  • Creating our parser structures 6:05
  • Writing our parser template 6:04
  • Creating our node file 7:59
  • Creating Our First Node 14:19
  • Creating an expression node 22:02
  • Dealing with precedence in expressions - Part 1 12:27
  • Dealing with precedence in expressions - Part 2 21:19
  • Dealing with precedence in expressions - Part 3 2:42
  • Creating an identifier node 1:44
  • Implementing datatypes and keywords - Part 1 17:23
  • Implementing datatypes and keywords - Part 2 17:59
  • Implementing datatypes and keywords - Part 3 16:56
  • Implementing datatypes and keywords - Part 4 7:55
  • Understanding scopes 6:41
  • Implementing the scopes 21:21
  • Understanding Symbol Resolution 3:18
  • Implementing The Symbol Resolver 17:37
  • Implementing datatypes and keywords - Part 5 4:43
  • Implementing Variables Part 1 16:56
  • Implementing Variables Part 2 8:46
  • Implementing Variables Part 3 21:00
  • Understanding Array Declarations 3:51
  • Implementing the calculation of array sizes 5:26
  • Implementing Structures - Part 1 10:34
  • Implementing Structures - Part 2 1:38
  • Implementing Body's - Part 1 19:28
  • What is padding and alignment 4:27
  • Implementing datatype size functions 6:51
  • Implementing variable size functions 5:16
  • Implementing Alignment And Padding Functions 14:01
  • Implementing Body's - Part 2 12:28
  • Implementing Body's - Part 3 8:25
  • Scope offsets explained 11:34
  • Implementing parser scope entities and functionalities 4:16
  • Implementing the variable node scope offsets - Part 1 16:59
  • Implementing the variable node scope offsets - Part 2 2:34
  • Implementing the variable node scope offsets - Part 3 7:07
  • Pushing variables to the scope 1:35
  • Implementing Body's - Part 4 15:13
  • Implementing Body's - Part 5 5:39
  • Implementing Structures - Part 3 17:46
  • Implementing Structures - Part 4 8:41
  • Initializing our symbol resolver 1:25
  • Testing our structure functionality 2:33
  • Error checking our structures 4:17
  • Project Cleanup 2:30
  • Understanding Functions 7:32
  • Implementing the function structures 4:54
  • Parsing Functions 23:00
  • Parsing function arguments 9:15
  • Dealing with upward stacks 3:34
  • Changing the parsing of identifiers 0:35
  • Res = 0 is missing 1:00
  • Implementing expression parentheses 14:30
  • Implementing IF statements 9:49
  • Implementing Else And Else If 6:30
  • Fixing some compiler warnings 1:37
  • Implementing the return statement 4:17
  • Implementing for loops 11:01
  • Implementing while loops 4:09
  • Implementing Do While Loops 3:26
  • Implementing switch statements 13:23
  • Implementing continue and break 3:35
  • Implementing labels 5:16
  • Implementing goto 3:43
  • Implementing switch cases 4:26
  • Implementing tenaries 4:56
  • Implementing commas 1:59
  • Implementing array brackets 3:16
  • Implementing casts 5:59
  • Case indexes or our register case function 0:52
  • Understanding Fixups 4:29
  • Creating our fixup core functionality 14:08
  • Integrating our fixup functionality into the parser 7:07
  • Parsing forward declarations 2:03
  • Parsing unions 8:23
  • Adjusting the function stack size 0:59
  • Additional reordering of nodes 19:51
  • Quiz
Chương 5 Bonus Lecture
  • Bonus Lecture 2:56

Requirment

  • You must have a basic experience of assembly language.

Outcomes

  • 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

Instructor

...
Daniel McCarthy

0.0

  • ... 0 Student
  • ... 2 Courses
  • ... 0 review

View Details

Reviews

Rate this course :

Remove all