Please enable JavaScript.
Coggle requires JavaScript to display documents.
Stages of Compilation - Coggle Diagram
Stages of Compilation
1. Lexical Analysis
Lexer creates tokens
Tokens are in the format: [tokenclass : token]
Tokens consist of operators, keywords, and identifiers
Each token is added to a symbol table
Tokens are checked
Comments and whitespaces are removed
Symbol table is created to keep track of variables and subroutines
2. Syntax Analysis
Receives inputs in the form of tokens
Analyses the syntax of the input to make sure that it follows the rules of the programming language
Finds any errors in syntax and reports to the user
Abstract syntax tree is built from tokens
3. Code generation
Object code is the machine code produced
Abstract code tree is converted into object code
4. Code optimisation
Code is tweaked to make sure that it will run as quickly and efficiently as possible
Linkers and Loaders
Only required if libraries are in use
Dynamic linked libraries
Specifies where code is located
Creates a smaller executable
Static linked libraries
Does not require library file to run program
Code from library is put into executable during compilation