Lecture 1 Flashcards
Components of language translator
Source program
Pre processor
Modified source program
Compiler
Target assembly code
Assembler
Relocatable machine code
Linker loader
Target machine code
Job of a preprocessor
Collects source program which may be divided into different modules. The modified source program is then fed to a compiler.
Job of a compiler
Reads a program in one language–source program– and translate into an equivalent program in another language–target language
A role of the compiler is to report any errors in the source program that it detects during the translation process.
What is an interpreter?
An interpreter is another component of a language translator.
It does not produce a target program as a translation; instead, it directly executes the operations specified in the source program on inputs supplied by the user.
source program–>
Interpreter –> output
input –>
Compiler vs Interpreter
The target program produced by a compiler is much faster than that of an interpreter at mapping inputs to outputs.
An interpreter can give better error diagnostics than a compiler.
Examples of compilers and interpreters
Compilers: Rust, C, C++, COBOL
Interpreters: PERL, Python, Ruby, awk, sed, shells, Scheme/Lisp/ML, postscript/pdf, Java VM
What is a hybrid compiler
A hybrid compiler combine both compilation and interpretation process in translating a source language. E.g Java language translator
THERS AN IMAGE HERE
Job of an assembler
The compiler may produce an assembly-language program as its output, because assembly language is easier to produce as output and is easier to debug.
The assembly language is then processed by a program called an assembler that produces relocatable machine code as its output.
What is the job of the loader/linker?
The linker resolves external memory addresses, where the code in one file may refer to a location in another file.
The loader then puts together all of the executable object files into memory for execution.