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

CD Assignement 24 25

Uploaded by

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

CD Assignement 24 25

Uploaded by

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

Shri S’ad Vidya Mandal Institute of Technology

Department of Computer Engineering and Information Technology


B.E-IV(7TH SEMESTER )Computer Sceince & Engineering
ACADEMIC YEAR 2024-25(ODD SEMESTER)
SUB: COMPILER DESIGN SUB CODE: 3170701

Assignment-I (chapter 1,2)


1] Compare and Contrast Compilers and interpreters.

2] Explain Types of Compilers.

3] Explain Phases of Compilers with suitable example.(summer -13)

4] Explain Front End and Back end of compiler.

5] Explain Compiler Writing Tools.

6] What is pass in compiler? What is effect of reducing number of passes? [NOV-2011]

Text Book :
Compilers: Principles, Techniques and Tools by Aho, Lam, Sethi,
and Ullman, Second Edition, Pearson, 2014
Shri S’ad Vidya Mandal Institute of Technology
Department of Computer Science and Engineering
SUB: COMPILER DESIGN SUB CODE: 3170701

Assignment-II (chapter 3)

1] Write the two methods used in lexical analyzer for buffering the input. Which
technique is used for speeding up the lexical analyzer?
2] Describe language denoted by the following regular expression :(3.6)
A] 0 (0|1)*0
B] ((ε|0)1*)*
C] (0|1)*0(0|1)(0|1)
D] 0*|0*|0*|0*
E] (00|11)*((01|10)(00|11)* (01|10) (00|11)*)*
3] Construct nondeterministic finite automata for following regular expression
Using Thomson‟s Construction. Show the sequence of moves made by each in
Processing the input string ababbab (3.16)
a] (a|b)*
b] (a*|b*)*
c] ((ε|a)b*)*
d] (a|b)*abb(a|b)*
4] Construct DFA for (a|b)*abb(a|b)*.
5] Convert exercise 3 – c into DFA using subset construction method.
6] Construct DFA for (a|b)*abb(a|b)* using firstpos() and followpos().
7] Construct DFA and minimum state DFA for the following regular expression.(3.23)
A] (a|b)*a(a|b)
B] (a|b)*a(a|b)(a|b)
C] (a|b)*a(a|b)(a|b)(a|b)
8] Explain Lexical error found in Lexical analysis phase.
9] Define terms: pattern, lexeme, token
10] Draw transition diagram for following tokens.
1] relop
2] Identifier
3] Unsigned number
4] Whitespace
11] Explain LEx specification.
Shri S’ad Vidya Mandal Institute of Technology
Department of Computer Science and Engineering
SUB: COMPILER DESIGN SUB CODE: 3170701

Assignment-III (chapter 4: Syntax Analysis)


1] Explain Error-Recovery Strategies.
2] Define : Left Recursive Grammar. Check Following grammar is left recursive or not
,if yes, Remove left recursive from it.
[1] SaBDh
BBb|c
DEF
Eg| ε
Ff| ε
[2] SA
AAd|Ae|aB|aC
BbBC|f
Cg
[3] S(L)|a
LL,S|S

3] Consider the grammar

SaSbS|bSaS|ε

A] Show that this grammar is ambiguous by constructing two different leftmost


derivations for the sentence abab.
B] Construct the corresponding rightmost derivations for abab.
C] Construct the corresponding parse trees for abab.

4] Show that no left-recursive grammar can be LL(1).


5] Show that no LL(1) grammar can be ambiguous.
6] Test Whether the grammar is LL(1) or not, construct a predictive parsing
table for it.
SiEtSS‟|a
S‟eS| ε
Eb
7] Consider the following grammar, and test whether the grammar is LL(1) or
not.
S1AB| ε
A1AC|0C
B0S
C1
8] Construct SLR,CLR and LALR Parsing table for the following grammar.
SCC
CcC|d

9] Generate the SLR parsing table for the following Grammar(may-12 paper)

S->Aa|bAc|bBa
A->d
B->d
10] Compute the operator precedence matrix and precedence function for the
following grammar if it exists. +,*,-,/,id,num,( and ) are terminal symbols.
G→E
E→E+T|E-T|T
T→T*F|T/F/F
F→num|id|(E)
Shri S’ad Vidya Mandal Institute of Technology
Department of Computer Science and Engineering
SUB: COMPILER DESIGN SUB CODE: 3170701

Assignment –IV (chapter 5: Syntax Directed Translation)

1] Construct the parse tree and syntax tree for the expression ((a)+(b)) according to

(a) Syntax directed definition:

Production Sementic Rules


EE1+T E.nptr:=mknode(„+‟,E1.nptr,T.nptr)
E E1-T E.nptr:=mknode(„-„,E1.nptr,T.nptr)
ET E.nptr:=T.nptr
T(E) T.nptr:=E.nptr
Tid T.nptr:=mkleaf(id,id.entry)
Tnum T.nptr:=mkleaf(num,num.val)

Translation Scheme of fig 5.28

2] For the input expression (4*7+1)*2 , construct on annotated Parse tree according to the
syntax directed definition of figure given below.
Production Semantic Rules
LEn Print(E.val)
E E1+T E.val:=E.val+T.val
ET E.val:=T.val
TT1 *F T.val:= T1.val * F.val
T(E) T.val:=E.val
Fdigit F.val:=digit.lexval
TF T.val:=F.val

3] Construct the dag and identify the value numbers for the subexpression of the following
expression assuming from the left.
a+a+(a+a+a+(a+a+a+a))

4] Construct syntax directed translation scheme and definition that translate arithmetic
operation from infix to postfix in which an operator appears before its operand as for
figure xy- is a positive notaion for x-y . Give annonated parse tree for the input 9-5+2 and
9-5*2(“11” for string concatenation)

5] Construct Syntax directed translation scheme and definition that translate postfix notaion into
infix notation 95-2+ and 95-2*.
6] A robot is to be moved to a unit step in a direction specified as a command given to it. The
robot moves in the direction North, South, East, West on receiving N, S, E, W command
respectively & in the direction North-East , North-West, South-East, South-West on receiving A,
B, C, D commands respectively. The current position of the robot is initialized to (0,0) Cartesian
coordinates on receiving command Start. Write production rules for producing sequence of
commands and semantic rules for knowing position of a robot after receiving a sequence of
commands. Draw annotated parse tree for following sequence:
Start N N A A C C N (dec-12 paper)

7] Discuss synthesized and inherited attributes using a suitable grammar.

8] Explain with an appropriate example that how to perform bottom up evaluation of an inherited
attributes.
Shri S’ad Vidya Mandal Institute of Technology
Department of Computer Science and Engineering
SUB: COMPILER DESIGN SUB CODE: 3170701

Assignment-V(Chapter 7,8,9,10)

1. Explain various parameter passing methods.

2. Explain activation record. How is task divided between calling & called program for stack

Updating?
3. Explain heap, dynamic storage allocation techniques and synthesized attributes.
4. Draw syntax tree and DAG for following statement. Write three address codes from
both.
a = (a + b * c) ^ (b * c) + b * c
5. What is Intermediate form of the code? What are the advantages of it? What are
generally used intermediate forms? Write three address code for following expression.
(a+b)*(c+d)-(a+b+c)
6. Explain: Symbol Table Management. How symbol table differs from other data structures?
7. Compare: Static v/s Dynamic Memory Allocation
8. What are the limitations of static storage allocation? Explain the problem of dangling
references.
9. Translate the arithmetic expression a*-(b+c) into
1. Syntax tree
2. Postfix notation
3. Three address code
10. Translate the expression –(a+b)*(c+d)+(a+b+c) into
1. Quadruples Note : All three are type of n-tuple notation.
2. Triples
3. Indirect triples.
11. Explain any three code optimization methods with examples.
12. Explain Peephole optimization in detail.
13. Explain various issues in design of code generator.

You might also like