2.2.15

Compilation Stages

Test yourself on Compilation Stages

Test your knowledge with free interactive questions on Seneca — used by over 10 million students.

Syntax Analysis, Code Generation & Optimisation

When code is compiled through a compiler, it has to go through 4 stages before it is ready to run.

Step 2: syntax analysis

Step 2: syntax analysis

  • During syntax analysis, the tokenised code from the lexical analysis is compared to the rules of the programming language.
  • If a section or part of the code is found to not fit with these rules, an error is generated with details of what and where it is.
  • It will continue to perform syntax analysis of all of the code and generate more errors if found.
  • A full error report will be given back to the user of all errors found.
  • This differs to interpreted languages as they return one error at a time.
Step 3: code generation

Step 3: code generation

  • Once the code has successfully passed the first two stages, it’s time to generate the code.
  • During this stage object or machine code is generated.
  • This is what the CPU actually works with to make your program run.
Step 4: optimisation

Step 4: optimisation

  • After your code has been generated into machine or object code it will be optimised for efficiency.
  • The purpose is to make the binary footprint as small as possible and will remove procedures and variables that are written into the code but never used.
Jump to other topics
1

Components of a Computer

2

Software & Software Development

3

Exchanging Data

4

Data Types, Data Structures & Algorithms

5

Legal, Moral, Cultural & Ethical Issues

6

Elements of Computational Thinking

6.1

Thinking Abstractly

6.2

Thinking Ahead

6.3

Thinking Procedurally

6.4

Thinking Logically

6.5

Thinking Concurrently

7

Problem Solving & Programming

8

Algorithms

Practice questions on Compilation Stages

Can you answer these? Test yourself with free interactive practice on Seneca — used by over 10 million students.

  1. 1
  2. 2
Answer all questions on Compilation Stages

Unlock your full potential with Seneca Premium

  • Unlimited access to 10,000+ open-ended exam questions

  • Mini-mock exams based on your study history

  • Unlock 800+ premium courses & e-books

Get started with Seneca Premium