Introduction
Turning human-written code into something a computer can run is tricky. This process happens in steps, each solving a part of the problem to make the code ready for the machine.
Imagine writing a recipe in your language and wanting to share it with a friend who only understands a special cooking language. First, you break your recipe into words, then check if the words are in the right order. Next, you make sure the ingredients and steps make sense. Then, you rewrite the recipe in a simple, clear way. After that, you improve it to be quicker to cook. Finally, you translate it into your friend's cooking language.
┌─────────────────────┐
│ Source Code │
└─────────┬───────────┘
│
▼
┌─────────────────────┐
│ Lexical Analysis │
│ (Tokens) │
└─────────┬───────────┘
│
▼
┌─────────────────────┐
│ Syntax Analysis │
│ (Parse Tree) │
└─────────┬───────────┘
│
▼
┌─────────────────────┐
│ Semantic Analysis │
│ (Symbol Table) │
└─────────┬───────────┘
│
▼
┌─────────────────────┐
│ Intermediate Code │
│ Generation │
└─────────┬───────────┘
│
▼
┌─────────────────────┐
│ Code Optimization │
└─────────┬───────────┘
│
▼
┌─────────────────────┐
│ Code Generation │
│ (Machine Code) │
└─────────────────────┘