Please enable JavaScript.
Coggle requires JavaScript to display documents.
Program construction (Compilers (Lexical analysis (Comments and unneeded…
Program construction
Compilers
A compiler is used when high-level programming languages are converted into machine code, ready to be executed by the CPU.
Lexical analysis
-
-
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.
Tokens are checked to see if they match the spelling and grammar expected, using standard language definitions.
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. real values are not being assigned to integers.
Variables are checked to ensure that they are of the correct data type, e.g. real values are not being assigned to integers.
-
Assemblers
An assembler is a program which coverts the low level assembly programming language into machine code.
The assembler does this by converting the one-word assembly instructions into an opcode, e.g. converting AND to 0010. It also allocates memory to variables, often resulting in an operand.
Translators
A translator changes (translates) a program written in one language into an equivalent program written in a different language.
For example, a program written using the PASCAL programming language may be translated into a program written in one of the C programming languages using a translator.
Interpreters
Before high level programming languages can be run, code is converted by an interpreter, one line at a time, into machine code, which is then executed by the CPU.