Please enable JavaScript.
Coggle requires JavaScript to display documents.
13 - Program Construction (the compilation process (lexical analysis…
13 - Program Construction
translators
computers can only execute binary code so any program written in another language must be converted into machine code before it can be run
translators cover all types of software to a different type of code
compiler
translates a complete source code program into machine code and creates an executable file
runs faster than interpreted program
can be saved on disk and run as many times as needed
interpreters
analyses source code statement by statement as execution proceeds, interpreting every line
less storage
less complex pieces of software so cheaper
assemblers
converts low level code from one form to another
the compilation process
requires a large amount of processing time separated to different stages
lexical analysis
spaces are removed
comments removed
simple error checking
illegal identifiers are flagged
all keywords constants and identifiers replaced by tokens
checking types
semantic analysis
syntax analysis
checks if tokens are in an acceptable order
will show a syntax error if tokens do no follow a rule stored in the computer
generating machine code
cant generate machine code if there are syntax errors
convert elements of the abstract syntax tree into machine code
allocate registers to minimise memory
optimise the machine code to improve efficency
sequencing code blocks
allocating registers
optimising
most programmers make inefficient code
if statements and loops aare jumps in code and slow it down
limit the amount of if statements used
translation and execution errors
division by 0
reading past end of file
stack overflow
request more memory than available
overflow of data type
integer too big
trying to access an out of range array element
summary
translators take source code and turn it into machine code
compilers
breaks it down into stages, processes it all and creates an execiutable file
assemblers
interpreters
read code line by line