1.8
No description yet. This curated deck is ready for daily study.
Card preview (19)
Lexical Analysis
• Comments and unneeded spaces are removed • Keywords, constants and identifiers are replaced by tokens • A Symbol Table is created which holds the address of variables, labels and subroutines • Creates new table entries in the symbol table
Syntax Analysis
• Tokens are checked to see if they match the spelling and grammar expected, using standard language definitions • Parsing each token to determine if it uses the correct syntax for the programming language • If syntax errors are found, error messages are produced./ if no errors are found the compilation process continues • Adds information regarding attribute type, scope, line of reference, etc in the symbol table.
Semantic Analysis
• Variables (are checked to ensure that they) have been properly declared and used • Variables (are checked to ensure that they) are of the correct data type • Operations are (checked to ensure that they are) legal for the type of variable being used
Code Optimisation
• high-level general programming constructs are replaced by very efficient low-level programming codes OBJECTIVES - Achieve the required output of the program - Not delay the compilation process - Increase speed of the program - Decrease resources demand
Code Generation
Machine code is generated
Translator
A computer program used to convert a program from one languate to another
Compiler
Takes the source code of the entire program as input to produce a machine code version of the program which can be run through a single executable file
Interperter
Takes a single code instruction as input, translates and executes it
Compiler Advantages
• Can be re-run without further translation • Executes faster than interperated code • Machine code can be distributed without compiler being present • Machine code is more seccure, cannot be read without a lot of reverse engineering • Libraries can be packaged with the executable
Compilers Disadvantages
• Compilers take longer than interperating • Errors are only reported after compilation has finished • One error may cause many more related errors • Recompiling after fixing an error adds time
Interperators Advantages
• Debugging will stop translation at the point where error occurs • Complete re-compilation not needed when error found • Easier to partially test and debug • Can be used during program development • Source code is visible and can be checked for security purposes, before being interperated
Interperator Disadvantages
• Associated libraries must be present for the code to run • To execute source code the interperator needs to be installed on the running platform • Source code needs to be present, making interllectual property harder to protect
Assembler
• Translates assembly into machine code • Each single assembly instruction will translate to one machine code instruction • Assembly is easier and less prone to errors than coding in binary • Each CPU has own instruction set
Syntax Error
Occurs when a command does not folow the expected syntac of a language
Linking Error
Calling a standard function where the correct library has not been linked to the program
Semantic Error
Variable declared illegally
Run Time Error
An error that only occurs when a program is running and is difficult to foresee beofree it is compiled and run (program compiles successfully but doesnt perform correctly)
Logical Error
An error that causes a program to output an incorrect answer to what was expected
Rounding/ Truncation Error
Continued use in further calculations causes inaccuracy