Please enable JavaScript.
Coggle requires JavaScript to display documents.
Compilation - Coggle Diagram
Compilation
Lexical Analysis
Splits the code into words or "lexemes"
each token is added to a symbol table
keywords
identifiers
operators
comments/whitespace removed
Code optimisation
removes unused variables/functions
aim to reduce runtime/memory needs
this might increase the compilation time
redundant or unreachable instructions are removed
execessive jumps also removed (flow control)
Linkers & Loaders
Static linked libraries
Code from the lib is put into the executable during compilation directly
does not require lib file to run program
dynamic linked libraries
specifies where the code is located
means the lib is not included in the executable
program requires library to be in the correct location to run
creates a smaller executable
Only required if libraries are used
loader fetches code from secondary storage
Syntax Analysis
checks if the tokens are valid
checks if they are in the correct order
if it finds an error it will report that to the user
creates an abstract syntax tree
checks if used identifiers are in symbol table
adds data types if needed
Code generation
machine code is generated
abstract code tree is used to make object code