Compilers, Interpreters and Formal Languages

23h 47m 44s
English
Paid

This course is a beginner-friendly introduction to compilers. We will gradually develop an interpreter for a simple scripting language.

Read more about the course

We will cover:

  • Lexical analysis
  • Syntax analysis
  • Parsing algorithms
  • Intermediate Representation (AST)
  • Formal languages and grammars
  • Backus-Naur Form (BNF) and syntax diagrams
  • Error detection and handling
  • Code generation
  • Creating your own virtual machine (VM)
  • Bytecode generation
  • Type checking
  • LLVM IR
  • Basic code optimization
  • ...and much more!

Compilers have always been considered a complex topic, and their historical association with "dragons" (starting with the Dragon Book) only added to this myth's mystique. We will try to explain everything with beginners in mind. This course can be called a "first course" on compilers for developers who have not yet written interpreters.

What We Will Create

We will develop a compiler for a simple programming language called Pinky. It will be a hypothetical scripting language with syntax inspired by Lua and ALGOL W.

The main language for the course will be Python, which will allow us to focus on compiler-specific concepts while remaining productive. In addition, we will provide useful tips for implementing these ideas in the C language.

Required Tools

All you need is a command line, a simple text editor, and a Python interpreter. These tools are cross-platform, so you will be able to work on Windows, macOS, or Linux.

The course does not require prior knowledge, but knowing the basics of programming (if-else, loops, functions) will help you better grasp the material.

Watch Online Compilers, Interpreters and Formal Languages

Join premium to watch
Go to premium
# Title Duration
1 Motivations & Learning Outcomes 14:35
2 How to Take this Course 02:59
3 Compilers as Translators 06:47
4 CPU Components 11:28
5 Opcodes & Instructions 10:00
6 Stack Push & Pop 05:32
7 Control Flow 15:11
8 What is a Program? 11:10
9 Tokens & Lexemes 05:23
10 Syntax Tree 17:00
11 Setting Up our Project Folder 09:50
12 Configuring Python on Windows 02:58
13 Makefile 01:25
14 Adding Token & Lexer Files 03:22
15 Simple Scanning Algorithm 11:33
16 Single-Character Tokens 11:54
17 Ignoring Whitespace & Comments 09:38
18 Scanning Equals & Not Equals 05:08
19 Scanning Two-Char Tokens 06:24
20 Scanning Numbers 13:22
21 Scanning Strings & Identifiers 09:14
22 Identifying Keywords 04:56
23 Scanning -- as Line Comment 05:13
24 Multiline Comments 01:58
25 Syntax Analysis 05:44
26 Context-Free Grammars & BNF 17:46
27 Grammar for Simple Expressions 13:56
28 A Model for AST Nodes 19:36
29 Recursive Descent Parsing 14:30
30 Parser Helper Functions (Exercise) 05:44
31 AST of a Simple Expression 11:41
32 Pretty AST Printing (Exercise) 03:16
33 AST Printing & Polish Notation 09:20
34 Terminal Colors & ANSI Escape Codes 03:33
35 Standardizing Errors Messages 10:39
36 Storing Line Numbers in Nodes 07:11
37 Renaming Term & Factor 04:59
38 A Tree-Walking Interpreter 07:47
39 Coding a Simple Tree-Walking Interpreter 16:23
40 No Signed Number Tokens? 02:52
41 Pinky Language Data Types 10:24
42 Dynamic Types at Runtime 14:03
43 Runtime Type Checks 08:34
44 Parsing Equality & Comparison (Exercise) 08:57
45 Parsing Equality & Comparison Operators 10:48
46 Exponent Associativity 07:50
47 Logical And & Logical Or 07:25
48 Short-Circuit Evaluation 12:46
49 Testing Expressions 13:21
50 REPL 03:24
51 Alphabets, Languages, & Grammars 11:56
52 Chomsky Grammar Hierarchy 14:43
53 A Program as a List of Statements 14:03
54 Parsing Print Statements 12:38
55 Interpreting Print Statements 06:51
56 PrintLn Statements (Exercise) 01:02
57 PrintLn Statements & Escape Chars 06:35
58 If Statements 21:04
59 Identifiers & Assignments 16:31
60 Program State & Memory 13:01
61 The Environment Class 13:08
62 Environment Load & Store (Exercise) 11:16
63 Global & Local Variables 10:53
64 While Statement (Exercise) 02:08
65 While Statements 06:43
66 For Statements 17:20
67 Stringifying Booleans & Integers 07:27
68 Mandelbrot Set (Exercise) 07:52
69 Mandelbrot Set Script in Pinky 08:25
70 Compiler-Compilers 08:03
71 Functions in Pinky 10:28
72 Function Model 14:02
73 Parsing Function Declaration 05:49
74 Parsing Function Call 17:20
75 Interpreting Function Declaration 26:35
76 Interpreting Function Call 09:51
77 Expressions as Statements? 03:06
78 Max. Number of Params (Exercise) 01:05
79 Max. Number of Params 00:45
80 Parsing Return Statements 07:20
81 Interpreting Return Statements 15:58
82 Fixing Params as Local Variables 05:17
83 Local Variables & Shadowing 16:55
84 Dragon Curve 18:12
85 Simplified Cosine & Sine Functions 08:07
86 Code Generation & VMs 12:29
87 Example of Stack Instructions 05:58
88 Adding Classes for Compiler & VM 10:46
89 Emitting Push Instructions 17:49
90 Emitting BinOp Instructions 08:40
91 Exercise: Formatting our Code 02:46
92 Formatting our Instructions 03:47
93 Emitting UnOp Instructions 08:28
94 Step by Step Stack Execution 04:41
95 VM Execution 14:36
96 VM Expression Evaluation 16:42
97 VM Comparison Instructions 14:18
98 Generating Code for If Statements 12:06
99 Generating Then & Else Labels 07:36
100 VM Jumps & Branches 10:47
101 String Concat Instruction? 06:26
102 Global Memory Load & Store 14:27
103 Coding Globals Load & Store 17:39
104 Scope Depth 14:58
105 Starting & Ending Blocks 07:37
106 Local Variables & Stack Slots 17:19
107 Local Variables Code Generation 21:12
108 Local Variables at Runtime 08:56
109 Storing Globals by Slot Number 08:23
110 Program Symbols & Debug Info 08:55
111 Exercise: While Code Generation 01:05
112 Generating Code for While Statements 06:02
113 Register vs Stack VMs 05:31
114 Register-based Bytecode 10:26
115 CPython Bytecode Disassembly 10:29
116 Search Locals in Reverse Order 13:15
117 Function Code Generation 11:56
118 Activation Frames 16:33
119 Function Symbol Table 08:04
120 Compiling Function Declarations 12:47
121 Implementing JSR & RTS Instructions 10:48
122 Exercise: Function Parameters 03:51
123 Validating Function Arity & Arguments 08:22
124 Frame Pointer Offsets 13:20
125 Return Statements 07:36
126 Removing Inactive Frame Slots 14:40
127 Type Systems 19:12
128 Type Annotations 20:28
129 Shunting Yard for Simple Expressions 13:11
130 Exercise: Shunting Yard Evaluation 05:19
131 A Simple Shunting Yard Implementation 13:47
132 Shunting Yard & Parentheses 09:53
133 Shunting Yard & Right-Associativity 04:28
134 Pratt Parser 13:43
135 NUD, LED, & Binding Powers 23:11
136 Example Pratt Parsing Expression 11:07
137 Pratt Code (Without Precedence) 11:47
138 Pratt Code (Precedence & Parentheses) 08:24
139 Pratt Code (Right Associativity) 08:53
140 Pratt Code (Prefix Unary Minus) 10:17

Read Book Compilers, Interpreters and Formal Languages

#Title
1Register-based Bytecode
2NUD, LED, & Binding Powers

Similar courses to Compilers, Interpreters and Formal Languages

Programming: Beyond the Basics

Programming: Beyond the BasicsOz Nova (csprimer.com)

Category: Others
Duration 11 hours 14 minutes 57 seconds
Eve: Building RESTful APIs with MongoDB and Flask

Eve: Building RESTful APIs with MongoDB and FlaskTalkpython

Category: Python, MongoDB
Duration 5 hours 6 minutes 34 seconds
Learn Hugging Face by Building a Custom AI Model

Learn Hugging Face by Building a Custom AI Modelzerotomastery.io

Category: Others
Duration 6 hours 32 minutes 55 seconds
Django 2.1 & Python | The Ultimate Web Development Bootcamp

Django 2.1 & Python | The Ultimate Web Development Bootcampudemy

Category: Python, MongoDB
Duration 9 hours 52 minutes 1 second
Prompt Engineering Bootcamp (Working With LLMs): Zero to Mastery

Prompt Engineering Bootcamp (Working With LLMs): Zero to Masteryzerotomastery.io

Category: Others
Duration 14 hours 24 minutes 46 seconds
Python for Business Data Analytics & Intelligence

Python for Business Data Analytics & Intelligencezerotomastery.io

Category: Python, Data processing and analysis
Duration 15 hours 25 minutes 6 seconds
A/B Testing for Data Science

A/B Testing for Data ScienceLunarTech

Category: Others, Python
Duration 1 hour 47 minutes 56 seconds
Python Interview Espresso

Python Interview Espressointerviewespresso (Aaron Jack)

Category: Preparing for an interview, Python
Duration 5 hours 11 minutes 29 seconds
MongoDB with Async Python

MongoDB with Async PythonTalkpython

Category: Python
Duration 7 hours 19 minutes 54 seconds
Introduction to Prompt Engineering

Introduction to Prompt EngineeringDAIR.AI

Category: Others
Duration 1 hour 27 minutes 29 seconds