2025-2026 Assignment I - Compiler Design
2025-2026 Assignment I - Compiler Design
ASSIGNMENT SHEET
Set 1:
a. Convert the Regular Expression (a|b)* a into DFA.( May-June 2016) [CO1,L3]
b. Check whether the following grammar can be implemented using predictive
parser. Check whether the string “(a,a)” is accepted or not using predictive
parsing.
S (L)|a
LL,S|S [CO2,L3]
Set 2:
a. Consider the set of strings on {0,1} in which, every substring of 3 symbols has at
most two zeros. For example, 001110 and 011001 are in the language, but 100010 is
not. All strings of length less than 3 are also in the language. A partially completed
DFA that accepts this language is shown below. GATE 2012, SET 1[CO1, L3]
Complete the DFA and reduce the number of states so that the meaning does not change.
a. Consider the following context-free grammar where the start symbol is S and the set of
terminals is {a,b,c,d}.
SAaAb|BbBa
AcS|Epsilon
BdS|Epsilon
Construct LL(1) Parsing Table (GATE 2024 SET 2) [CO2, L3][CO2, L3]
Set 3:
[CO1, L3]
a. Construct NFA for the regular expression 10+(0+11)0*1 and convert it into DFA.
Further, formulate a minimized DFA it.
[CO1, L3]
b. Construct parsing table for the following grammar and find moves made by
predictive parser on input id+id*id. Compute and find FIRST and FOLLOW.
(Nov/Dec 2016)
E→E+T
E→ T
T→T*F
T→F
F→(E)/id
[CO2,L3]
a. Find the equivalent regular expression for the language L={ w |w ∈ {0,1} and w is
Set 5:
the set of all strings containing at least two 0’s.}. Construct a minimized DFA for this
Regular expression.
[CO1, L3]
b. Check whether the following grammar can be implemented using predictive
parser.Check whether the string “abfg” is accepted or not using predictive parsing.
(April/May 2022)
SA
AaB|Ad
B bBC|f
Cg
[CO2,L3]
Set 6:
a. Consider the Deterministic Finite-state Automaton (DFA) A shown below. The DFA
runs on the alphabet {0, 1}, and has the set of states {s, p, q, r}, with s being the start
state and p being the only final state. [GATE CSE 2023]
a. Convert the Regular Expression abb|(a|b)* to DFA and minimize it. (April May
2017)
[CO1, L3]
b. Construct the Predictive parser for the given grammar. [GATE CS 2003][CO2,L3]
S iEtS | iEtSeS | a
Eb
Set 8:
a. A cybersecurity analyst is designing a pattern matching system and needs to convert the
regular expression (01∣10)+ into an NFA. Create an NFA that accepts all strings that
match this regular expression, where the strings must contain at least one occurrence of
either "01" or "10". Show all states and transitions in your NFA diagram.
[CO1, L3]
b. Consider the following grammar,
S→uBDz
B→Bv|w
D→EF
E→y|€
F→x|€
1. Find First and Follow sets for above grammar.
2. Construct LL (1) parsing table.
[CO2,L3]
Set 9:
b. Find FIRST, and FOLLOW sets for this grammar; then construct the LL(1) parsing
table.
0. S′ → S $
1. S → ε
2. S → XS
3. B → \ begin {WORD}
4. E → \ end {WORD}
5. X → BSE
6. X → {S}
7. X → WORD
8. X → begin
9. X → end
10. X → \ WORD
Parse the input “{\begin{WORD}\end{WORD}} $” using LL (1) Parse table.
[CO2,L3]
Set 10:
a. Construct a NFA for the regular expression (ba*a+ ab*b)* (ab* + ba*) and convert it
into DFA.
[CO1, L3]
SiEtS|iEtSeS|a
E b
Also define the FIRST and FOLLOW procedures.
[CO2,L3]
Set 11:
a. A DFA is given below. Find the minimal DFA for the given DFA.
a. Find a regular expression that represents the set of all binary numbers that are
divisible by three. Assume that the string ϵ is divisible by three. Construct a
NFA for the same. Also, construct an equivalent minimized DFA for the NFA.
[GATE CSE 2021 SET 2[ [CO1, L3]
Set 13:
a. Find the equivalent regular expression for the language L={ w |w ∈ {0,1} and
w is the set of all strings containing at least two 0’s.}. Construct a minimized
DFA for this Regular expression.
[CO1, L3]
b. Show that the following grammar
SAa|bAc|dc|bda
Aa
is LALR but not SLR(1)
[CO2,L3]
Set 14
a. Let L= {w ∈ (0 + 1)*|w has even number of 1s}. Construct a minimized DFA for L.
[CO1, L3]
b. Give the algorithm for construction of LALR parsing table for the given grammar.
Using the algorithm for construction of LALR parsing table, construct the LALR
parsing table for the following grammar.
S’S
SaAd|bBd|aBe|bAc
Ac
Bc
[CO2,L3]
Set 15
a. Using the following lexical rules, specify the regular expressions for each:
(i) A floating-point number (e.g., 3.14, .25, 0.001)
(ii) A single-line comment that starts with // and continues to the end of a line
[CO1, L3]
b. Draw LR(1) states for the following grammar without left factoring and construct the
LR(1) parse table. Clearly indicate any conflicts. [CO2, L3]
1. S → G $
2. G → P
3. G → PG
4. P → id : R
5. R → id
6. R → id R
Set 16:
a. Write regular Expression for the set of strings that ends with 00 over the input alphabets
Σ={0,1}. Convert the obtained the regular expression to DFA.
[CO1, L3]
b. Write down the algorithm to eliminate left recursion and left factoring and apply both to
the following grammar and construct the predictive parsing table. [CO2,L3]
E→E+T|E-T|T,
T→a|b|(E)
Set 17:
a. Give DFAs accepting the languages over the alphabet {0,1} containing the set of all
strings such that the number of 1’s is even and the number of 0’s is a multiple of 3.
[CO1, L3]
b. Construct a LL(1) parsing table for the following grammar.
E --> TE'
E' --> +TE' | ε
T --> FT'
T' --> *FT' | ε
F --> id | (E)
[CO2,L3]
Set 18:
a. Construct RE for the language over the set z={a,b} in which total number of a’s are
divisible by 3 and convert the same to DFA.
[CO1, L3]
b. Design a LALR Parser for the following grammar and parse the input id=id.
SL=R|R
L *R|id
R L
[CO2,L3]
Set 19:
a. Convert the following ε-NFA to NFA and then convert the resultant NFA to DFA
[CO1, L3]
b. Consider the following grammar
SL=R
SR
L*R
Lid
RL
Discuss the LALR Parsing method for this grammar. List out canonical collections and
also construct a parsing table.
[CO2,L3]
Set 20:
a.Write regular Expression for the set of strings that ends with 01 over the input alphabets
Σ={0,1}. Convert the obtained the regular expression to DFA
[CO1, L3]
b. Consider CFG depicted below where “begin”, “end”, ”x” are all terminal symbol for the
grammar and stat is considered as the starting symbol for this grammar. Productions are
numbered in parenthesis and you can abbreviate “begin” to “b” and end to “e” respectively.
StatBlock
[CO1, L3]
Set 23:
a. Convert the given NFA to DFA
0 1
p {p.q} {p}
q {r,s} {t}
r {p,r} {t}
*s φ Φ
*t Φ φ
[CO1, L3]
b. Consider the following grammar
S AS|b
A SA|a
Construct the SLR Table for the grammar. Show the actions of the parser for the input
string “abab”.
[CO2,L3]
Set 24:
(01+1)*
Minimize the obtained DFA if possible.
b. Generate SLR parsing table for the following grammar [CO2, L3]
SAa|bAc|Bc|bBa
Ad
Bd
and parse the sentence ‘bdc’ and ‘dd’
[CO2,L3]
Set 25:
a. Construct a Deterministic Finite Automaton from the regular expression (x+y)x(x+y)* over
input alphabets Σ={x,y} [CO1, L3]
b. Consider the following grammar
S TL
Tint|float
L L,id|id
Parse the input string ‘int id,id’ using Shift Reduce Parser.
[GATE CS 2019][CO2,L3]
Set 26:
a. Minimize the following DFA [CO1, L3]
0 1
2 3
1
2 4 5
3 6 7
4 4 5
5 6 7
*6 4 5
7 6 7
δ € a b c
b. In the following grammar for certain statements, e and s are terminals standing for
conditional expressions and “other statements,” respectively.
stmt →if e then stmt
| if e then stmt else stmt
| while e do stmt
| begin list end
|s
Set 34:
a. Convert the regular expression. (a|b) * into minimized DFA [CO1, L3]
b. Consider the following grammar:
SS
SSS|a|ε
i) Construct the collection of sets of LR(0) items for this grammar and draw its goto
graph .
ii) Indicate the shift reduce and reduce and reduce- reduce conflict (if any) in the
various state of LR(0) parser.
[CO2,L3]
Set 35:
a. Convert the regular expression ((a|c)*)ac(ba)* into minimized DFA [CO1, L3]
b. Construct stack implementation of shift reduce parsing for the grammar. [CO2, L3]
E →E +E
E →E *E
E → (E)
E →id and the input string id1+id2*id3
Set 36:
a. Minimize the following DFA [CO1, L3]
q0 q5 q1
q1 q2 q6
*q2 q2 q0
q4 q5 q7
q5 q6 q2
q6 q6 q2
q7 q4 q6
q3 q2 q6
b. Convert the following pascal like grammar where terminals are in boldface:
EE*B
EE+B
EB
B0
B1 [CO2, L3]
Set 40:
a. Convert the NFA with ε into its equivalent DFA. [CO1, L3]
S → Aa
A → BD
B→b|ε
D→d|ε
Let a, b, d, and $ be indexed as follows:
a b d $
3 2 1 0
Compute the FOLLOW set of the non-terminal B and write the index values for the
symbols in the FOLLOW set in the descending order. (For example, if the FOLLOW set
is {a, b, d, $}, then the answer should be 3210)
[GATE CS 2019] [CO2, L3]
Set 41:
a. Formulate the regular expression to represent the set of all strings that begin with
01 and ends with 11. Convert this regular expression to DFA. [CO1, L3]
b. Find LALR for the given grammar and parse the sentence (a+b)*c.
[CO2,L3]
Set 42:
b. Consider the following CFG grammar over the non-terminals{X,Y,Z} and terminals
{a,c,d} with the productions below and start symbol Z. [CO2, L3]
X→a
X→Y
Z→d
Z→XYZ
Y→c
Y→ε
i. Compute the FIRST and FOLLOW sets of every non-terminal and the set of non
terminals that are nullable.
ii. Construct the predictive parsing table.
Set 43:
a. Give DFAs accepting the languages over the alphabet {0,1} containing the set
of all strings such that every 1 is followed immediately by 00. [CO1, L3]
b. Consider the following grammar
1. S→ A #
2. A→ a A b | c
Find LR(0) parsing table and parse the sentence a a c b b #
[CO2,L3]
Set 44:
a. Construct DFA for the regular Expression (a|b)*abb and try to minimize the obtained
DFA. [CO1, L3]
b. Explain ambiguous grammar G: E → E + E | E * E | (E) | - E | id for the sentence
id+id*id.
[CO2,L3]
Set 45:
a. Convert the regular expression (b|a)*abb(b|a)* into minimized DFA. [CO1, L3]
b. Consider the following context-free grammar where the set of terminals is {a,b.c.d.f}.
S daT|Rf
TaS|baT|epsilon
RcaTR|epsilon
Construct LL(1) parse table.
[CO2, L3]
Set 46:
a. Construct a minimum state automaton equivalent to the finite automaton [CO1, L3]
(Hint: State 1 is the Initial state)
a. Find the minimum state DFA for the given DFA [CO1, L3]
a. Write regular Expression for the set of strings that contains the substring ‘101’ over the
input alphabets Σ={0,1}. Convert the obtained the regular expression to DFA [CO1, L3]
b. A grammar symbol X (terminal or nonterminal) is useless if there is no derivation of the
form S wXy wxy That is, X can never appear in the derivation of any sentence. Elaborate
on the algorithm that is used to eliminate from a grammar all productions containing
useless symbols. Apply your algorithm to the grammar:
S →0|A
A → AB
B→1
[CO2,L3]
Set 50:
a. Find the minimum state DFA for the given DFA [CO1, L3]
Set 52:
a. Construct a minimum state automaton equivalent to the finite automaton [CO1, L3]
a. Formulate regular expression to represent the set of all strings which when interpreted
as a binary integer is a multiple of 3. Convert the same to DFA. [CO1, L3]
b. Building the LR Parse Table for LR(0) [CO2,L3]
(0) S’ →E $
(1) E →E || B
(2) E →B
(3) B →t
(4) B →f
Set 54:
a. Construct a minimum state automaton equivalent to the finite automaton [CO1, L3]
b. Generate top down paring table for the following grammar and parse the input string w =
cad [CO2,L3]
S → cAd A → ab | a
Set 55:
a. Construct Finite Automata equivalent to the regular expression (ab+a)* [CO1, L3]
b. Check whether the given grammar is suitable for predictive parsing. [CO2,L3]
A → AA | (A) | ε
Justify your answer
in detail.
Set 56:
δ 0 1
->q1 q2 q6
q2 q1 q3
*q3 q2 q4
q4 q4 q2
q5 q4 q5
*q6 q5 q4
Draw the table of distinguishability for this automaton. Construct the minimum state
equivalent DFA [CO1, L3]
b. Construct the LR(0) states for this grammar, and then determine whether it is an SLR
grammar. [CO2,L3]
0. S → B $
1. B → id P
2. B → id *(E )
4. P → (E)
5. E → B
6. E → B, E
Set 57:
a. Write regular expression for the language which is accepted by the following NFA and
convert it into DFA.
[CO1, L3]
b. Consider the following grammar G: [CO2,L3]
SXaY|Y
XbY|c
YX
i) Discuss the various steps involved in the construction of SLR parsing.
ii) Show the canonical collections of LR(0) items.
iii) Construct the SLR parsing table.
iv) Show the actions of the parser on the input string cac$.
Set 58:
a. Construct a minimized DFA from the regular expression 0*(01)(0/111)* [CO1, L3]
b. Construct the LALR parsing table for the following grammar. [CO2,L3]
S (L)|a
LL,S|S
Set 59:
a.Write regular Expression for the set of strings that starts with 00 over the input alphabets
Σ={0,1}. Convert the obtained the regular expression to DFA [CO1, L3]
b. Construct LALR parsing table for the following grammar. [CO2,L3]
SAA
AaA|b
Set 60:
SAA
AaA|b
Set 61:
a. Construct a minimized DFA from the regular expression (b/a)*baa [CO1, L3]
b. Design an SLR parser for the following grammar and parse the input id=id
S→L=R|R [CO2,L3]
L→*R|id
R→L
Set 62:
a. Convert the regular expression 1*0 (0+1)* to DFA where the input alphabets Σ={0,1}.
[CO1, L3]
b. Find SLR for the given grammar and parse the sentence (a+b)*c [CO2,L3]
E→E+E|E*E|(E)|id
Set 63:
b. Consider the five state DFA M accepting the Language L(M) ⸦(0+1) * shown below.
For any String wε(0+1)*, let n 0(w) be number of 0’s in w and n 1(w) be the number of
1’s in w.
(Hint: Give your opinion about each option given in the question)
c. Consider the following context-free grammar where the start symbol is S and the set of
terminals is {a,b,c,d}.
SAaAb|BbBa
AcS|Epsilon
BdS|Epsilon
Construct LL(1) Parsing Table (GATE 2024 SET 2) [CO2, L3]
CO1: The students will be able to elucidate different phases of a compiler and design a lexical
analyzer for a sample language, implement a scanner using LEX.
CO2: The students will be able to apply different parsing algorithms to develop the parsers for a
given grammar and implement parser using YACC.
L1: Remember; L2: Understand; L3: Apply
Register
Sl.No Number Name Sl.No
Number
1 953623104001 ABISRI M 1
2 953623104005 AMRUTHA V 2
3 953623104007 ANISH KUMAR R 3
4 953623104011 ARJUN S 4
5 953623104012 ARUNADEVI M 5
6 953623104013 ASMA M 6
7 953623104016 ATHISH M 7
8 953623104020 CHRISWIN PRAYSON J 8
9 953623104022 DEEPAK LINGARAJ M 9
10 953623104023 DEEPALAKSHMI M 10
11 953623104025 DHIVYA DHARSHINI A 11
12 953623104026 DHURKA DEVI S 12
13 953623104027 DILIBAN S M 13
14 953623104030 DIVYADHARSINI A 14
15 953623104031 DURGADEVI M 15
16 953623104035 HARISH N 16
17 953623104036 HARISHKUMAR I 17
18 953623104038 HEMAMALINI R 18
19 953623104040 JANARAMJI R 19
20 953623104042 JECI CARMEL A 20
21 953623104043 JEYASEELAN S 21
22 953623104044 J K KAVIYALAKSHMI 22
23 953623104045 JUMANA JASEELA J 23
24 953623104047 KARTHIKA A 24
25 953623104048 KARUPPASAMY A 25
26 953623104051 K S KAMALASRI 26
27 953623104052 LAKSHITHA S 27
28 953623104053 LALITH KRISHNA V M 28
29 953623104055 LOKESH KUMARAN M 29
30 953623104058 MOHAMED AMMA GULSHAN M 30
31 953623104060 M PRANAV 31
Register
Sl.No Number Name Sl.No
Number
32 953623104061 MUNEESWARAN M 32
33 953623104063 MUTHUMARI M 33
34 953623104065 MUVIYA M 34
35 953623104067 NAMEETHA K 35
36 953623104071 NITHYA SRI S 36
37 953623104073 PADMADHARSHINI B 37
38 953623104076 PASAM RAJAVARDHAN 38
39 953623104077 PAVITHRA M 39
40 953623104078 PRAVEEN KUMAR R 40
41 953623104079 PRINCE S 41
42 953623104080 PRIYADHRSHINI K 42
43 953623104083 RAJESWARI C 43
44 953623104084 RAMAKRISHNAN A 44
45 953623104086 RAM KUMAR S 45
46 953623104090 SAKTHI SUNDARI G 46
47 953623104091 SANDHIB K 47
48 953623104092 SANJAY P 48
49 953623104096 SATHYAPRIYA K 49
50 953623104098 SELVAMANI M 50
51 953623104099 SENTHATTI KALAI PANDIYAN P 51
52 953623104102 SHENBAGAPRIYA A 52
53 953623104103 SHRIJA A 53
54 953623104104 SINDHE MOHITH SIVA SAI 54
55 953623104105 SIVA K 55
56 953623104107 SIVAPRIYA A 56
57 953623104109 SONA S 57
58 953623104115 SRI PON MATHU SWASTHIK P 58
59 953623104116 SRI PRISHIGAA R 59
60 953623104122 UDHAYASANKARI R 60
61 953623104123 VASHINI J 61
62 953623104125 VIGNESH A P 62
63 953623104126 VIGNESHA S 63