0% found this document useful (0 votes)
14 views80 pages

Compiler Design Lab Manual

The document is a lab manual for the Compiler Design course (KCS-552) at Meerut Institute of Engineering and Technology for the 2023-2024 academic session. It outlines the course objectives, lab experiments, teaching methods, and evaluation criteria, along with the vision and mission of the institute and department. The manual also includes a checklist for course files and details on program outcomes and specific skills students are expected to acquire.

Uploaded by

tusharjand1876
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)
14 views80 pages

Compiler Design Lab Manual

The document is a lab manual for the Compiler Design course (KCS-552) at Meerut Institute of Engineering and Technology for the 2023-2024 academic session. It outlines the course objectives, lab experiments, teaching methods, and evaluation criteria, along with the vision and mission of the institute and department. The manual also includes a checklist for course files and details on program outcomes and specific skills students are expected to acquire.

Uploaded by

tusharjand1876
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/ 80

MEERUT INSTITUTE OF ENGINEERING

&
TECHNOLOGY MEERUT

(COMPUTER SCIENCE & ENGINEERING)

DR. A.P.J.ABDUL KALAM TECHNICAL UNIVERSITY LUCKNOW

LAB MANUAL
Subject Code :( KCS-552)
Lab Name: Compiler Design Using C
(Session -2023-2024 B.Tech CSE V Semester)

Prepared By: Checked & Verified By:


Ms.Sonam Jahan Dr. Satish Babu
MEERUT INSTITUTE OF ENGINEERING & TECHNOLOGY, MEERUT

Name of Faculty: Sonam Jahan Designation: Assistant Professor


Subject Name with Code: Compiler Design Lab (KCS-552)

Checklist for Course File (Theory) # 2023 – 2024(Odd Semester)

S.No. Description Observations

1. CoverPagementioningfacultyname,designationandsubject/sessiondetails

2. Vision and Mission of the Institute

3. Vision and Mission of the Department,PEOs,POs,PSOs

Teaching and Evaluation Scheme, List of Experiments prescribed by affiliating university


and to be conducted in the class ,List of standard/text/reference books, other study material /
4.
web links, CO, CO-PO Mapping, List of Equipment / Machines etc., Layout of Lab

5. Lab Plan

6. Lab Manuals

7. Sample Quizzes/Viva-questions

8. Students Lists

9. Personal and Lab Time-table

10. Attainment Levels and Assessment Tools(direct and indirect methods both)

Record of CO-Attainment including End Sem Marks and Course End/Exit Survey, and
11.
Actions taken / to be taken to improve attainment / academic performance

12. Lab Performance Record (Continuous Evaluation Record)

13. Sessional Marks

14. Attendance Register(completed)

15. Evaluated Record of Lab Files ,Jobs, Drawing Sheets, Quizzes etc.
Vision of the Institute

To be an outstanding institution in the country imparting technical education, providing need based, value
based and career based programmes and producing self-reliant, self-sufficient technocrats, capable of
meeting new challenges.

Mission of the Institute

To educate young aspirants in various technical fields to fulfill global requirement of human resources by
providing sustainable quality education, training and invigorating environment, also molding them into
skilled competent and socially responsible citizens who will lead the building of a powerful nation
Vision of Department

To be an excellent department that imparts value based quality education and uplifts innovative research
in the ever-changing field of technology.

Mission of Department

1. To fulfill the requirement of skilled human resources with focus on quality education.
2. To create globally competent and socially responsible technocrats by providing value
and need based training.
3. To improve Industry-Institution Interaction and encourage the innovative research
activities.
Program Educational Objectives (PEOs)

Students will have the successful careers in the field of computer science and allied
PEO 1 sectors as an innovative engineer.

Students will continue to learn and advance their careers through participation in
professional activities, attainment of professional certification and seeking advance
PEO 2
studies.

Students will be able to demonstrate a commitment to life-long learning.


PEO 3
Students will be ready to serve society in any manner and become a responsible and
PEO 4
aware citizen.
Establishing students in a leadership role in any field.
PEO 5

Program Specific Outcomes (PSOs)


Professional Skills: The ability to research, understand and implement
computer programs in the areas related to algorithms, system software,
PSO 1
multimedia, web design, big data analytics, and networking for efficient
analysis and design of computer-based systems of varying complexity.
Problem-Solving Skills: The ability to apply standard practices and strategies
PSO 2 in software project development using open-ended programming environments
to deliver a quality product for business success.
Successful Career and Entrepreneurship: The ability to employ modern
PSO 3 computer languages, environments, and platforms in creating innovative career
paths, to be an entrepreneur, and a zest for higher studies.
Program Outcomes
PO1 Engineering knowledge: Apply the knowledge of mathematics, science, engineering
fundamentals, and an engineering specialization to the solution of complex engineering
problem.

PO2 Problem analysis: Identify, formulate, review research literature, and analyze complex
engineering problems reaching substantiated conclusions using first principles of mathematics,
natural sciences, and engineering sciences.

PO3 Design/development of solutions: Design solutions for complex engineering problems and
design system components or processes that meet the specified needs with appropriate
consideration for the public health and safety, and the cultural, societal, and environmental
considerations.

PO4 Conduct investigations of complex problems: Use research-based knowledge and research
methods including design of experiments, analysis and interpretation of data, and synthesis of
the information to provide valid conclusions.

PO5 Modern tool usage: Create, select, and apply appropriate techniques, resources, and modern
engineering and IT tools including prediction and modeling to complex engineering activities
with an understanding of the limitations.

PO6 The engineer and society: Apply reasoning informed by the contextual knowledge to assess
societal, health, safety, legal and cultural issues and the consequent responsibilities relevant to
the professional engineering practice.

PO7 Environment and sustainability: Understand the impact of the professional engineering
solutions in societal and environmental contexts, and demonstrate the knowledge of, and need
for sustainable development.

PO8 Ethics: Apply ethical principles and commit to professional ethics and responsibilities and
norms of the engineering practice.

PO9 Individual and team work: Function effectively as an individual, and as a member or leader in
diverse teams, and in multidisciplinary settings.

PO10 Communication: Communicate effectively on complex engineering activities with the


engineering community and with society at large, such as, being able to comprehend and write
effective reports and design documentation, make effective presentations, and give and receive
clear instructions.

PO11 Project management and finance: Demonstrate knowledge and understanding of the
engineering and management principles and apply these to one’s own work, as a member and
leader in a team, to manage projects and in multidisciplinary environments.

PO12 Life-long learning: Recognize the need for, and have the preparation and ability to engage in
independent and life-long learning in the broadest context of technological change.

Lab Outcomes
Subject Name: Compiler Design Lab Subject code: KCS-552

Bloom’s
At the end of course, the student will be able to understand Knowledge
Course Outcome
Level

LO1 Identify patterns, tokens & regular expressions for lexical analysis. K4
Design Lexical analyzer for given language using C and K3,K5
LO2 LEX/YACC tools
LO3 Design and analyze top down and bottom up parsers. K5
LO4 Generate the inter mediate code K3
LO5 Generate machine code from the intermediate code forms K5

Bloom’s Knowledge Level


At the end of course, the student
Course will be able to understand
Outcome

Identify patterns, tokens & regular Analyze [K4]: In the context of designing a lexical
expressions for lexical analysis. analyzer, this task requires analyzing the structure of a
programming language to identify patterns, tokens, and
regular expressions that define the lexical elements of the
LO1 language. It involves breaking down the language's lexical
rules, understanding the relationships between different
lexical elements, and recognizing the patterns that
characterize valid tokens.
Design Lexical analyzer for given Apply / Synthesis [K3,K5]: Designing a lexical analyzer
language using C and requires combining knowledge of the specific programming
LEX/YACC tools language's lexical rules, understanding the Lex/Yacc tools,
and creating a coherent system that can recognize and
LO2 tokenize the input based on the language's lexical structure.
This task involves the application of knowledge and skills to
create something new (the lexical analyzer) by integrating
different components and tools.
Design and analyze top down and Synthesis [K5]: Designing parsers requires synthesizing
bottom up parsers. knowledge of language grammar, parsing algorithms, and
compiler theory to create a complete parsing system.
Additionally, analyzing the performance and characteristics
LO3 of top-down and bottom-up parsers involves synthesizing
information and evaluating their strengths and weaknesses in
different contexts.

LO4 Generate the inter mediate code Apply [K3]: Generating intermediate code requires applying
programming concepts, language syntax, and compiler
design principles to produce a representation of a program
that serves as an intermediate step between the source code
and the eventual machine code. This task involves a practical
application of knowledge and skills in the specific context of
compiler construction.
Generate machine code from the Synthesis [K5]: In the context of programming and compiler
intermediate code forms design, generating machine code from intermediate code
requires synthesizing and organizing information to create a
LO5 final executable program. It involves the application of
knowledge and skills to transform abstract representations
(intermediate code) into a concrete and functional form
(machine code).

Bloom’s Knowledge Level

K1 Knowledge/ Remember Retrieving, recognizing, and recalling relevant knowledge from


long‐term memory.

K2 Comprehension/Understand Constructing meaning from oral, written, and graphic messages


through interpreting, exemplifying, classifying, summarizing,
inferring, comparing, and explaining.

K3 Application/Apply Carrying out or using a procedure for executing, or


implementing. The Application level involves using acquired
knowledge and skills in new situations or applying them in a
different way.

K4 Analysis/Analyze Breaking material into constituent parts, determining how the


parts relate to one another and to an overall structure or purpose
through differentiating, organizing, and attributing.

K5 Synthesis /Evaluate Making judgments based on criteria and standards through


checking and critiquing, synthesis involves the ability to put
together parts or elements to form a whole, or to reorganize
elements into a new pattern or structure.

K6 Evolution/Create Putting elements together to form a coherent or functional


whole; reorganizing elements into a new pattern or structure
through generating, planning, or producing.

COMPILER DESIGN LAB DETAILED SYLLABUS


S. No. List of Experiments
1 Design and implement a lexical analyzer for given language using C and the lexical analyzer
should ignore redundant spaces, tabs and new lines.

2 Implementation of Lexical Analyzer using Lex Tool

3 Generate YACC specification for a few syntactic categories.


a. Programtorecognizeavalidarithmeticexpressionthatusesoperator+,–,*and/.
b. Programtorecognizeavalidvariablewhichstartswithaletterfollowedbyanynumb
eroflettersordigits.
c. Implementation of Calculator using LEX and YACC
d. Convert the BNF rules into YACC form and write code to generate abstract
syntax tree

4 Write program to find ε–closure of all states of any given NFA with ε transition.

5 Write program to convert NFA with ε transition to NFA without ε transition.

6 Write program to convert NFA to DFA

7 Write program to minimize any given DFA.

8 Develop an operator precedence parser for a given language.

9 Write program to find Simulate First and Follow of any given grammar.

10 Construct a recursive descent parser for an expression.

11 Construct a Shift Reduce Parser for a given language.


12 Write a program to perform loop unrolling.

13 Write a program to perform constant propagation.

14 Implement Intermediate code generation for simple expressions

15 Implement the back end of the compiler which takes the three address code and produces the
8086 assembly language instructions that can be assembled and run using an 8086
assembler. The target assembly instructions can be simple move, add, sub, jump etc
COURSE NAME DESCRIPTION SEM

C Language Mathematical Concepts as well as Logical concept I

Formal Language & DFA,NFA, Regular language, Regular IV


Automata Theory expression, Context Free Grammar, PDA,
DPDA, CSL,LBA, REC, RE, Turing Machine,
Pumping Lemma, Decidability & Undesirability

Assembly level programming Various operations like MOV, INCR, DCR, ADD, III
and SUB. "EAX," "EBX" and "ECX" are the
variables
Lab Pre-Requisites:
Curriculum & Evaluation Scheme CS & CSE (V semester)

B.TECH (COMPUTER SCIENCE & ENGINEERING


COMPUTER SCIENCE) CURRICULUM STRUCTURE
SEMESTER- V

End
Sl.No. Subjec t Subject Periods Evaluation Scheme Semester Total Credi
t
Codes

L T P CT TA Total PS TE PE

1 KCS-501 Database Management System 3 1 0 30 20 50 100 150 4

KCS-502 3 1 0 30 20 50
Compiler Design
2 100 150 4

3 KCS-503 Design and Analysis of 3 1 0 30 20 50 100 150 4


Algorithm

Deptt. Departmental Elective-I


4 3 0 0 30 20 50 100 150 3
Elective-I

5 Deptt. Departmental Elective-II 3 0 0 30 20 50 100 150 3


Elective-II

6 KCS551 Database Management System Lab 0 0 2 25 25 50 1

7 KCS552 Compiler Design Lab 0 0 2 25 25 50 1


Design and Analysis of
8 KCS553 0 0 2 25 25 50 1
Algorithm
Lab

KCS553 50 50
9 Mini Project or Internship 0 0 2 0
Assessment*

KNC501/ Constitution of India, Law 2 0 0 10 15 25 50


10 KNC502 and Engineering /
Indian Tradition, Culture
and Society

Total 17 3 8 950

*The Mini Project or internship (4 weeks) conducted during summer break after IV semester and will be assessed during V semester.

Meerut Institute of Engineering & Technology, Meerut

Lesson Plan / Teaching Plan / Lecture Plan with Progress: B Tech - …. Semester : 2023-24

Course
: CD Lab KCS 552 Faculty: Ms.Sonam
Name(Code)

Topics / lectures are arranged in sequence - same - as to be taught in the class. Maintain data related to
"Date" in its hard copy.

Lab Date
Tur Referen
S. Teaching
n CO Experiment (Title) to be ce Remark
N Pedagog
Sequ (No) conducted Materia Actual s, if any
o. y Planned
ence l Delivery
No

Design a lexical analyzer for


given language and the
CO Chalk
1 1 lexical analyzer should ignore R1 29/8/23 29/8/23
1 and Talk
redundant spaces, tabs and
new lines

CO Implementation of lexical Chalk


2 2 R1 5/9/23 5/9/23
1 analyzer using lex tool and Talk

CO Chalk
3 3 Implementation of Calculator R1 12/9/23 12/9/23
1 and Talk
using LEX and YACC
4 4 CO Develop an operator Chalk R1 19/9/23 19/9/23
2 precedence parser for a given and
language. Talk,PPT
Write program to find Chalk
CO R1 10/10/23 10/10/23
5 5 Simulate First and Follow of and Talk
2
any given grammar.

Construct a recursive descent Chalk


CO and R1 17/10/23 17/10/23
6 6 parser for an expression.
2
Talk,PPT

CO Construct a Shift Reduce Chalk


7 7 R1 24/10/23 24/10/23
2 Parser for a given language. and Talk

CO Implement Intermediate Chalk


8 8 R1 16/11/23 16/11/23
5 code generation for simple and Talk
expressions
CO Write a program to perform Chalk
9 9 23/11/23 23/11/23
5 constant propagation. and Talk

1 CO Write a program to perform Chalk


10 R1 30/11/23 30/11/23
0 5 loop unrolling. and Talk

1 Buffer Session 9/12/23 9/12/23


11
1

1 Summative Evaluation 10/12/23 10/12/23


12
2

VALUE ADDITON PROGRAMS

EXPERIMENT NO EXPERIMENT NAME CO’S


1 Implement the back end of the compiler which takes the three CO1
address code and produces the 8086 assembly language
instructions that can be assembled and run using an 8086
assembler. The target assembly instructions can be simple move,
add, sub, jump etc.

2 Write program to convert NFA to DFA. CO1


Meerut Institute of Engineering and Technology, Meerut

CO-wise Syllabus #

Department of Computer Science and Engineering: 2023-24

Name of the
1 B.Tech / CD 3 Theory / Lab Lab
Course / Subject
Subject / Course CD-LAB 4 Name of the Faculty Ms. Sonam
2
Code KCS-552
CO- wise Syllabus

LO1 Statement Identify patterns, tokens & regular expressions for lexical analysis.
1
Syllabus Implement a lexical analyzer for given language using C and the lexical
analyzer should ignore redundant spaces, tabs and new lines. To
implement lexical Analyzer for any arithmetic expression.

LO2 Statement Design Lexical analyzer task for given language using C and LEX
2 /YACC tools

Syllabus Implementation of Lexical Analyzer using Lex Tool. Program to


recognize a valid variable which starts with a letter followed by any
number of letters or digits using YACC tool. Implementation of
Calculator using LEX and YACC

LO3 Statement Design and analyze the top down and bottom up parsers.
3
Syllabus Write program to find Simulate First and Follow of any given grammar.
Implement a recursive descent parser for an expression. Implement a
Shift Reduce Parser for a given language.

LO4 Statement Generate the intermediate code.


4
Syllabus Write a program to perform loop unrolling and constant propagation.
Implement Intermediate code generation for simple expressions.

5 LO5 Statement Generate machine code from the intermediate code forms.

Syllabus Implement the back end of the compiler which takes the three address
code and produces the 8086 assembly language instructions that can be
assembled and run using an 8086 assembler. The target assemblies
instructions can be simple move, add, sub, jump etc.

CO-PO Mapping
COURSE OUT COMES VS POS MAPPING (DETAILED; HIGH: 3; MEDIUM: 2; LOW: 1)-

Program Outcomes
Course
outcome PO1 PO2 PO3 PO4 PO5 PO6 PO7 PO8 PO9 PO10 PO11 PO1
2

LO1 - - - - - - - - -

LO2 - - - - - - - - -

LO3 - - - - - - - - -

LO4 - - - - - - - - -

LO5 - - - - - - - - - -

Average

CO-PSO Mapping
Course Outcome Program Specific Outcomes

PSO1 PSO2 PSO3

LO1 - -

LO2 - -

LO3 - -

LO4 - -

LO5 - -

Average

POs & PSO REFERENCE:

PO 1 Engineeri PO7 Environment & PSO1 Knowledge of mathematical tools to


ng Sustainability solve, analyze, formulate different
Knowled problems
ge
PO 2 Probl PO8 Ethics PSO2 Use understanding of different
em subjects for product design and
Analy development
sis
PO 3 Design & PO9 Individual & Team PSO3 use the skills earned in Robotics, IoT
Developm Work and Automation fields.
ent
PO 4 Investigations PO1 0 Communication
Skills
PO 5 Modern Tools PO1 1 Project Mgt. &
Finance
PO 6 Engineer PO1 2 Life
& Long
Society Learnig
COs VS POs MAPPING JUSTIFICATION:
SNO PO/PSO LEVEL OF
MAPPED MAPPING JUSTIFICATION
LO.1 PO1,PO2, Student will be able to understand the basic concept, and
PSO2 3,2,1 working principle of compiler. Acquired knowledge
helps to provide novel approaches to design of system
software.
LO.2 PO1,PO2, PO3, 3,2,1,1 Apply engineering knowledge moderately for different
PSO2 phases of compilation. Student will be able to analyze the
problem.
LO.3 PO1,PO2, PO3, 3,2,1,1 Knowledge of Ambiguities in the context free grammar
PSO2 helps students moderately for analyzing the problems in
parsing. Information acquired from the fundamentals of
parsing leads moderately to implement the intermediate
code.
LO.4 PO1,PO2, 3,2,1, Knowledge of parsing helps students moderately for
PSO2 implementing the problems using lex and yacc.As student
will be able to choose appropriate software tools to
conduct the experiments using lex and yacc.
LO.5 PO1,PO2, 3,2,1 Apply engineering fundamentals slightly to learn about
PSO2 the Intermediate code generation and machine code
generation in compilation process. Information acquired
from the fundamentals of intermediate representation
leads moderately for implementation of target code.
Meerut Institute of Engineering and Technology, Meerut

Course End Survey # 2023-24 (Odd / Even Sem)

Name of the Compiler


Session : 2023-2024
Course : Design

Course Code : KCS-552 Semester : V

Name of the Student Roll No


Ms. Sonam
Faculty : (Optional) :

Department : CSE Student Name (Optional) :

Tick in appropriate column

SNO STATEMENT Agree Partially Disagree


Agree
LO1 Identify patterns, tokens & regular expressions
for lexical analysis.

LO2 Design Lexical analyser task for given language


using C and LEX /YACC tools
LO3 Design and analyze the top down and bottom up
parsers for a given Grammar.

LO4 Generate the intermediate code.

LO5 Generate machine code from the intermediate


code forms
COMPILER DESIGN LABORATORY
OBJECTIVE:

This laboratory course is intended to make the students experiment on the basic techniques of compiler
construction and tools that can used to perform syntax-directed translation of a high-level programming
language into an executable code. Students will design and implement language processors in C by using
tools to automate parts of the implementation process. This will provide deeper insights into the more
advanced semantics aspects of programming languages, code generation, machine independent
optimizations, dynamic memory allocation, and object orientation.

OUTCOMES:
Upon the completion of Compiler Design practical course, the student will be able

To:

1. Understand the working of lex and yacc compiler for debugging of


programs.

2. Understand and define the role of lexical analyzer, use of regular expression
and transition diagrams.

3. Understand and use Context free grammar, and parse tree construction.

4. Learn & use the new tools and technologies used for designing a compiler.

5. Develop program for solving parser problems.

6. Learn how to write programs that execute faster.

OPEN SOURCE RESOURCES:


 Conduct the Lab (C, C++, Lex, or Flex and YACC tools)
 YACC Tools( Unix/Linux utilites)
LAB MANUAL
LIST OF PROGRAMS
PROGRAM NO PROGRAM NAME CO’S
1 Design a lexical analyzer for given language and the lexical CO1
analyzer should ignore redundant spaces, tabs and new lines

2 Implementation of lexical analyzer using lex tool CO1

3 Implementation of Calculator using LEX and YACC CO1

4 Develop an operator precedence parser for a given language. CO2

5 Write program to find Simulate First and Follow of any given CO2
grammar.

6 Construct a recursive descent parser for an expression. CO2

7 Construct a Shift Reduce Parser for a given language. CO2

8 Implement Intermediate code generation for simple CO5


expressions
9 Write a program to perform constant propagation. CO5

10 Write a program to perform loop unrolling. CO5

VALUE ADDITION:

PROGRAM NO PROGRAM NAME CO’S


1 Implement the back end of the compiler which takes the three CO1
address code and produces the 8086 assembly language
instructions that can be assembled and run using an 8086
assembler. The target assembly instructions can be simple move,
add, sub, jump etc.

2 Write program to convert NFA to DFA. CO1


Experiment 1:
OBJECTIVE:

Implement a lexical analyzer for a given language using C and the lexical analyzer should ignore
redundant spaces, tabs, and new lines.

ALGORITHAM:

 Open the Input File:


o Open the input file for reading.
 Define Token Types:
o Define the token types for your language. These could include keywords, identifiers,
operators, literals, etc.
 Define a Data Structure for Tokens:
o Define a data structure to represent tokens. This structure may include fields such as
token type, lexeme, and line number.
 Skip Whitespaces:
o Implement a function to skip whitespaces (spaces, tabs, new lines).
o Whenever a whitespace character is encountered, move to the next non-whitespace
character.
 Tokenization:
o Implement a function to tokenize the input file.
o While there are characters in the file:
 Skip whitespaces.
 Check the current character to determine the token type.
 Extract the lexeme for the token.
 Create a token using the defined data structure.
 Print or store the token.
 Handle Comments:
o If your language supports comments, implement a mechanism to skip comments.
 Handle Literals:
o If your language has literals (e.g., strings or numbers), implement logic to recognize and
handle them.
 Handle Keywords and Identifiers:
o Implement logic to differentiate between keywords and identifiers.
 Print or Store Tokens:
o Choose whether to print the tokens to the console or store them for further processing.
 Close the Input File:
 Close the input file after processing.

SOURCE CODE:

#include <stdio.h>
#include <ctype.h>
intisWhitespace(char c) {
return (c == ' ' || c == '\t' || c == '\n');}
void lexicalAnalyzer(char input[]) {
inti = 0;
while (input[i] != '\0') {
while (isWhitespace(input[i])) {
i++; }
if (!isWhitespace(input[i])) {
printf("Token: ");
while (!isWhitespace(input[i]) && input[i] != '\0') {
printf("%c", input[i]);
i++; }
printf("\n");
} }}
intmain() {
char input[] = "This is a sample input\nwith redundant spaces and tabs.";
lexicalAnalyzer(input);
return 0;
}
Experiment 2:
OBJECTIVE:

Implementation of Lexical Analyzer using Lex Tool

ALGORITHAM:

A lexical analyzer, also known as a lexer or a scanner, is a fundamental component of a compiler or


interpreter. Its primary purpose is to process the source code of a programming language and break it
down into a sequence of tokens, which are the smallest units of meaning in the language. These tokens
serve as input to the subsequent phase of the compiler or interpreter.

 Define Token Types:


o Identify and define the different types of tokens in your language (keywords, identifiers,
operators, etc.).
 Write Lex Specification File:
o Create a Lex specification file (usually with a .l extension) containing the rules for token
recognition using regular expressions.
 Define Regular Expressions:
o Write regular expressions that match the patterns of your tokens.
o Use Lex syntax to associate actions with each regular expression to specify what should
be done when a match is found.
 Handle Whitespaces:
o Include rules to skip or ignore whitespaces (spaces, tabs, new lines) unless they are
meaningful for your language (e.g., whitespace in strings).
 Handle Comments:
o Implement rules to recognize and ignore comments if your language supports them.
 Handle Literals:
o Implement rules for recognizing literals such as strings or numbers.
 Handle Keywords and Identifiers:
o Write rules to differentiate between keywords and identifiers.
 Generate Lexical Analyzer Code:
o Run the Lex tool on your specification file to generate the C code for the lexical analyzer.
 Compile and Link:
o Compile the generated C code using a C compiler (e.g., gcc) and link it to create the
executable.
 Test the Lexical Analyzer:
o Test the generated lexical analyzer with input code samples to ensure correct
tokenization.

SOURCE CODE:

%{ #include <stdio.h>%}
%%

[ \t\n] ; /* Ignore whitespace characters */

[0-9]+ {

printf("NUMBER: %s\n", yytext);

[+\-*/] {printf("OPERATOR: %c\n", yytext[0]);}

[a-zA-Z_][a-zA-Z0-9_]* {

printf("IDENTIFIER: %s\n", yytext);

\( {printf("OPEN_PAREN\n");}

\) {

printf("CLOSE_PAREN\n");

printf("INVALID CHARACTER: %c\n", yytext[0]);

}%%

intmain() {

yylex(); /* Call the generated lexer */

return 0;

Save the above code in a file, for example, arithmetic.l.

To generate the lexer code from this Lex specification, use the following commands:

lexarithmetic.l

gcclex.yy.c -o lexer–ll

Now you can use the generated lexer executable to analyze arithmetic expressions.

echo "3 + 4 * (5 - 2)" | ./lexer


Experiment 3:

OBJECTIVE:

Implementation of Calculator using LEX and YACC.

ALGORITHAM:

 Lex (Lexical Analyzer Generator):

 Purpose: Lex helps generate lexical analyzers or scanners. A lexical analyzer breaks
down the source code into a sequence of tokens.
 Usage: It reads an input file containing regular expressions and corresponding actions and
generates a C program that recognizes those patterns in an input stream and takes
specified actions when a pattern is matched.
 Features:
 Lex allows you to specify patterns using regular expressions.
 It generates C code for a finite automaton that recognizes the specified patterns.

Yacc (Yet Another Compiler Compiler):

 Purpose: Yacc helps generate parsers. A parser processes the tokens generated by the
lexical analyzer and constructs a syntax tree or an abstract syntax tree (AST).
 Usage: It reads an input file containing a context-free grammar and associated actions,
and generates a C program that can parse sentences conforming to that grammar.
 Features:
 Yacc handles context-free grammars and generates LALR(1) parsers.

 It allows you to specify actions to be taken when specific grammar rules are
recognized.

 Define Lexical Rules (calculator.l):


 Define Grammar Rules (calculator.y):
 Generate Lexical Analyzer and Parser:
 Run the Calculator:
 Enter arithmetic expressions, and the calculator will parse and evaluate them.
 The Lex file (calculator.l) defines the lexical rules, and the Yacc file (calculator.y) defines the
grammar rules and actions. The %token declarations in the Yacc file should match the token
names used in the Lex file.
SOURCE CODE:

Lex specification (calculator.l):

%{

#include "y.tab.h"

%}

%%

[0-9]+ { yylval = atoi(yytext); return NUMBER; }

[-+*/\n] { return yytext[0]; }

[ \t] ; /* skip whitespace */

. { yyerror("Invalid character"); }

%%

intyywrap() {

return 1;

Yacc specification (calculator.y):

%{

#include <stdio.h>

%}

%token NUMBER

%%

program: /* empty */

| program expression '\n' { printf("Result: %d\n", $2); }

expression: NUMBER

| expression '+' expression { $$ = $1 + $3; }

| expression '-' expression { $$ = $1 - $3; }

| expression '*' expression { $$ = $1 * $3; }

| expression '/' expression { if ($3 != 0) $$ = $1 / $3; else { printf("Error: Division by zero\n"); $$ =


0; } }
%%

intmain() {

yyparse();

return 0;

intyyerror(const char *s) {

fprintf(stderr, "%s\n", s);

return 0;

Compile and run:


lexcalculator.l

yacc -d calculator.y

gcclex.yy.cy.tab.c -o calculator

./calculator

Test the calculator:


1+2*3

Ctrl + D (to end the input)

This will print the result:

Result: 7
Experiment 4:

OBJECTIVE:

Develop an operator precedence parser for a given language.

ALGORITHAM:

An operator precedence parser is a type of bottom-up parser used to parse expressions in a programming
language based on the precedence and associativity of operators. It's particularly well-suited for parsing
arithmetic expressions.

 Define the Operator Precedence Table:


 Create a table that specifies the precedence levels of operators in your language.
 Include all the operators in your language along with their precedence levels.
 If your language has different types of operators (e.g., arithmetic, logical, relational),
make sure to handle them appropriately.
Define Grammar Rules:
 Define the grammar rules for your language.
 Expressions should be broken down into smaller units based on the operators and
operands.
Initialize the Stack:
 Create a stack to keep track of operators and operands during parsing.
Read Tokens:
 Read the input tokens one by one.
Handle Operand:
 If the token is an operand, push it onto the stack.
Handle Operator:
 If the token is an operator, compare its precedence with the precedence of the operator on
the top of the stack.
 If the token has higher precedence, push it onto the stack.
 If the token has equal or lower precedence, pop operators from the stack until a lower
precedence operator is encountered or the stack is empty, then push the token onto the
stack.
Handle Parentheses:
 If the token is an opening parenthesis '(', push it onto the stack.
 If the token is a closing parenthesis ')', pop operators from the stack until an opening
parenthesis '(' is encountered.
Continue Parsing:
 Continue reading tokens and applying the above steps until the entire input is processed.
Finalize Parsing:
 After parsing the entire input, pop any remaining operators from the stack and append
them to the output.
Error Handling:
 Implement error handling for cases where the input expression is not well-formed according to
the grammar rules.

SOURCE CODE:

#include<stdio.h>
#include<string.h>
char *input;
int i=0;
char lasthandle[6],stack[50],handles[][5]={")E(","E*E","E+E","i","E^E"};
//(E) becomes )E( when pushed to stack
int top=0,l;
char prec[9][9]={
/*input*/
/*stack + - * / ^ i ( ) $ */
/* + */ ’>’, ’>’,’<’,’<’,’<’,’<’,’<’,’>’,’>’,
/* - */ ’>’, ’>’,’<’,’<’,’<’,’<’,’<’,’>’,’>’,
/* * */ ’>’, ’>’,’>’,’>’,’<’,’<’,’<’,’>’,’>’,
/* / */ ’>’, ’>’,’>’,’>’,’<’,’<’,’<’,’>’,’>’,
/* ^ */ ’>’, ’>’,’>’,’>’,’<’,’<’,’<’,’>’,’>’,
/* i */ ’>’, ’>’,’>’,’>’,’>’,’e’,’e’,’>’,’>’,
/* ( */ ’<’, ’<’,’<’,’<’,’<’,’<’,’<’,’>’,’e’,
/* ) */ ’>’, ’>’,’>’,’>’,’>’,’e’,’e’,’>’,’>’,
/* $ */ ’<’, ’<’,’<’,’<’,’<’,’<’,’<’,’<’,’>’,
};
int getindex(char c)
{
switch(c)
{
case ’+’:return 0;
case ’-’:return 1;
case ’*’:return 2;
case ’/’:return 3;
case ’^’:return 4;
case ’i’:return 5;
case ’(’:return 6;
case ’)’:return 7;
case ’$’:return 8;
}
}
int shift()
{
stack[++top]=*(input+i++);
stack[top+1]=’\0’;
}
int reduce()
{
int i,len,found,t;
for(i=0;i<5;i++)//selecting handles
{
len=strlen(handles[i]);
if(stack[top]==handles[i][0]&&top+1>=len)
{
found=1;
for(t=0;t<len;t++)
{
if(stack[top-t]!=handles[i][t])
{
found=0;
break;
}
}
if(found==1)
{
stack[top-t+1]=’E’;
top=top-t+1;
strcpy(lasthandle,handles[i]);
stack[top+1]=’\0’;
return 1;//successful reduction
}
}
}
return 0;
}
void dispstack()
{
int j;
for(j=0;j<=top;j++)
printf("%c",stack[j]);
}
void dispinput()
{
int j;
for(j=i;j<l;j++)
printf("%c",*(input+j));
}
void main()
{
int j;
input=(char*)malloc(50*sizeof(char));
printf("\nEnter the string\n");
scanf("%s",input);
input=strcat(input,"$");
l=strlen(input);
strcpy(stack,"$");
printf("\nSTACK\tINPUT\tACTION");
while(i<=l)
{
shift();
printf("\n");
dispstack();
printf("\t");
dispinput();
printf("\tShift");
if(prec[getindex(stack[top])][getindex(input[i])]==’>’)
{
while(reduce())
{
printf("\n");
dispstack();
printf("\t");
dispinput();
printf("\tReduced: E->%s",lasthandle);
}
}
}
if(strcmp(stack,"$E$")==0)
printf("\nAccepted;");
else
printf("\nNot Accepted;");
}

OUTPUT:

Enter the string

i*(i+i).
i*(i+i).
STACK INPUT ACTION
$i *(i+i).$ Shift
$E *(i+i).$ Reduced: E->i
$E* (i+i).$ Shift
$E*( i+i).$ Shift
$E*(i +i).$ Shift
$E*(E +i).$ Reduced: E->i
$E*(E+ i).$ Shift
$E*(E+i ).$ Shift
$E*(E+E ).$ Reduced: E->i
$E*(E ).$ Reduced: E->E+E
Experiment 5:

OBJECTIVE:

Write program to find Simulate First and Follow of any given grammar.

ALGORITHAM:

First Set Algorithm:

1. Initialize First sets for all non-terminals as empty.


2. Iterate until there is no change in any First set:

a.For each production A -> X1 X2 ... Xn:

i. If Xi is a terminal, add Xi to First(A).


ii. If Xi is a non-terminal, add First(Xi) - {epsilon} to First(A).
- Continue to the next Xi until a terminal or epsilon is found.
- If epsilon is in First(Xi), continue to the next Xi.
iii. If all Xi produce epsilon, add epsilon to First(A).

Follow Set Algorithm:


1. Initialize Follow set for the start symbol with { $ } (end marker).
2. Iterate until there is no change in any Follow set:

a. For each production A -> X1 X2 ... Xn:


i. For each non-terminal Xi in the production:
- Add First(Xi) - {epsilon} to Follow(Xi).
- If epsilon is in First(Xi), add Follow(A) to Follow(Xi).

b. If there is a production A -> B where B is a non-terminal:


- Add Follow(A) to Follow(B).

SOURCE CODE:

#include <ctype.h>
#include <stdio.h>
#include <string.h>
// Functions to calculate Follow
void followfirst(char, int, int);
void follow(char c);
// Function to calculate First
void findfirst(char, int, int);
int count, n = 0;
// Stores the final result
// of the First Sets
char calc_first[10][100];
// Stores the final result
// of the Follow Sets
char calc_follow[10][100];
int m = 0;
// Stores the production rules
char production[10][10];
char f[10], first[10];
int k;
char ck;
int e;
int main(int argc, char** argv)
{
int jm = 0;
int km = 0;
int i, choice;
char c, ch;
count = 8;
// The Input grammar
strcpy(production[0], "X=TnS");
strcpy(production[1], "X=Rm");
strcpy(production[2], "T=q");
strcpy(production[3], "T=#");
strcpy(production[4], "S=p");
strcpy(production[5], "S=#");
strcpy(production[6], "R=om");
strcpy(production[7], "R=ST");
int kay;
char done[count];
int ptr = -1;
// Initializing the calc_first array
for (k = 0; k < count; k++) {
for (kay = 0; kay < 100; kay++) {
calc_first[k][kay] = ’!’;
}
}
int point1 = 0, point2, xxx;
for (k = 0; k < count; k++) {
c = production[k][0];
point2 = 0;
xxx = 0;
// Checking if First of c has
// already been calculated
for (kay = 0; kay <= ptr; kay++)
if (c == done[kay])
xxx = 1;
if (xxx == 1)
continue;
// Function call
findfirst(c, 0, 0);
ptr += 1;
// Adding c to the calculated list
done[ptr] = c;
printf("\n First(%c) = { ", c);
calc_first[point1][point2++] = c;
// Printing the First Sets of the grammar
for (i = 0 + jm; i < n; i++) {
int lark = 0, chk = 0;
for (lark = 0; lark < point2; lark++) {
if (first[i] == calc_first[point1][lark]) {
chk = 1;
break;
}
}
if (chk == 0) {
printf("%c, ", first[i]);
calc_first[point1][point2++] = first[i];
}
}
printf("}\n");
jm = n;
point1++;
}
printf("\n");
printf("-----------------------------------------------"
"\n\n");
char donee[count];
ptr = -1;
// Initializing the calc_follow array
for (k = 0; k < count; k++) {
for (kay = 0; kay < 100; kay++) {
calc_follow[k][kay] = ’!’;
}
}
point1 = 0;
int land = 0;
for (e = 0; e < count; e++) {
ck = production[e][0];
point2 = 0;
xxx = 0;
// Checking if Follow of ck
// has already been calculated
for (kay = 0; kay <= ptr; kay++)
if (ck == donee[kay])
xxx = 1;
if (xxx == 1)
continue;
land += 1;
// Function call
follow(ck);
ptr += 1;
// Adding ck to the calculated list
donee[ptr] = ck;
printf(" Follow(%c) = { ", ck);
calc_follow[point1][point2++] = ck;
// Printing the Follow Sets of the grammar
for (i = 0 + km; i < m; i++) {
int lark = 0, chk = 0;
for (lark = 0; lark < point2; lark++) {
if (f[i] == calc_follow[point1][lark]) {
chk = 1;
break;
}
}
if (chk == 0) {
printf("%c, ", f[i]);
calc_follow[point1][point2++] = f[i];
}
}
printf(" }\n\n");
km = m;
point1++;
}
}
void follow(char c)
{
int i, j;
// Adding "$" to the follow
// set of the start symbol
if (production[0][0] == c) {
f[m++] = ’$’;
}
for (i = 0; i < 10; i++) {
for (j = 2; j < 10; j++) {
if (production[i][j] == c) {
if (production[i][j + 1] != ’\0’) {
// Calculate the first of the next
// Non-Terminal in the production
followfirst(production[i][j + 1], i,
(j + 2));
}
if (production[i][j + 1] == ’\0’
&& c != production[i][0]) {
// Calculate the follow of the
// Non-Terminal in the L.H.S. of the
// production
follow(production[i][0]);
}
}
}
}
}
void findfirst(char c, int q1, int q2)
{
int j;
// The case where we
// encounter a Terminal
if (!(isupper(c))) {
first[n++] = c;
}
for (j = 0; j < count; j++) {
if (production[j][0] == c) {
if (production[j][2] == ’#’) {
if (production[q1][q2] == ’\0’)
first[n++] = ’#’;
else if (production[q1][q2] != ’\0’
&& (q1 != 0 || q2 != 0)) {
// Recursion to calculate First of New
// Non-Terminal we encounter after
// epsilon
findfirst(production[q1][q2], q1,
(q2 + 1));
}
else
first[n++] = ’#’;
}
else if (!isupper(production[j][2])) {
first[n++] = production[j][2];
}
else {
// Recursion to calculate First of
// New Non-Terminal we encounter
// at the beginning
findfirst(production[j][2], j, 3);
}
}
}
}
void followfirst(char c, int c1, int c2)
{
int k;
// The case where we encounter
// a Terminal
if (!(isupper(c)))
f[m++] = c;
else {
int i = 0, j = 1;
for (i = 0; i < count; i++) {
if (calc_first[i][0] == c)
break;
}
// Including the First set of the
// Non-Terminal in the Follow of
// the original query
while (calc_first[i][j] != ’!’) {
if (calc_first[i][j] != ’#’) {
f[m++] = calc_first[i][j];
}
else {
if (production[c1][c2] == ’\0’) {
// Case where we reach the
// end of a production
follow(production[c1][0]);
}
else {
// Recursion to the next symbol
// in case we encounter a "#"
followfirst(production[c1][c2], c1,
c2 + 1);
}
}
j++;
}
}
}

OUTPUT:

First(X) = { q, n, o, p, #, }
First(T) = { q, #, }
First(S) = { p, #, }
First(R) = { o, p, q, #, }
-----------------------------------------------
Follow(X) = { $, }
Follow(T) = { n, m, }
Follow(S) = { $, q, m, }
Follow(R) = { m, }

Experiment 6:
OBJECTIVE:

Construct a recursive descent parser for an expression.

ALGORITHAM:

A recursive descent parser is a top-down parser that starts with the topmost rule of the grammar and
recursively expands non-terminals by matching the input against the production rules. Below are the
algorithm steps to construct a recursive descent parser for an expression grammar:

 Define a function for each non-terminal in the grammar.


 Each non-terminal function reads input tokens and recursively calls other non-terminal functions.
 Implement the functions to match the grammar rules.
 Use a global variable or a parameter to keep track of the current position in the input.

function parse_E():
parse_T()
parse_E_prime()

function parse_E_prime():
if current_token is '+':
match('+')
parse_T()
parse_E_prime()

function parse_T():
parse_F()
parse_T_prime()

function parse_T_prime():
if current_token is '*':
match('*')
parse_F()
parse_T_prime()

function parse_F():
if current_token is '(':
match('(')
parse_E()
match(')')
elif current_token is 'id':
match('id')
else:
error("Invalid token")

function match(expected_token):
if current_token == expected_token:
consume_token()
else:
error("Unexpected token")

function consume_token():
move to the next token

SOURCE CODE:
#include <stdio.h>
#include <string.h>
#define SUCCESS 1
#define FAILED 0
int E(), Edash(), T(), Tdash(), F();
const char *cursor;
char string[64];
int main()
{
puts("Enter the string");
// scanf("%s", string);
sscanf("i+(i+i)*i", "%s", string);
cursor = string;
puts("");
puts("Input Action");
puts("--------------------------------");
if (E() && *cursor == ’\0’) {
puts("--------------------------------");
puts("String is successfully parsed");
return 0;
} else {
puts("--------------------------------");
puts("Error in parsing String");
return 1;
}
}
int E()
{
printf("%-16s E -> T E’\n", cursor);
if (T()) {
if (Edash())
return SUCCESS;
else
return FAILED;
} else
return FAILED;
}
int Edash()
{
if (*cursor == ’+’) {
printf("%-16s E’ -> + T E’\n", cursor);
cursor++;
if (T()) {
if (Edash())
return SUCCESS;
else
return FAILED;
} else
return FAILED;
} else {
printf("%-16s E’ -> $\n", cursor);
return SUCCESS;
}
}
int T()
{
printf("%-16s T -> F T’\n", cursor);
if (F()) {
if (Tdash())
return SUCCESS;
else
return FAILED;
} else
return FAILED;
}
int Tdash()
{
if (*cursor == ’*’) {
printf("%-16s T’ -> * F T’\n", cursor);
cursor++;
if (F()) {
if (Tdash())
return SUCCESS;
else
return FAILED;
} else
return FAILED;
} else {
printf("%-16s T’ -> $\n", cursor);
return SUCCESS;
}
}
int F()
{
if (*cursor == ’(’) {
printf("%-16s F -> ( E )\n", cursor);
cursor++;
if (E()) {
if (*cursor == ’)’) {
cursor++;
return SUCCESS;
} else
return FAILED;
} else
return FAILED;
} else if (*cursor == ’i’) {
cursor++;
printf("%-16s F ->i\n", cursor);
return SUCCESS;
} else
return FAILED;
}

OUTPUT:

Enter the string


Input Action
--------------------------------
i+(i+i)*i E -> T E’
i+(i+i)*i T -> F T’
+(i+i)*i F ->i
+(i+i)*i T’ -> $
+(i+i)*i E’ -> + T E’
(i+i)*i T -> F T’
(i+i)*i F -> ( E )
i+i)*i E -> T E’
i+i)*i T -> F T’
+i)*i F ->i
+i)*i T’ -> $
+i)*i E’ -> + T E’
i)*i T -> F T’
)*i F ->i
)*i T’ -> $
)*i E’ -> $
*i T’ -> * F T’
F ->i
T’ -> $
E’ -> $
--------------------------------
String is successfully parsed
Experiment 7:

OBJECTIVE:

Construct a Shift Reduce Parser for a given language.

ALGORITHAM:

A Shift-Reduce parser is a type of bottom-up parser that processes the input from left to right, using two
main operations: shift and reduce. The parser shifts input symbols onto a stack and attempts to reduce
them according to the production rules of the grammar. Here are the algorithm steps for constructing a
Shift-Reduce parser:

 Initialization:
 Initialize an empty stack to hold symbols (both terminals and non-terminals).
 Read the input string from left to right.
 Initialize the pointer to the first input symbol.
Parsing Loop:
 Repeat until the stack contains only the start symbol and the input is fully processed.
 Check if there is a reduce operation possible by matching the stack's top with the right-
hand side of any production. If a match is found, perform reduce.
 If no reduce is possible, perform shift by pushing the next input symbol onto the stack.
Reduce Operation:
 Identify the rightmost substring on the stack that matches the right-hand side of a
production.
 Replace the matched substring with the non-terminal on the left-hand side of the
production.
Shift Operation:
 Push the next input symbol onto the stack.
Acceptance:
 If the stack contains only the start symbol and the input is fully processed, accept the
input.
 Otherwise, reject the input.

SOURCE CODE:

#include<stdio.h>
#include<stdlib.h>
#include<string.h>
//Global Variables
int z = 0, i = 0, j = 0, c = 0;
// Modify array size to increase
// length of string to be parsed
char a[16], ac[20], stk[15], act[10];
// This Function will check whether
// the stack contain a production rule
// which is to be Reduce.
// Rules can be E->2E2 , E->3E3 , E->4
void check()
{
// Copying string to be printed as action
strcpy(ac,"REDUCE TO E -> ");
// c=length of input string
for(z = 0; z < c; z++)
{
//checking for producing rule E->4
if(stk[z] == ’4’)
{
printf("%s4", ac);
stk[z] = ’E’;
stk[z + 1] = ’\0’;
//printing action
printf("\n$%s\t%s$\t", stk, a);
}
}
for(z = 0; z < c - 2; z++)
{
//checking for another production
if(stk[z] == ’2’ && stk[z + 1] == ’E’ &&
stk[z + 2] == ’2’)
{
printf("%s2E2", ac);
stk[z] = ’E’;
stk[z + 1] = ’\0’;
stk[z + 2] = ’\0’;
printf("\n$%s\t%s$\t", stk, a);
i = i - 2;
}
}
for(z=0; z<c-2; z++)
{
//checking for E->3E3
if(stk[z] == ’3’ && stk[z + 1] == ’E’ &&
stk[z + 2] == ’3’)
{
printf("%s3E3", ac);
stk[z]=’E’;
stk[z + 1]=’\0’;
stk[z + 1]=’\0’;
printf("\n$%s\t%s$\t", stk, a);
i = i - 2;
}
}
return ; //return to main
}
//Driver Function
int main()
{
printf("GRAMMAR is -\nE->2E2 \nE->3E3 \nE->4\n");
// a is input string
strcpy(a,"32423");
// strlen(a) will return the length of a to c
c=strlen(a);
// "SHIFT" is copied to act to be printed
strcpy(act,"SHIFT");
// This will print Labels (column name)
printf("\nstack \t input \t action");
// This will print the initial
// values of stack and input
printf("\n$\t%s$\t", a);
// This will Run upto length of input string
for(i = 0; j < c; i++, j++)
{
// Printing action
printf("%s", act);
// Pushing into stack
stk[i] = a[j];
stk[i + 1] = ’\0’;
// Moving the pointer
a[j]=’ ’;
// Printing action
printf("\n$%s\t%s$\t", stk, a);
// Call check function ..which will
// check the stack whether its contain
// any production or not
check();
}
// Rechecking last time if contain
// any valid production then it will
// replace otherwise invalid
check();
// if top of the stack is E(starting symbol)
// then it will accept the input
if(stk[0] == ’E’ && stk[1] == ’\0’)
printf("Accept\n");
else //else reject
printf("Reject\n");
}
OUTPUT:

GRAMMAR is -
E->2E2
E->3E3
E->4

stack input action

$ 32423$ SHIFT
$3 2423$ SHIFT
$32 423$ SHIFT
$324 23$ REDUCE TO E -> 4
$32E 23$ SHIFT
$32E2 3$ REDUCE TO E -> 2E2
$3E 3$ SHIFT
$3E3 $ REDUCE TO E -> 3E3
$E $ Accept
Experiment 8:

OBJECTIVE:

Implement Intermediate code generation for simple expressions.

ALGORITHAM:

Intermediate code generation is a crucial step in the compilation process, where the high-level source
code is translated into an intermediate representation. For simplicity, let's focus on generating
intermediate code for simple arithmetic expressions. Here's a basic algorithm with steps:

Algorithm for Intermediate Code Generation for Simple Expressions:

Input:
 A simple arithmetic expression in infix notation.

Output:
 Intermediate code in a suitable representation (e.g., three-address code).

Steps:
 Tokenization:
 Break the input expression into tokens, such as operators (+, -, *, /), operands (variables
or constants), and parentheses.
Conversion to Postfix Notation:
 Use the Shunting Yard Algorithm or a similar method to convert the infix expression into
postfix notation. This simplifies the expression evaluation.
Generate Intermediate Code:
 Initialize an empty stack to hold intermediate results.
 Iterate through the postfix expression.
 For each token:
 If it is an operand, push it onto the stack.
 If it is an operator, pop the required number of operands from the stack,
perform the operation, and push the result back onto the stack.
 If it is a variable or constant, push it onto the stack.
 Handle parentheses appropriately.
 At the end of the iteration, the stack should contain the final result or the intermediate
results.
Display Intermediate Code:
 The final stack or generated intermediate code can be displayed in a suitable format.
Common formats include three-address code, quadruples, or any other representation that
suits your needs.

Example:
Consider the expression: a = b + c * (d - e)

 Tokenization: [a, =, b, +, c, *, (, d, -, e, )]
 Postfix Notation: [a, b, c, d, e, -, *, +, =]
 Intermediate Code:t1 = d - e
 t2 = c * t1
 t3 = b + t2
 a = t3

SOURCE CODE:

#include<stdio.h>
#include<string.h>
int i=1,j=0,no=0,tmpch=90;
char str[100],left[15],right[15];
void findopr();
void explore();
void fleft(int);
void fright(int);
struct exp
{
int pos;
char op;
}k[15];
void main()
{
printf("\t\tINTERMEDIATE CODE GENERATION\n\n");
printf("Enter the Expression :");
scanf("%s",str);
printf("The intermediate code:\n");
findopr();
explore();
}
void findopr()
{
for(i=0;str[i]!=’\0’;i++)
if(str[i]==’:’)
{
k[j].pos=i;
k[j++].op=’:’;
}
for(i=0;str[i]!=’\0’;i++)
if(str[i]==’/’)
{
k[j].pos=i;
k[j++].op=’/’;
}
for(i=0;str[i]!=’\0’;i++)
if(str[i]==’*’)
{
k[j].pos=i;
k[j++].op=’*’;
}
for(i=0;str[i]!=’\0’;i++)
if(str[i]==’+’)
{
k[j].pos=i;
k[j++].op=’+’;
}
for(i=0;str[i]!=’\0’;i++)
if(str[i]==’-’)
{
k[j].pos=i;
k[j++].op=’-’;
}
}
void explore()
{
i=1;
while(k[i].op!=’\0’)
{
fleft(k[i].pos);
fright(k[i].pos);
str[k[i].pos]=tmpch--;
printf("\t%c := %s%c%s\t\t",str[k[i].pos],left,k[i].op,right);
printf("\n");
i++;
}
fright(-1);
if(no==0)
{
fleft(strlen(str));
printf("\t%s := %s",right,left);
exit(0);
}
printf("\t%s := %c",right,str[k[--i].pos]);
}
void fleft(int x)
{
int w=0,flag=0;
x--;
while(x!= -1 &&str[x]!= ’+’ &&str[x]!=’*’&&str[x]!=’=’&&str[x]!=’\0’&&str[x]!=’-’&&str[x]!
=’/’&&str[x]!=’:’)
{
if(str[x]!=’$’&& flag==0)
{
left[w++]=str[x];
left[w]=’\0’;
str[x]=’$’;
flag=1;
}
x--;
}
}
void fright(int x)
{
int w=0,flag=0;
x++;
while(x!= -1 && str[x]!= ’+’&&str[x]!=’*’&&str[x]!=’\0’&&str[x]!=’=’&&str[x]!=’:’&&str[x]!
=’-’&&str[x]!=’/’)
{
if(str[x]!=’$’&& flag==0)
{
right[w++]=str[x];
right[w]=’\0’;
str[x]=’$’;
flag=1;
}
x++;
}
}

OUTPUT:

Enter the Expression :a*b+c/d-e/f+g*h


The intermediate code:
Z := e/f
Y := a*b
X := g*h
W := Y+c
V := Z+X
U := d-V
W := U
Experiment 9:

OBJECTIVE:

Write a program to perform constant propagation.

ALGORITHAM:

Constant propagation is a compiler optimization technique that replaces variables with their known
constant values where applicable. Here's a basic algorithm with steps for implementing constant
propagation:

Algorithm for Constant Propagation:

Input:
 Intermediate code with potential constant values.

Output:
 Optimized intermediate code with constants replaced where possible.

Steps:
 Initialize:
 Create a symbol table to store variable values.
 Initialize the symbol table with known constant values.
Iterate through Intermediate Code:
 For each statement in the intermediate code:
 Identify assignment statements and update the symbol table accordingly.
 For example, if the statement is x = 5, update the symbol table with x = 5.
Propagate Constants:
 Iterate through the intermediate code again.
 For each statement:
 If it's an expression like y = a + b, check if a and b are constants in the
symbol table.
 If both are constants, evaluate the expression and replace a and b with the
result in the intermediate code.
 Update the symbol table with the result: y = constant_result.
Remove Redundant Assignments:
 Iterate through the intermediate code once more.
 For each assignment statement like z = x, check if x is a constant in the symbol
table.
 If x is a constant, replace z with the constant value in the intermediate code.
Display or Output Optimized Code:
 The final optimized intermediate code can be displayed or used for further compilation
phases.
Example:

Consider the input intermediate code:

x=5
y=x+3
z=y*2

After constant propagation, the optimized code would be:

x=5
y=5+3
z = (5 + 3) * 2

And if further optimization is performed to replace constants in expressions, it would become:

x=5
y=8
z = 16

SOURCE CODE:

#include<stdio.h>
#include<string.h>
void input();
void output();
void change(int p,char *res);
void constant();
struct expr
{
char op[2],op1[5],op2[5],res[5];
int flag;
}arr[10];
int n;
void main()
{
input();
constant();
output();
}
void input()
{
int i;
printf("\n\nEnter the maximum number of expressions : ");
scanf("%d",&n);
printf("\nEnter the input : \n");
for(i=0;i<n;i++)
{
scanf("%s",arr[i].op);
scanf("%s",arr[i].op1);
scanf("%s",arr[i].op2);
scanf("%s",arr[i].res);
arr[i].flag=0;
}
}
void constant()
{
int i;
int op1,op2,res;
char op,res1[5];
for(i=0;i<n;i++)
{
if(isdigit(arr[i].op1[0]) && isdigit(arr[i].op2[0]) || strcmp(arr[i].op,"=")==0) /*if both digits, store them in
variab
les*/
{
op1=atoi(arr[i].op1);
op2=atoi(arr[i].op2);
op=arr[i].op[0];
switch(op)
{
case ’+’:
res=op1+op2;
break;
case ’-’:
res=op1-op2;
break;
case ’*’:
res=op1*op2;
break;
case ’/’:
res=op1/op2;
break;
case ’=’:
res=op1;
break;
}
sprintf(res1,"%d",res);
arr[i].flag=1; /*eliminate expr and replace any operand below that uses result of this expr */
change(i,res1);
}
}
}
void output()
{
int i=0;
printf("\nOptimized code is : ");
for(i=0;i<n;i++)
{
if(!arr[i].flag)
{
printf("\n%s %s %s %s",arr[i].op,arr[i].op1,arr[i].op2,arr[i].res);
}
}
}
void change(int p,char *res)
{
int i;
for(i=p+1;i<n;i++)
{
if(strcmp(arr[p].res,arr[i].op1)==0)
strcpy(arr[i].op1,res);
else if(strcmp(arr[p].res,arr[i].op2)==0)
strcpy(arr[i].op2,res);
}
}

OUTPUT:

Enter the maximum number of expressions : 4

Enter the input :

=3-a
+ a b t1
+ a c t2
+ t1 t2 t3
=3-a
+ a b t1
+ a c t2
+ t1 t2 t3

Optimized code is :

+ 3 b t1
+ 3 c t2
+ t1 t2 t3
Experiment 10:

OBJECTIVE:

Write a program to perform loop unrolling.

ALGORITHAM:

Loop unrolling is a compiler optimization technique that aims to reduce loop overhead by increasing the
size of the loop body. This is done by replicating or unwinding the loop code to achieve better
performance. Below are the algorithm steps for loop unrolling:

 Input:
 Input the loop structure and its body.
Determine Loop Characteristics:
 Analyze the loop to determine its characteristics, such as loop bounds, stride, and
dependencies.
Choose Unrolling Factor:
 Decide on the unrolling factor, which represents how many iterations of the loop will be
combined into a single iteration.
Loop Unrolling:
 Identify the loop body and duplicate its code according to the chosen unrolling factor.
 For example, if the unrolling factor is 2, each iteration of the loop will be
replaced by two copies of the loop body.
Adjust Loop Bounds:
 Modify loop bounds to account for the increased loop body size.
 If the original loop had n iterations, and the unrolling factor is 2, the modified
loop will have n/2 iterations.
Handle Remaining Iterations:
 If the number of iterations is not divisible evenly by the unrolling factor, handle the
remaining iterations separately with a residual loop.
Optimize for Pipelining:
 Consider optimizing the unrolled loop for pipelining by scheduling instructions to
minimize pipeline stalls.
Check Dependencies:
 Ensure that there are no dependencies within the loop body that would prevent effective
unrolling.
Update Variable References:
 Adjust variable references within the loop body to account for the modified loop bounds.
Generate Code:
 Generate the optimized code with the loop unrolling applied.
Test and Validate:
 Test the unrolled loop to ensure correctness and validate its performance against the
original loop.
SOURCE CODE:

#include<stdio.h>
void main() {
unsigned int n;
int x;
char ch;
printf("\nEnter N\n");
scanf("%u", & n);
printf("\n1. Loop Roll\n2. Loop UnRoll\n");
printf("\nEnter ur choice\n");
scanf(" %c", & ch);
switch (ch) {
case ’1’:
x = countbit1(n);
printf("\nLoop Roll: Count of 1’s : %d", x);
break;
case ’2’:
x = countbit2(n);
printf("\nLoop UnRoll: Count of 1’s : %d", x);
break;
default:
printf("\n Wrong Choice\n");
}
}
int countbit1(unsigned int n) {
int bits = 0, i = 0;
while (n != 0) {
if (n & 1) bits++;
n >>= 1;
i++;
}
printf("\n no of iterations %d", i);
return bits;
}
int countbit2(unsigned int n) {
int bits = 0, i = 0;
while (n != 0) {
if (n & 1) bits++;
if (n & 2) bits++;
if (n & 4) bits++;
if (n & 8) bits++;
n >>= 4;
i++;
}
printf("\n no of iterations %d", i);
return bits;
}
OUTPUT:

Enter N
3
1. Loop Roll
2. Loop UnRoll

Enter ur choice
2
no of iterations 1
Loop UnRoll: Count of 1’s : 2
VALUE ADDED PROGRAMS

Experiment 1:

OBJECTIVE:

Implement the back end of the compiler which takes the three address code and produces the 8086
assembly language instructions that can be assembled and run using an 8086 assembler. The target
assembly instructions can be simple move, add, sub, jump etc.

ALGORITHAM:

Implementing the back end of a compiler involves translating an intermediate representation, such as
three-address code, into the target assembly language, in this case, 8086 assembly language instructions.
Below is a simplified algorithm to guide you through this process:

 Initialize the Environment:


 Set up data structures and variables to store the intermediate code, symbol table, and
generated assembly code.
 Iterate Through Three-Address Code:
 Iterate through each three-address code instruction.
 For each instruction, determine the type of operation (e.g., assignment, arithmetic
operation, conditional jump, etc.).
 Generate Assembly Code:
 Translate each three-address code instruction into equivalent 8086 assembly language
instructions.
 Handle different types of operations accordingly:
 Assignment Operation:
 Translate the assignment operation, such as x = y, to MOV instruction.
 Arithmetic Operations:
 Translate arithmetic operations like addition (x = y + z), subtraction,
multiplication, and division to appropriate ADD, SUB, MUL, or DIV
instructions.
 Conditional Jumps:
 Translate conditional jumps (e.g., if x > y goto label) to CMP and Jxx
instructions.
 Unconditional Jumps:
 Translate unconditional jumps (e.g., goto label) to JMP instructions.
 Function Calls and Returns:
 Translate function calls (call function) and returns (ret) appropriately.
 Memory Operations:
 Handle operations involving memory locations, using MOV instructions.
 Label Handling:
 Deal with labels and generate labels in the assembly code.
 Symbol Table Handling:
 Update the symbol table as needed for variable assignments and usage.
 Generate Final Assembly Code:
 Combine all the generated assembly code instructions into the final output.
 Output or Save Assembly Code:
 Output the generated 8086 assembly code to a file or another suitable destination.
 Optimizations (Optional):
 Apply optimization techniques to improve the generated assembly code's efficiency if
desired.
 Error Handling:
 Implement error handling mechanisms to identify and report errors in the input three-
address code.
 Testing:
 Thoroughly test the generated assembly code with various input programs to ensure
correctness and performance.
 Documentation:
 Document the generated assembly code and any specific details related to the compilation
process.

SOURCE CODE:

class AssemblyCodeGenerator:

def __init__(self):

self.assembly_code = []

self.label_count = 0

defgenerate_label(self):

label = f'L{self.label_count}'

self.label_count += 1

return label

defgenerate_assembly(self, three_address_code):

for instruction in three_address_code:

operation = instruction[0]

if operation == '=':

# Assignment

dest, source = instruction[1], instruction[2]


self.assembly_code.append(f'MOV {dest}, {source}')

elif operation == '+':

# Addition

dest, op1, op2 = instruction[1], instruction[2], instruction[3]

self.assembly_code.append(f'ADD {dest}, {op1}, {op2}')

elif operation == '-':

# Subtraction

dest, op1, op2 = instruction[1], instruction[2], instruction[3]

self.assembly_code.append(f'SUB {dest}, {op1}, {op2}')

elif operation == 'if<':

# Conditional Jump (if op1 < op2, jump to label)

op1, op2, label = instruction[1], instruction[2], instruction[3]

self.assembly_code.append(f'CMP {op1}, {op2}')

self.assembly_code.append(f'JL {label}')

defprint_assembly(self):

for line in self.assembly_code:

print(line)

defmain():

# Example three-address code

three_address_code = [

('=', 'a', '5'),

('=', 'b', '10'),

('+', 'c', 'a', 'b'),

('-', 'd', 'c', 'a'),

('if<', 'c', 'd', 'L1'),

('=', 'e', '1'),

('JMP', 'L2'),

('L1:',),

('=', 'e', '0'),


('L2:',)

# Generate assembly code

generator = AssemblyCodeGenerator()

generator.generate_assembly(three_address_code)

# Print the generated assembly code

generator.print_assembly()

if __name__ == "__main__":

main()
VALUE ADDED PROGRAMS

Experiment 2:

OBJECTIVE:

Write program, to convert NFA to DFA.

ALGORITHM:

 Initialize:
 Create an empty set to represent states in the DFA.
 Create an empty set to represent states in the DFA that have been visited.
 Define an empty set for the DFA transitions.
 Compute ε-Closure:
 Compute the ε-closure of the start state of the NFA. This will be the initial state of the
DFA.
 Create DFA Transition Table:
 For each state set in the DFA:
 For each input symbol (excluding ε):
 Find the set of NFA states that can be reached from the current state set
using the input symbol.
 Compute the ε-closure of the union of NFA states obtained in the
previous step.
 This becomes the next state for the current state set and input symbol in
the DFA.
 Repeat Until No New States:
 Repeat step 3 until no new states are added to the DFA.
 Keep track of visited state sets to avoid redundant computations.
 Identify Accept States:
 Mark a state set in the DFA as an accept state if it contains at least one accept state from
the NFA.
 Finalize DFA:
 The set of states in the DFA is the collection of all state sets obtained during the process.
 The transitions represent the computed transitions for each state set and input symbol.
 The start state is the ε-closure of the start state of the NFA.
 The accept states are the state sets in the DFA marked as accept states.
 Output DFA:
 The DFA is now constructed and ready for use.

The algorithm essentially simulates the behavior of the NFA, exploring all possible state combinations
and transitions to build the corresponding DFA. The ε-closure operation is crucial for handling epsilon
transitions in the NFA. The process continues until no new states are discovered in the DFA.
SOURCE CODE:

#include <stdio.h>
int main()
{
int nfa[5][2];
nfa[1][1]=12;
nfa[1][2]=1;
nfa[2][1]=0;
nfa[2][2]=3;
nfa[3][1]=0;
nfa[3][2]=4;
nfa[4][1]=0;
nfa[4][2]=0;
int dfa[10][2];
int dstate[10];
int i=1,n,j,k,flag=0,m,q,r;
dstate[i++]=1;
n=i;

dfa[1][1]=nfa[1][1];
dfa[1][2]=nfa[1][2];
printf("\nf(%d,a)=%d",dstate[1],dfa[1][1]);
printf("\nf(%d,b)=%d",dstate[1],dfa[1][2]);

for(j=1;j<n;j++)
{
if(dfa[1][1]!=dstate[j])
flag++;
}
if(flag==n-1)
{
dstate[i++]=dfa[1][1];
n++;
}
flag=0;
for(j=1;j<n;j++)
{
if(dfa[1][2]!=dstate[j])
flag++;
}
if(flag==n-1)
{
dstate[i++]=dfa[1][2];
n++;
}
k=2;
while(dstate[k]!=0)
{
m=dstate[k];
if(m>10)
{
q=m/10;
r=m%10;
}
if(nfa[r][1]!=0)
dfa[k][1]=nfa[q][1]*10+nfa[r][1];
else
dfa[k][1]=nfa[q][1];
if(nfa[r][2]!=0)
dfa[k][2]=nfa[q][2]*10+nfa[r][2];
else
dfa[k][2]=nfa[q][2];

printf("\nf(%d,a)=%d",dstate[k],dfa[k][1]);
printf("\nf(%d,b)=%d",dstate[k],dfa[k][2]);

flag=0;
for(j=1;j<n;j++)
{
if(dfa[k][1]!=dstate[j])
flag++;
}
if(flag==n-1)
{
dstate[i++]=dfa[k][1];
n++;
}
flag=0;
for(j=1;j<n;j++)
{
if(dfa[k][2]!=dstate[j])
flag++;
}
if(flag==n-1)
{
dstate[i++]=dfa[k][2];
n++;
}
k++;
}
return 0;
}
OUTPUT:

f(1,a)=12
f(1,b)=1
f(12,a)=12
f(12,b)=13
f(13,a)=12
f(13,b)=14
f(14,a)=12
f(14,b)=1
Sample Quizzes/Viva-questions

LO-1:
PRE LAB QUESTIONS

1. What is token?
2. What is lexeme?
3. What is the difference between token and lexeme?
4. Define phase and pass?
5. What is the difference between phase and pass?
6. What is the difference between compiler and interpreter?

LAB ASSIGNMENT

1. Write a program to recognize identifiers.


2. Write a program to recognize constants.
3. Write a program to recognize keywords and identifiers.
4. Write a program to ignore the comments in the given input source program.

POST LAB QUESTIONS

1. What is lexical analyzer?


2. Which compiler is used for lexical analyzer?
3. What is the output of Lexical analyzer?
4. What is LEX source Program?
LO 2:

PRE LAB QUESTIONS:

1. What is top-down parsing?


2. What are the disadvantages of brute force method?
3. What is context free grammar?
4. What is parse tree?
5. What is ambiguous grammar?
6. What are the derivation methods to generate a string for the
given grammar? 7. What is the output of parse tree?

LAB ASSIGNMENT:

1. Write a program to compute FIRST for the following grammar?


E-> TE'
E'->+TE'/î
T->FT’
T'->*FT'/î
F-> (E)/i
2. Write a program to compute FIRST for the following grammar?
S->iCtSS’
S’->eS/ î
3. Write a program to construct predictive parsing table for the
following grammar? S🡪iCtSS’
S’->eS/ î

POST LAB QUESTIONS

1. What is Predictive parser?


2. How many types of analysis can we do using Parser?
3. What is Recursive Decent Parser?
4. How many types of Parsers are there?
5. What is LR Parser?
LO 3:

PRE-LAB QUESTIONS

1 Why bottom-up parsing is also called as shift reduce parsing?


2 What are the different types of bottom up parsers?
3 What is mean by LR (0) items?
4 Write the general form of LR(1) item?
5 What is YACC?

LAB ASSIGNMENT

1 Write a program to compute FOLLOW for the following


grammar? E🡪 TE'
E'->+TE'/î
T->FT’
T'->*FT'/î
F-> (E)/i

2 Write a program to construct LALR parsing table for the following


grammar. S->iCtSS’
S’->eS/ î

POST-LAB QUESTIONS:

1. What is LALR parsing?


2. What is Shift reduced parser?
3. What are the operations of Parser?
4. What is the use of parsing table?
5. What is bottom up parsing?
LO 4:

PRE-LAB QUESTIONS
1 What are the functions we use to construct a syntax tree?
2 What is Meta data?
3 How list of identifiers are represented using BNF rules?
4 What is three address code?
5 What are the record structures we use to represent three address code?

LAB ASSIGNMENT

1 Write YACC for the desktop calculator?


2 Write BNF rules for the following grammar?
E->E+T/T
T-> T*F/F
F-> (E)/id

POST-LAB QUESTIONS:
1. What is Abstract Syntax tree?
2. What are BNF Rules?
3. What is DAG representation?
4. How LALR (1) states are generates?
5. In which condition the user has to supply more information to YACC?
LO 5:

PRE-LAB QUESTIONS

1 What are the different forms of object code?


2 What is mean by relocatable object code?
3 What is the cost of register to register operation?
4 What is address descriptor?
5 What is register descriptor?

LAB ASSIGNMENT

1 Write a program to generate the code for the following three address code
statements? A=B+C
W=X-Y
2 Write a program to generate the code for the following three address code
statements? W=(A+B)*C

POST-LAB QUESTIONS

1. What is target code?


2. What is machine code?
3. What is Cross compiler?
4. Give the example for cross compiler?
5. What is the difference between syntax & Semantics?
LIST OF STUDENTS B.TECH 3RD YEAR (5TH SEMESTER)
SECTION-E
Department of Computer Science & Engineering

S.NO AKTU ROLL NO NAME OF STUDENTS SECTION


1 2100680100241 PRAGYESHA PRAGHAVA BHARDWAJ EG1
2 2100680100242 PRAKHARSAHU EG1
3 2100680100243 PRANAVMITTAL EG1
4 2100680100244 PRASHAANT EG1
5 2100680100245 PRASHANTYADAV EG1
6 2100680100246 PRASUKJAIN EG1
7 2100680100247 PRATHNA DHALL EG1
8 2100680100248 PRATHU DWIVEDI EG1
9 2100680100249 PRAYASCHAUDHARY EG1
10 2100680100250 PRERNASHARMA EG1
11 2100680100251 PRIYANSHU CHAUHAN EG1
12 2100680100252 PRIYANSHU GOYAL EG1
13 2100680100253 PRIYANSHU KASHYAP EG1
14 2100680100254 PRIYEVRATARYA EG1
15 2100680100255 PURVI RASTOGI EG1
16 2100680100256 RADHIKA GUPTA EG1
17 2100680100257 RAGHAVVERMA EG1
18 2100680100258 RAJNISHKUMAR EG1
19 2100680100259 RAMVASHISHTHA EG1
20 2100680100260 RASHI GUPTA EG1
21 2100680100261 RASHI SHARMA EG1
22 2100680100262 RISHAB CHAUDHARY EG1
23 2100680100263 RISHABHGOYAL EG1
24 2100680100264 RISHABHYADAV EG1
25 2100680100265 RITIKCHAUDHARY EG1
26 2100680100266 RITIKA SINGH EG1
27 2100680100267 RIYA EG1
28 2100680100268 RIYACHAUDHARY EG1
29 2100680100269 RIYANSHI GOEL EG1
30 2100680100270 RUCHI PANDEY EG1
31 ] 2100680100271 SAANVINEGI EG1
32 2100680100272 SACHIN EG1
33 2100680100273 SAFDERHUSSAINZAIDI EG1
34 2100680100274 SAIYAM AGARWAL EG2
35 2100680100275 SAKSHAMPANDEY EG2
36 2100680100276 SAKSHISHARMA EG2
37 2100680100277 SAMRIDHI SHARMA EG2
38 2100680100278 SARTHAKPANWAR EG2
39 2100680100279 SARTHAKSAINI EG2
40 2100680100280 SATAKSHI TOMAR EG2
41 2100680100281 SHAGUN EG2
42 2100680100282 SHAMBHAVI SHUKLA EG2
43 2100680100283 SHIKHA CHAUDHARY EG2
44 2100680100284 SHIV ARORA EG2
45 2100680100286 SHOBHITJAIN EG2
46 2100680100287 SHREYASHARMA EG2
47 2100680100289 SHRISHTI GUPTA EG2
48 2100680100290 SHRIYANSHGOEL EG2
49 2100680100291 SHRUTI JAIN EG2
50 2100680100292 SHRUTI MISHRA EG2
51 2100680100293 SHRUTI MITTAL EG2
50 2100680100294 SHRUTI TRIPATHI EG2
52 2100680100295 SHUBHMUDGAL EG2
53 2100680100296 SHUBHANKAR EG2
54 2100680100297 SHUCHI VERMA EG2
55 2100680100299 SIDHARTHSINGH EG2
56 2100680100300 SNEHA AGGARWAL EG2
57 2200680109021 SHIVAMPANWAR EG2
58 2200680109023 SUDHANSHU EG2
59 2100680110043 RISHABHJAIN EG2
60 2100680110042 RAHULMIGLANI EG2
61 2100681520058 YASHBHARDWAJ EG2
62 2100681550031 JYOTI KUMARI EG2
63 2100681530010 ARPITSHARMA EG2
LIST OF STUDENTS B.TECH 3RD YEAR (5TH SEMESTER)
SECTION-F
Department of Computer Science & Engineering

S.NO AKTU ROLL NO NAME OF STUDENTS SECTION


1 2100680100301 SNEHA VERMA FG1
2 2100680100302 SONU FG1
3 2100680100303 SPARSHSHARMA FG1
4 2100680100304 SPARSHSINGHAL FG1
5 2100680100305 SRISHTI DAGAR FG1
6 2100680100306 SUDHANSHMALIK FG1
7 2100680100307 SUDHARMSINGH FG1
8 2100680100308 SUDHIRKUMAR FG1
9 2100680100309 SUKTI JAIN FG1
10 2100680100310 SUMITCHAUDHARY FG1
11 2100680100311 SURYANSHGOSHWAMI FG1
12 2100680100312 SWAPNILGAUR FG1
13 2100680100313 TANU FG1
14 2100680100314 TANU DHAKA FG1
15 2100680100315 TANVIBANSAL FG1
16 2100680100316 TANVIKHATIYAN FG1
17 2100680100317 TANYAGARG FG1
18 2100680100318 TARANGBISHNOI FG1
19 2100680100319 TARUNKUMAR FG1
20 2100680100320 TEJASWINI FG1
21 2100680100322 TUSHARLATIYAN FG1
22 2100680100323 TUSHTI SINGH FG1
23 2100680100324 UDAYPRATAPSINGH FG1
24 2100680100325 UDITKUMAR FG1
25 2100680100326 UDITKUMARSINGH FG1
26 2100680100327 UJJWALSHARMA FG1
27 2100680100328 UPENDRA YADAV FG1
28 2100680100329 UTKARSHRANA FG1
29 2100680100330 UTKARSHTYAGI FG1
30 2100680100331 VAIBHAV TYAGI FG1
31 2100680100332 VANI GAUTAM FG1
32 2100680100333 VANSHSHARMA FG1
33 2100680100334 VANSHTOMAR FG2
34 2100680100335 VANSHIKA GARG FG2
35 2100680100336 VANSHIKA GOEL FG2
36 2100680100337 VANSHIKA JINDAL FG2
37 2100680100338 VANSHIKA VISHNOI FG2
38 2100680100339 VARNANKSHARMA FG2
39 2100680100341 VARUNPATEL FG2
40 2100680100342 VASU TYAGI FG2
41 2100680100343 VATSALSHARMA FG2
42 2100680100344 VEDANSHKUMAR FG2
43 2100680100345 VIDUSHI BHARDWAJ FG2
44 2100680100346 VIKRANTTOMAR FG2
45 2100680100347 VINEETGOLA FG2
46 2100680100348 VIVEKCHAUHAN FG2
47 2100680100349 VRINDA GUPTA FG2
48 2100680100350 YASHCHAUDHARY FG2
49 2100680100352 YASHMITTAL FG2
50 2100680100353 YASHPOONIA FG2
51 2100680100354 YASHRANA FG2
50 2100680100355 YASHRASTOGI FG2
52 2100680100356 YASHSHARMA FG2
53 2100680100357 YASHSHARMA FG2
54 2100680100358 YASHUPADHYAY FG2
55 2100680100359 YOGINDERSINGH FG2
56 2200680109027 VIKASHCHAUHAN FG2
57 2200680109003 AMITKUMAR FG2
58 2100681550047 PRIYANK MISHRA FG2
59 2100681550048 PRIYANSHU RAWAT FG2
60 2100681550001 AARYAN RANA FG2
61 2100680130028 KATYAYNI SHARMA FG2
62 2100681530040 RAJATKUMAR FG2
63 200680100342 VAIBHAV MAAN FG2
64 200680100301 SHAURYA PRATAP SINGH FG2
SESSIONAL 1ST, 2ND & PUT MARKS

STUDENTS MARKS B.TECH 3RD YEAR (5TH SEMESTER)

SECTION-E

S.NO ROLL NO NAME SESSIONAL -1st SESSIONAL -2nd PUT


(60) (60) (100)
1 2100680100241 P R BHARDWAJ 59 60 98
2 2100680100242 PRAKHARSAHU 56 57 93
3 2100680100243 PRANAVMITTAL 40 40 54
4 2100680100244 PRASHAANT 10 14 11
5 2100680100245 PRASHANTYADAV 40 34 50
6 2100680100246 PRASUKJAIN 51 58 71
7 2100680100247 PRATHNA DHALL 34 30 71
8 2100680100248 PRATHU DWIVEDI 42 46 53
9 2100680100249 PRAYASCHAUDHAR
Y 48 42 70
10 2100680100250 PRERNASHARMA 55 58 90
11 2100680100251 PRIYANSHU
CHAUHAN 46 40 66
12 2100680100252 PRIYANSHU GOYAL AB AB 16
13 2100680100253 PRIYANSHU
KASHYAP 13 4 26
14 2100680100254 PRIYEVRATARYA 35 32 45
15 2100680100255 PURVI RASTOGI 56 50 92
16 2100680100256 RADHIKA GUPTA 59 51 73
17 2100680100257 RAGHAVVERMA 49 45 61
18 2100680100258 RAJNISHKUMAR 21 0 29
19 2100680100259 RAMVASHISHTHA AB 8
20 2100680100260 RASHI GUPTA 42 AB 50
21 2100680100261 RASHI SHARMA 40 41 80
22 2100680100262 RISHAB
CHAUDHARY 13 10 62
23 2100680100263 RISHABHGOYAL 58 60 96
24 2100680100264 RISHABHYADAV 30 2 7
25 2100680100265 RITIKCHAUDHARY 20 24 4
26 2100680100266 RITIKA SINGH 20 18 0
27 2100680100267 RIYA 36 30 23
28 2100680100268 RIYACHAUDHARY 40 40 56
29 2100680100269 RIYANSHI GOEL 20 AB 1
30 2100680100270 RUCHI PANDEY 59 60 96
31 2100680100271 SAANVINEGI 16 9 10
32 2100680100272 SACHIN 26 6 49
33 2100680100273 SAFDERHUSSAINZAI
DI AB AB 8
34 2100680100274 SAIYAM AGARWAL 24 0 24
35 2100680100275 SAKSHAMPANDEY 31 AB 25
36 2100680100276 SAKSHISHARMA 45 39 54
37 2100680100277 SAMRIDHI SHARMA 59 59 95
38 2100680100278 SARTHAKPANWAR 20 5 3
39 2100680100279 SARTHAKSAINI 28 AB 45
40 2100680100280 SATAKSHI TOMAR 20 AB 0
41 2100680100281 SHAGUN AB 54 80
42 2100680100282 SHAMBHAVI
SHUKLA 30 31 40
43 2100680100283 SHIKHA
CHAUDHARY 47 32 75
44 2100680100284 SHIV ARORA 36 35 87
45 2100680100286 SHOBHITJAIN 56 AB 80
46 2100680100287 SHREYASHARMA 53 50 83
47 2100680100289 SHRISHTI GUPTA 30 18 45
48 2100680100290 SHRIYANSHGOEL 0 AB 26
49 2100680100291 SHRUTI JAIN 51 54 60
50 2100680100292 SHRUTI MISHRA 58 58 98
51 2100680100293 SHRUTI MITTAL 49 53 91
50 2100680100294 SHRUTI TRIPATHI 30 30 76
52 2100680100295 SHUBHMUDGAL 40 30 70
53 2100680100296 SHUBHANKAR 26 7 32
54 2100680100297 SHUCHI VERMA AB 45 57
55 2100680100299 SIDHARTHSINGH 12 2 44
56 2100680100300 SNEHA AGGARWAL 54 59 95
57 2200680109021 SHIVAMPANWAR 20 0 6
58 2200680109023 SUDHANSHU 25 AB
59 2100680110043 RISHABHJAIN 53 55 80
60 2100680110042 RAHULMIGLANI 57 40 87
61 2100681520058 YASHBHARDWAJ 44 49 62
62 2100681550031 JYOTI KUMARI 40 43 50
63 2100681530010 ARPITSHARMA 35 13 74
SESSIONAL 1ST, 2ND & PUT MARKS

STUDENTS MARKS B.TECH 3RD YEAR (5TH SEMESTER)

SECTION-F

S.NO ROLL NO NAME SESSIONAL -1st SESSIONAL -2nd PUT


(60) (60) (100)
1 2100680100301 SNEHA VERMA 58 58 94
2 2100680100302 SONU 46 36 63
3 2100680100303 SPARSHSHARMA 38 6 62
4 2100680100304 SPARSHSINGHAL 5 15 29
5 2100680100305 SRISHTI DAGAR
56 60 96
6 2100680100306 SUDHANSHMALIK 33 36 68
7 2100680100307 SUDHARMSINGH AB 2 14
8 2100680100308 SUDHIRKUMAR 7 45 67
9 2100680100309 SUKTI JAIN 58 59 94
10 2100680100310 SUMITCHAUDHAR
Y 31 16 72
11 2100680100311 SURYANSHGOSHW
AMI 5 36 34
12 2100680100312 SWAPNILGAUR 34 AB 55
13 2100680100313 TANU 48 58 79
14 2100680100314 TANU DHAKA 56 53 97
15 2100680100315 TANVIBANSAL 59 60 99
16 2100680100316 TANVIKHATIYAN 26 AB 60
17 2100680100317 TANYAGARG 59 60 89
18 2100680100318 TARANGBISHNOI 31 AB 42
19 2100680100319 TARUNKUMAR AB AB
20 2100680100320 TEJASWINI 59 60 98
21 2100680100322 TUSHARLATIYAN 45 0 42
22 2100680100323 TUSHTI SINGH AB AB 26
23 2100680100324 UDAYPRATAPSING
H 50 50 65
24 2100680100325 UDITKUMAR 16 7 22
25 2100680100326 UDITKUMARSINGH 50 55 18
26 2100680100327 UJJWALSHARMA 55 57 62
27 2100680100328 UPENDRA YADAV 43 40 40
28 2100680100329 UTKARSHRANA 33 AB 25
29 2100680100330 UTKARSHTYAGI 40 30 33
30 2100680100331 VAIBHAV TYAGI 45 50 69
31 2100680100332 VANI GAUTAM AB 40 42
32 2100680100333 VANSHSHARMA 50 42 76
33 2100680100334 VANSHTOMAR 26 23 7
34 2100680100335 VANSHIKA GARG 59 59 98
35 2100680100336 VANSHIKA GOEL AB 45 45
36 2100680100337 VANSHIKA JINDAL 45 51 79
37 2100680100338 VANSHIKA
VISHNOI 45 45 44
38 2100680100339 VARNANKSHARM
A 51 56 58
39 2100680100341 VARUNPATEL AB AB
40 2100680100342 VASU TYAGI 45 45 82
41 2100680100343 VATSALSHARMA 44 50 73
42 2100680100344 VEDANSHKUMAR 37 11 44
43 2100680100345 VIDUSHI
BHARDWAJ 53 53 70
44 2100680100346 VIKRANTTOMAR 28 AB 31
45 2100680100347 VINEETGOLA 35 47 58
46 2100680100348 VIVEKCHAUHAN AB 40 67
47 2100680100349 VRINDA GUPTA 53 40 90
48 2100680100350 YASHCHAUDHARY 50 50 85
49 2100680100352 YASHMITTAL AB AB
50 2100680100353 YASHPOONIA 0 45 49
51 2100680100354 YASHRANA 15 8 52
50 2100680100355 YASHRASTOGI 34 52 63
52 2100680100356 YASHSHARMA 54 54 85
53 2100680100357 YASHSHARMA 7 AB 4
54 2100680100358 YASHUPADHYAY 40 41 40
55 2100680100359 YOGINDERSINGH AB 31 41
56 2200680109027 VIKASHCHAUHAN 34 43 56
57 2200680109003 AMITKUMAR 39 45 68
58 2100681550047 PRIYANK MISHRA 26 20 43
59 2100681550048 PRIYANSHU
RAWAT 21 16 75
60 2100681550001 AARYAN RANA 18 20 26
61 2100680130028 KATYAYNI
SHARMA 31 44 53
62 2100681530040 RAJATKUMAR 44 41 78
63 200680100342 VAIBHAV MAAN AB AB 33
64 200680100301 SHAURYA PRATAP
SINGH 21 24 25

You might also like