Why Study Languages?
Language Design
Types of Languages
Examples
Declarative Languages
Prolog examples
Imperative Languages
Compilation versus Interpretation
Execution Control
- During the compilation the compiler has control
- The execution happens in the OS
- During the execution phase, the control lies in the compiled program.
- The code is subjected to a virtual machine.
- The virtual machine reads one instruction at a time and executes it.
- The control of the execution belongs to the interpreter.
Interpretation Features
Typical Language Translation
|
Compilation Phases
|
Compilation Steps
Other Compilation Details
Example
int main() { cout << "Hello world" << endl; return 0; }
Parse Tree
Semantic Analysis
- That identifiers are declared before they are used.
- That the identifiers are used in the correct context.
- Functions are called with the right number of arguments.
- Variables are assigned values before they are used.
- Pointers are not dereferenced in the wrong context.
- Array subscripts being used within boundaries.
- Divisions by 0, arithmetic overflow.