Please enable JavaScript.
Coggle requires JavaScript to display documents.
PROGRAM CONSTRUCTION (Translators (Computers can only execute binary…
PROGRAM CONSTRUCTION
Translators
Computers can only execute binary machine code instructions. Any program written in another language must be converted into machine code before the program can be run
. Compilers, interpreters and assemblers are all types of translators.
Assemblers
Assembly language is a low-level programming language that is almost in a form that the processor can directly understand
An assembler is a program that converts assembly language program into executable code that the processor can execute. The assembler does this by converting the assembly instructions into an opcode and an operand.
Compliers
A compiler translates a source code program into machine code and creates an executable file that can be run in future without the need for recompilation.
.
Lexical Analysis
-
Keywords, constants and identifiers are replaced by 'tokens'.
A symbol table is created which holds the addresses of variables, labels and subroutines.
Syntax Analysis
Tokens are checked to see if they match the spelling and grammar expected, using standard language definitions. This is done by parsing each token to determine if it uses the correct syntax for the programming language.
If syntax errors are found, error messages are produced.
Semantic Analysis
-
Variables are checked to ensure that they are of the correct data type, e.g. strings are not assigned to integers.
Operations are checked to ensure that they are legal for the type of variable being used, e.g. don’t store division in an integer.
-
Code Generation
Machine code is generated.
Code optimisation may be employed to make it more efficient/faster/less resource intense.
Interpreters
Interper
An interpreter analyses the source code statement by statement as execution proceeds, interpreting the meaning of each statement and calling routines to carry out each instruction.
-