process of compilation Flashcards
name the stages of compilation in order
lexical analysis syntax analysis semantic analysis code generation optimisation
What does the Lexical analysis stage remove?
comments and spaces
What is replaced with tokens in this lexical analysis stage?
keywords, constants and identifiers in the source code
What is created in lexical analysis stage?
symbol table- holds the addresses of variables, labels and subroutines
What’s the function of the syntax analysis stage?
Each statement is checked against the rules of syntax for the assembler
What’s checked in syntax analysis?
spelling
grammar
sequence of input characters, symbols, items or tokens should obey the rules of syntax of the language
Describe parsing.
task of systematically breaking down high level statements into their component parts e.g. reserved words and variables
during translation process
What does the semantic analysis stage do?
check meanings of statements are clear and consistent with rules of compiler, structure and data types that are supposed to be used
checks to see if all variables in program have been declared
carries out type checks e.g. makes sure real values haven’t been assigned to integer variables
checks that appropriate operations have been carried out on variables e.g. integer division not carried out on real variables
What does the code generation stage do?
generates machine code
high level statements (most) translated into several machine code instructions
What is optimisation stage?
employing a technique to try and reduce the execution time of the object program
Explain a syntax error.
occurs when program is being compiled
code doesn’t fit into expected syntax of the language
e.g. spelling mistake, not closing brackets, missing colon
Explain linking error.
may occur if compiled program is linked to library routines
e.g. a program may not be present in the library
Explain run time error.
occurs when program is being run
parts of program work, elements have been coded incorrectly
program will crash (this is a run time error)
e.g. a program tries to display a user’s name but the name hasn’t been saved anywhere and so the program crashes
Explain rounding error.
When a number is approximated to the nearest whole number
Explain logical error.
causes a program to output an incorrect value, but the program doesn’t crash