Compilation process

?
  • Created by: arrey
  • Created on: 18-04-19 20:45
Name 4 stages of Compilation
Lexical Analysis - Syntax Analysis - Code Generation - Code Optimisation - [Linking and Loading]
1 of 11
What happens during Lexical Analysis Part 1
Spaces and comments removed. When all spaces are removed, 'lexemes' remain - INDIVISIBLE blocks of text that compiler recognizes. Details stored in a Symbol Table
2 of 11
What happens during Lexical Analysis Part 2
Code converted into Tokens. Goes through code trying to classify function of each code elements: looks for identifiers (variables), keywords (if while), operators (+ -). Tokens are stored as Binary Digits. We do not yet have address, scope details,
3 of 11
Syntax Analysis (Parsing) stage
A syntax analyzer takes the tokenized form of our code and applies the rules of the language to it to produce a Parse Tree AKA Abstract Syntax Tree. This stage notes the syntax errors and produces error report. Still no actual code given yet.
4 of 11
Code Generation
The Abstract Syntax Tree is then converted into Object Code, AKA Machine Code. Addresses and Scopes of Variables are finally established.
5 of 11
Code Optimisation
Object Code now -> Optimised Object Code. Requires entire code to be parsed again to identify possible efficiencies which is part of the reason compilation is slow. Would look for unused variables to exclude, shortcuts with loops, etc.
6 of 11
What are Libraries
Collections of pre-written code which can be called to add functionality to programs. They save time in coding, and are fully tested/efficient code we can rely on.
7 of 11
Linkers
These copy compiled Library Code into our program to give the functionality offered by Libraries.
8 of 11
Linker - Notes
This could add considderably to size of our program; if a library is referenced multiple times, library code copied multiple times = bloated programs,
9 of 11
Loaders
These copy a reference to a compiled copy of the Library code into our code. The library code IS NOT ADDED to our program.
10 of 11
Loaders - Notes
We have not copied the code so bloating isn't a problem. Multiple references could be made to library code with no increase in size of code. Updates to library we are referencing could make our code unstable.
11 of 11

Other cards in this set

Card 2

Front

What happens during Lexical Analysis Part 1

Back

Spaces and comments removed. When all spaces are removed, 'lexemes' remain - INDIVISIBLE blocks of text that compiler recognizes. Details stored in a Symbol Table

Card 3

Front

What happens during Lexical Analysis Part 2

Back

Preview of the front of card 3

Card 4

Front

Syntax Analysis (Parsing) stage

Back

Preview of the front of card 4

Card 5

Front

Code Generation

Back

Preview of the front of card 5
View more cards

Comments

No comments have yet been made

Similar Computing resources:

See all Computing resources »See all Software resources »