2.4 Programming language translators
No description yet. This curated deck is ready for daily study.
Card preview (12)
Assembler
• Converts source/assembly code to bytecode (intermediate form) • The output is machine code (object code)
Instruction set
Machine code instructions that a particular computer can execute
Compiler
• Source code as input • Performs different checks • Converts source code to object code and can be run anywhere without the presence of a compiler
Interpreter
Each line is analysed, translated into machine code and ran one by one if it contains ono syntax errors
Bytecode
• Intermediate representation which combines compiling and interpreting • Executed by a bytecode interpreter
Advantages of bytecode and JVM
• Platform independence • Masks differences between different computer architectures and operating systems • Adds extra security layer between the computer and program
Advantages/Disadvantages of compilers
• 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’
Advantages/ Disadvantages of compiler
• Platform interdependence • No lengthy recompilation each time an error is discovered • Iterations have to be interpreted
Stages of compilation
• Lexical analysis • Syntax analysis • Code generation • Optimisation
Lexical analysis
• Removes superfluous spaces and comments • Checks for illegal identifiers • Replace keywords with tokens from a symbol table
Syntax and semantic analysis
• Compared to syntax diagrams • Parsing • Stacks are used to check brackets are correctly paired (reverse Polish notation) • Semantic of the program are checked
Code generation and optimisation
• Aim to reduce the execution time of the object progh