[go: up one dir, main page]

0% found this document useful (0 votes)
20 views2 pages

Introduction To Compiler Construction Lecture Note

The document provides an overview of compiler construction, defining a compiler as a program that translates high-level code into machine code. It outlines the differences between compilers and interpreters, details the phases of compiler construction, and discusses various types of compilers. Additionally, it highlights the importance of compiler construction and lists common tools used in the process.

Uploaded by

Salisu Zubairu
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
20 views2 pages

Introduction To Compiler Construction Lecture Note

The document provides an overview of compiler construction, defining a compiler as a program that translates high-level code into machine code. It outlines the differences between compilers and interpreters, details the phases of compiler construction, and discusses various types of compilers. Additionally, it highlights the importance of compiler construction and lists common tools used in the process.

Uploaded by

Salisu Zubairu
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 2

Lecture Note: Introduction to Compiler Construction

1. Definition of Compiler
A compiler is a special program that translates a source code written in a high-level
programming language (like C, Java, or Python) into machine code (binary form) that a
computer’s processor can understand and execute.

2. Difference Between Compiler and Interpreter


Feature | Compiler | Interpreter

--------------- | -------------------------------- | ----------------------------------

Execution | Translates whole code at once | Translates code line by line

Speed | Faster execution | Slower execution

Error Detection | Detects errors after compilation| Detects errors line by line

Example | C, C++ | Python, JavaScript

3. Phases of Compiler Construction


A typical compiler has several phases that work together in sequence:

1. Lexical Analysis (Scanner): Breaks input source code into tokens (e.g., 'int', 'x', '=', '5', ';').

2. Syntax Analysis (Parser): Checks if the token sequence follows grammar rules; builds a
parse tree.

3. Semantic Analysis: Checks for meaningfulness like type checking and variable
declarations.

4. Intermediate Code Generation: Produces an intermediate code.

5. Code Optimization: Improves code efficiency.

6. Code Generation: Converts intermediate code to machine code.

7. Code Linking and Assembly: Combines modules into a single executable.

4. Types of Compilers
- Single Pass Compiler: Scans code once.

- Multi Pass Compiler: Scans code multiple times for better optimization.

- Just-In-Time (JIT) Compiler: Compiles during execution (e.g., Java).


5. Importance of Compiler Construction
- Makes programs run efficiently.

- Deepens understanding of programming languages.

- Useful for building custom programming languages.

- Enhances skills in language design, parsing, and optimization.

6. Common Compiler Construction Tools


- Lex/Yacc (for Lexical and Syntax Analysis)

- ANTLR (Another Tool for Language Recognition)

- LLVM (Low-Level Virtual Machine for code generation)

You might also like