A program that transforms source code into machine code, or something that transforms an input string into structured outputs. These are written in high level languages to translate into a lower level language
Compilers do extensive preprocessing and offline optimizations.
Translation Process
- During the process of translation, the compiler checks the input program for correctness
- Optimizes the code
- Links to code libraries
- Generates a binary or executable
- Program output by the compiler must be functionally equivalent to the input program
Batch compilation systems dominate:
- GCC
- LLVM
- CLANG
Structure
- Lexical Analysis → Tokens
- Parsing → AST
- Semantic Analysis (type checking) → IR
- Optimization → Address format
- Code Generation
In general, the structure of compilers follows the above, but the proportions have changed since FORTRAN. Today, optimization optimizes all other compilation phases.
What is at the core of a compiler depends on a language and its applications.
See Virtual Machine.