2.4 Programming language translators Flashcards
1
Q
Assembler
A
- Converts source/assembly code to bytecode (intermediate form)
- The output is machine code (object code)
2
Q
Instruction set
A
Machine code instructions that a particular computer can execute
3
Q
Compiler
A
- Source code as input
- Performs different checks
- Converts source code to object code and can be run anywhere without the presence of a compiler
4
Q
Interpreter
A
Each line is analysed, translated into machine code and ran one by one if it contains ono syntax errors
5
Q
Bytecode
A
- Intermediate representation which combines compiling and interpreting
- Executed by a bytecode interpreter
6
Q
Advantages of bytecode and JVM
A
- Platform independence
- Masks differences between different computer architectures and operating systems
- Adds extra security layer between the computer and program
7
Q
Advantages/Disadvantages of compilers
A
- Object code can be run whenever required without the need to recompile, however if an error is discovered in program has to be recompiled
- Object code executes faster than interpreted code
- Object code produced by compiler can be distributed without compiler present
- Object code is secure and cannot be read without a great deal of ‘reverse engeneering’
8
Q
Advantages/ Disadvantages of compiler
A
- Platform interdependence
- No lengthy recompilation each time an error is discovered
- Iterations have to be interpreted
9
Q
Stages of compilation
A
- Lexical analysis
- Syntax analysis
- Code generation
- Optimisation
10
Q
Lexical analysis
A
- Removes superfluous spaces and comments
- Checks for illegal identifiers
- Replace keywords with tokens from a symbol table
11
Q
Syntax and semantic analysis
A
- Compared to syntax diagrams
- Parsing
- Stacks are used to check brackets are correctly paired (reverse Polish notation)
- Semantic of the program are checked
12
Q
Code generation and optimisation
A
- Aim to reduce the execution time of the object progh