0% found this document useful (0 votes)
18 views7 pages

Compiler Design Mini Project Shivang

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

Compiler Design Mini Project Shivang

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

Mini Project Assignment

CSF401-Compiler Design

Submitted By
Rollno: 210102360
SAPID: 1000016727
Name : Shivang Juyal
Section: G

Submitted to
Ms.Sumita Lamba, Assistant Professor
School of Computing

Shivang Juyal 1000016727


Compiler Design Mini Project Submission:
Introduction
This report offers an insightful summary of the fundamental concepts discussed in the introductory
lecture on Compiler Design. The lecture explored the core principles behind compilers, covering
essential topics like system software, the differences between translators, the comparison of compilers
and interpreters, and the detailed phases of compilation. These concepts are vital for understanding how
compilers function and why they are a critical component of computer science

System Software
1. Categories of Software

System Software: This type of software manages and controls computer hardware and provides a
platform for other software to run. Key examples include:

Operating Systems (OS): Programs such as Windows, Linux, and macOS that manage system
resources and provide a user interface for interacting with hardware.

Firmware: Embedded software in hardware devices that facilitates the booting process and loads the OS
into memory during startup.

Application Software: These programs are designed to help users perform specific tasks, such as
editing documents, browsing the internet, or playing media. Examples include applications like
Microsoft Word, Google Chrome, and VLC Media Player.

2. Components of System Software

Operating System (OS): The OS serves as the main interface between users and computer hardware,
overseeing memory management, process scheduling, and peripheral control.

Firmware: This low-level software is embedded in hardware and is responsible for initializing system
components and loading the operating system into memory during booting.

Translators
Translators are responsible for converting source code written in a high-level programming language into
machine-readable instructions. There are different types of translators based on how they process code.

1. Types of Translators
Compiler: A compiler translates the entire high-level source code into machine code in a single pass,
generating an executable file. This process is more efficient for execution but requires the entire program
to be error-free before running.

Interpreter: An interpreter translates and executes source code line by line. This is beneficial for
debugging, as errors are detected during runtime, but the execution tends to be slower compared to
compiled code.

Assembler: Converts assembly code into machine code, which the processor can directly execute. This
is typically used in low-level programming and systems development.
Shivang Juyal 1000016727
2. Translation Process
High-Level Language (HLL): User-friendly programming languages like Python, C++, and Java,
designed for ease of use and abstraction from machine code.

Low-Level Language (LLL): A more hardware-oriented language, closer to machine code but still
human-readable, like assembly language.

Machine Language: The lowest-level binary code directly understood and executed by a computer’s
CPU.

Below is the table that gives the Difference between Compiler and Interpreter:

Feature Compiler Interpreter


Method of Converts the entire
Conversion program at once Converts and executes line by line
Execution Generally faster due to
Speed pre- compilation Slower due to real-time translation
Error Reports errors after the
Handling whole program is Reports errors immediately upon encountering
compiled them
Produces an executable
Output file (e.g., .exe) Does not generate a separate executable file

Phases of the Compiler


Compilers translate high-level code into machine-readable code through several distinct phases, each
designed to systematically convert the source code into efficient, executable machine code.

1. Lexical Analysis: This initial phase breaks down the source code into basic tokens, such as
keywords, operators, and identifiers, which are the building blocks of the program.
2. Syntax Analysis (Parsing): The tokens are checked against the grammar rules of the programming
language. This phase produces a parse tree or syntax tree, which represents the structure of the
program based on its grammar.
3. Semantic Analysis: In this phase, the compiler verifies the meaning of the program, ensuring
consistency and logical correctness. It checks data types, variable scopes, and function calls to
catch semantic errors.
4. Intermediate Code Generation: After validation, the compiler generates an intermediate
representation of the code, which acts as a bridge between the source language and the machine
language. This representation is often more abstract than machine code but easier for the compiler
to optimize.
5. Code Optimization: The intermediate code is optimized to improve the program’s efficiency by
reducing memory usage and enhancing runtime performance. The goal is to produce faster, smaller,
and more efficient machine code without altering the program's logic.
6. Target Code Generation: The optimized code is translated into machine language, producing the
final executable file that can run directly on hardware.

Shivang Juyal 1000016727


Parallel Components

• Symbol Table: One of the most important data structures in a compiler, the symbol table stores all
relevant information about variables, functions, objects, and other program identifiers. This helps
the compiler efficiently manage scope and type checking during compilation.

• Error Handling: Throughout the compilation process, error-handling mechanisms are in place to
detect and report issues, whether they are syntactic errors during parsing or semantic
inconsistencies during analysis. Effective error handling allows developers to debug and correct
their programs more efficiently.

Additional Concepts in Compiler Design

• Phases Working Together: It’s important to note that while each compiler phase operates
independently, they are all interconnected. For example, errors discovered during syntax analysis
may impact lexical analysis, and efficient code generation relies on successful optimization.
• Cross-Compiler: A cross-compiler is a specialized compiler that generates machine code for a
platform different from the one on which it is running. This is essential in embedded systems where
the development platform might differ from the target platform.
• Just-In-Time (JIT) Compilation: Used in environments like Java's JVM, JIT compilation
compiles code at runtime, providing a balance between the efficiency of compiled languages and
the flexibility of interpreted languages.

Shivang Juyal 1000016727


Screenshots of Course and Assignments

Module 1

Module 2

Shivang Juyal 1000016727


Conclusion
This report provides a high-level overview of the principles of compiler design, from system software to
the specific phases involved in compiling a program. Understanding these concepts is crucial for
developing efficient, high-performance software and paves the way for exploring more advanced topics
in the field of compiler theory.

Shivang Juyal 1000016727

You might also like