Compiler
A compiler translates source code into target code (machine code/bytecode) through lexical, syntactic, and semantic analysis, optimization, and code generation.
Purpose
Understand how high-level languages are transformed into executable code, and how optimization works.
Mechanism
Front end: lexical analysis into tokens, parsing into an AST, semantic analysis with type checking. Middle end: IR optimization (inlining, constant folding, loop unrolling). Back end: register allocation, instruction selection, and code generation.
Use cases
- Language implementation
- Code optimization
- Compilation theory