0% found this document useful (0 votes)
21 views

Assignment No 1 Compiler Design Assignment

Uploaded by

vishalsani72
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)
21 views

Assignment No 1 Compiler Design Assignment

Uploaded by

vishalsani72
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/ 18

Swami Keshvanand Institute of Technology, Management & Gramothan, Jaipur

Department of Computer Science & Engineering


Session 2024_25
Subject: Compiler Design (5CS4-02)
Max Marks- 40

Set assigned
S.no Roll Name Set assigned S.no Roll Name Set
assigned
1 22ESKCS300 Nitisha Vijay I 35 23ESKCS215 Nityam Kaushik X
2 22ESKCS301 Tanishka Jain 36 23ESKCS216 Priyansh
Khandelwal
3 22ESKCS302 Abhinav Soni 37 23ESKCS217 Riddhi Jangid XI
4 22ESKCS303 Tanisha Khandelwal 38 23ESKCS218 Sonali Sharma
5 22ESKCS304 Shreya Samariya II 39 23ESKCS219 Sudhansh Jain XII
6 22ESKCS838 Vikas 40 23ESKCS220 Suruchi Bharti
7 22ESKCS839 Vikas Maur 41 23ESKCS221 Tanishka Sain
8 22ESKCS840 Vikas Singh Gurjar 42 23ESKCS222 Utkarshika Jangid

9 22ESKCS841 Vishakha Nayak III


10 22ESKCS842 Vishal Gothwal
11 22ESKCS843 Vishal Saini
12 22ESKCS844 Vishal Songara
13 22ESKCS845 Vivek Meena IV
14 22ESKCS846 Yadumeet Singh
15 22ESKCS847 Yagya Joshi
16 22ESKCS849 Yash Jangid
17 22ESKCS850 Yash Karodiwal V
18 22ESKCS851 Yash Kumawat
19 22ESKCS852 Yash Tailor
20 22ESKCS853 Yashika
21 22ESKCS854 Yashveer Singh VI
Chouhan
22 22ESKCS855 Yashwender Singh
23 22ESKCS856 Yug Sharma
24 23ESKCS200 Aditya Singh
25 23ESKCS203 Anuj VII
26 23ESKCS204 Aseem Jain
27 23ESKCS205 Barkha Vijay
28 23ESKCS207 Dharmendra Singh
Shekhawat
29 23ESKCS208 Gajraj Singh VIII
30 23ESKCS209 Harshit Chhipa
31 23ESKCS210 Jatin Jain
32 23ESKCS212 Lokesh Sharma
33 23ESKCS213 Mohit Joshi IX
34 23ESKCS214 Nikhil Sharma

SET- I
Swami Keshvanand Institute of Technology, Management & Gramothan, Jaipur
Department of Computer Science & Engineering
Session 2024_25
Subject: Compiler Design (5CS4-02)
Max Marks- 40

QN. Question BL CO MM
What are the various phases of compiler? Explain the functions of each
Q1. phase with its input and output for example statement
3 1 10
A = X*Y.

Apply the concept of bootstrapping to explain how another compiler could


be built using a pre-existing compiler for a higher-level language. Provide an 3
Q2. 1 10
example.

What is Top-Down parser in syntax analysis? Generate the parse tree for the
Q3. givengrammar G:
G: EE+E | E-E | E*E
Eid 4 2 10
Also verify that the given word w=id + id * id belongs to the given grammar
or not,using top-down parsing? Also generate the parse tree for the given
string.

Consider the following given grammar:

Q4. G: EBB
BcB
4 2 10
Bd
Find the LR(0) parsing table and verify that the input “ccdd” is parsed with
LR(0) Grammar or not. Specify all necessary steps in LR(0) algorithm.
Swami Keshvanand Institute of Technology, Management & Gramothan, Jaipur
Department of Computer Science & Engineering
Session 2024_25
Subject: Compiler Design (5CS4-02)
Max Marks- 40

SET- II
QN. Question BL CO MM
Analyze the role of lexical analyzers in a compiler's front-end by examining
Q1. its interaction with the syntax analyzer. How does the recognition of tokens 3 1 10
impact the overall efficiency of the compilation process?

Given a set of tokens and their definitions, apply the process of token
recognition to manually simulate the output of a lexical analyzer for a 3
Q2. 1 10
specific input program

Construct an LR(0) parsing table for the following grammar:


Q3.

S xAy | xBy | xAz


AaS | q
4 2 10
Bq

and verify that the input “xaxqyy” is parsed with LR(0) Grammar or not.
Specify all necessary steps in LR(0) algorithm

Consider the following grammar:

Q4. G: EE +T | T
TT * F | F
4 2 10
F (E) | id

Compute the First and Follow for each non-terminal.


Swami Keshvanand Institute of Technology, Management & Gramothan, Jaipur
Department of Computer Science & Engineering
Session 2024_25
Subject: Compiler Design (5CS4-02)
Max Marks- 40

SET- III
QN. Question BL CO MM
Analyze how error handling in the lexical analysis phase can impact the
Q1. overall performance of the compiler. Provide examples of common errors
3 1 10
and explain the strategies used to recover from them.
Apply the concept of input buffering in lexical analysis to optimize token
recognition for a given source program. Explain how the use of buffering 3
Q2. improves efficiency 1
10
Write the steps to remove the left recursion and design LL(1) predictive
Q3. parser for the following Grammar:
4 2 10
G: E  E + E | E – E | E * E | E\E | (E) / id
Consider the following grammar G:
G: SL = R
Q4. S R
L*R 4 2 10
Lid
RL
Compute FIRST and Follow for each non-terminal.
Swami Keshvanand Institute of Technology, Management & Gramothan, Jaipur
Department of Computer Science & Engineering
Session 2024_25
Subject: Compiler Design (5CS4-02)
Max Marks- 40

SET- IV
Swami Keshvanand Institute of Technology, Management & Gramothan, Jaipur
Department of Computer Science & Engineering
Session 2024_25
Subject: Compiler Design (5CS4-02)
Max Marks- 40

QN. Question BL CO MM
Using a real-world example, apply the phases of a compiler to demonstrate
Q1. how code is translated from a high-level language to machine code, focusing 3 1 10
on the lexical and syntax analysis phases.

Analyze the role of lexical analyzers in a compiler's front-end by examining


its interaction with the syntax analyzer. How does the recognition of tokens 3
Q2. 1 10
impact the overall efficiency of the compilation process?

Design a LALR(1) parser for the following grammar:


Q3.
S aAd | bBd | aBc | bAc
A€ 4 2 10
B€
Where are a,b,c,d,e are terminals.

Consider the following grammar G:

Q4. G: SCC
CcC | d 4 2 10

Compute FIRST and Follow for each non-terminal.


Swami Keshvanand Institute of Technology, Management & Gramothan, Jaipur
Department of Computer Science & Engineering
Session 2024_25
Subject: Compiler Design (5CS4-02)
Max Marks- 40

SET- V
QN. Question BL CO MM
Apply the concept of input buffering in lexical analysis to optimize token
Q1. recognition for a given source program. Explain how the use of buffering 3 1 10
improves efficiency.

Apply the techniques of error handling in compilers to detect and report


lexical and syntactic errors in a given program 3 1
Q2. 10

Construct the CLR parsing table for the following grammar:


Q3.

SL=R|R
L *R | id
4 2 10
RL

Is the word id = *id parsed from the above grammar. Specify the all steps of
CLR parsing

Consider the following grammar G:

Q4.

SaAd | bBd | aBe | bAe


Ac 4 2 10
Bc

Compute FIRST and Follow for each non-terminal.


Swami Keshvanand Institute of Technology, Management & Gramothan, Jaipur
Department of Computer Science & Engineering
Session 2024_25
Subject: Compiler Design (5CS4-02)
Max Marks- 40

SET- VI
Swami Keshvanand Institute of Technology, Management & Gramothan, Jaipur
Department of Computer Science & Engineering
Session 2024_25
Subject: Compiler Design (5CS4-02)
Max Marks- 40

QN. Question BL CO MM
Analyze the impact of using a lexical analyzer generator like LEX on the
Q1. development of compilers and discuss its advantages over manual 3 1 10
implementation.

Analyze the bootstrapping process of a compiler by evaluating the steps


involved in self-hosting a compiler 3 1
Q2. 10

Show that the following grammar:


Q3.
G: S  AaAb | BbBa
A € 4 2 10
B €
Is a LL(1) grammar but not SLR(1).

Consider the following grammar G:

Q4. E TE’
E’+E | E
T FT’
T’T | €
4 2 10
FPF’
F’*F’ | €
F(E) | a | b | €
Compute FIRST and Follow for each non-terminal. Construct the predictive
parsing table for that. Also check the given grammar is LL(1) or not.
Swami Keshvanand Institute of Technology, Management & Gramothan, Jaipur
Department of Computer Science & Engineering
Session 2024_25
Subject: Compiler Design (5CS4-02)
Max Marks- 40

SET- VII
Swami Keshvanand Institute of Technology, Management & Gramothan, Jaipur
Department of Computer Science & Engineering
Session 2024_25
Subject: Compiler Design (5CS4-02)
Max Marks- 40

QN. Question BL CO MM
Illustrate the Analysis and Synthesis phase of compiler also categories all
Q1. phases of compiler according to their functioning. 3 1 10

Write a Regular Expression to identify the valid identifiers of C language is


such a way that:
Q2.
i)It can start only with underscore or alphabet followed by any number of
underscore, alphabets or digits.
3 1 10
ii) It should not contain any special character except underscore.
Also describe the shorthand and naming for Regular expressions with
respect to the above problem.

Identify the different red flags or blockers in a Context-Free Grammar (CFG)


Q3. that prevent the generation of a Top-Down Parser. Additionally, explain the
methods to eliminate these blockers, with particular emphasis on the 4 2 10
technique of left factoring and conversion of left recursion to right recursion
in CFG.

Consider the following grammar G and Design the LL(1) parser with parsing
table and parse tree for given input string id+id*id
Q4.
E TE’
E’+TE | €
4 2 10
T  FT’
T’  *FT’ | €
F  (E) | id
Swami Keshvanand Institute of Technology, Management & Gramothan, Jaipur
Department of Computer Science & Engineering
Session 2024_25
Subject: Compiler Design (5CS4-02)
Max Marks- 40

SET- VIII
QN. Question BL CO MM
Analyze the differences between compilers and interpreters in terms of their
Q1. working principles, advantages, and disadvantages. 3 1 10

Examine the relationship between a lexical analyzer and a parser, and


analyze how token generation errors during lexical analysis affect the
Q2. 3
subsequent phases of the compiler. Provide specific examples to support 1 10
your analysis.

Construct an SLR (1) parsing table for the following grammar:


Q3.
S 0S0 | 1S1 | 10
4 2 10
Parse the following word = 00100. Is this word belonging to SLR (1) parse
table or not. Show the stack implementation for the above word w.

Consider the following grammar G:

Q4. SiC t SS’ | a


S’eS | €
Cb
4 2 10

Compute FIRST and Follow for each non-terminal. Construct the predictive
parsing table for that. Also check if the given grammar is LL(1) or not.
Swami Keshvanand Institute of Technology, Management & Gramothan, Jaipur
Department of Computer Science & Engineering
Session 2024_25
Subject: Compiler Design (5CS4-02)
Max Marks- 40

SET- IX
Swami Keshvanand Institute of Technology, Management & Gramothan, Jaipur
Department of Computer Science & Engineering
Session 2024_25
Subject: Compiler Design (5CS4-02)
Max Marks- 40

QN. Question BL CO MM
Illustrate how the below input gets processed in compiler through each
Q1. phase with proper diagram along with the entries in Symbol Table through
symbol table management. 3 1 10
x=y+z*10

Construct an NFA for a regular expression (a|b)*(ab)*ausing Thompson


construction algorithm. 3 1
Q2. 10

Categories the grammar using Chomsky’s Normal Form with particular


Q3. emphasis on Context Free Grammar. Also define Ambiguous grammar with 4 2 10
suitable example.

Consider the following grammar G:

Q4. E TE’
E’ +TE’ | €
T FT’
T’ *FT’ | € 4 2 10
F (E) | id
Construct Recursive Descent Parser for input string id+id
Swami Keshvanand Institute of Technology, Management & Gramothan, Jaipur
Department of Computer Science & Engineering
Session 2024_25
Subject: Compiler Design (5CS4-02)
Max Marks- 40

SET- X
QN. Question BL CO MM
Analyze the relationship between the lexical analyzer and parser also
Q1. illustrate the steps of how a lexical analyzer is implemented? 3 1 10

Categorize the different compiler construction tools with particular emphasis


on LEX. Explain the working of LEX with suitable block diagram and describe 3
Q2. 1 10
Lex file format.

Consider the following grammar G:


Q3. 4 2 10
S  aAc | aB
Ab|c
A  ccd | ddc
Generate the Brute Force parsing with backtrekking for the given input string
addc

Categorize the different Error Recovery modes in the parsers. Also explain
how error handling is performed in parsers. 4 2 10
Q4.
Swami Keshvanand Institute of Technology, Management & Gramothan, Jaipur
Department of Computer Science & Engineering
Session 2024_25
Subject: Compiler Design (5CS4-02)
Max Marks- 40

SET- XI
QN. Question BL CO MM
Apply the concept of Cross Compiler to explain how a simple cross compiler
Q1. could be built using a pre-existing compiler that runs on one machine and 3 1 10
provides machine code for another machine. Provide an example.

Illustrate the process of execution of program in language processing system


with the help of proper diagram and particular emphasis on Compiler, 3
Q2. 1 10
Relocatable machine code,Loader and Linker.

Consider the following grammar G:


Q3.
S CC
CcC
Cd 4 2 10

Evaluate whether the given grammar is CLR(1) or not.

Categorize the different compiler construction tools with particular emphasis


Automatic Parser Generator Tool like YAAC. Explain the working of YAAC 4 2 10
Q4.
with suitable block diagram and describe format of specification file.
Swami Keshvanand Institute of Technology, Management & Gramothan, Jaipur
Department of Computer Science & Engineering
Session 2024_25
Subject: Compiler Design (5CS4-02)
Max Marks- 40

SET- XII
Swami Keshvanand Institute of Technology, Management & Gramothan, Jaipur
Department of Computer Science & Engineering
Session 2024_25
Subject: Compiler Design (5CS4-02)
Max Marks- 40

QN. Question BL CO MM
Apply the techniques of error handling in compilers to detect and report
Q1. lexical and syntactic errors in a given program and also explain the symbol 3 1 10
table management.

Categorize the different machine models of Automata. Also convert below


NFA to DFA.
Q2.

3 1 10

Q3.
Categorize the different parsing techniques with proper hierarchical 4 2 10
diagram.

Consider the following grammar G:

Q4. E  E+E
E  E*E
4 2 10
E  id

Evaluate Shift Reduce Parsing for the given input string id1+id2+id3.

You might also like