8. program construction Flashcards
What is an assembler?
Converts low level assembly language into machine code.
What is an interpreter?
Converts high level language one line at a time into machine code and executes it.
What is a compiler?
Converts high level language all at once into machine code for use at a later time.
What are the stages of compilation?
- lexical analysis
- syntax analysis
- semantic analysis
- code generation
- code optimisation
What happens during lexical analysis?
Spaces and comments are removed from the code. Identifiers, keywords and operators are replaced with tokens (a variable with a name and value). A symbol table is created, which stores the addresses of all variables, subroutines and labels used in the program.
What happens during syntax analysis?
The tokens will be checked to see if they fit with the language’s syntax. If a syntax error is found, an error message will occur and the compiling will stop.
What happens during semantic analysis?
Variables are checked to see if they are declared correctly and use a valid data type. Operations are checked to ensure they are correct for the data type used.
What happens during code optimisation?
the code is optimised to make it faster and more efficient.
What happens during code generation?
The code in is generated in machine code.