Compiler Design Mini Project Shivang
Compiler Design Mini Project Shivang
CSF401-Compiler Design
Submitted By
Rollno: 210102360
SAPID: 1000016727
Name : Shivang Juyal
Section: G
Submitted to
Ms.Sumita Lamba, Assistant Professor
School of Computing
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.
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:
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.
• 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.
• 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.
Module 1
Module 2