You are on page 1of 15

L.J.

Institute of Engineering & Technology Semester: VII (2018)

Subject Name: Compiler Design


Subject Code:2170701
Faculty: Ms. Kinjal Patel

Sr. CHAPTER NO- 1 :Introduction : Marks


No
Overview of the Translation Process, A Simple Compiler, Difference between
interpreter, assembler and compiler. Overview and use of linker and loader,
types of Compiler, Analysis of the Source Program, The Phases of a Compiler,
Cousins of the Compiler, The Grouping of Phases, Lexical Analysis, Hard
Coding and Automatic Generation Lexical Analyzers, Front-end and Back-
end of compiler, pass structure
DESCRIPTIVE QUESTIONS
1 Explain the analysis synthesis model of compilation. List the factors that affect the design of 06
compiler. Also List major functions done by compiler.(May-2012)[LJIET]
2 What does the linker do? What does the loader do? What does the preprocess do? Explain their 04, 08
role(s) in compilation process.(May-2012)[LJIET]
Explain the roles of linker, loader and preprocessor. (Nov-2013)[LJIET]
3 What is a pass in a compiler? What is the effect of reducing the number of passes? (Nov- 04, 03
2011)(Nov-2017_New) [LJIET]
4 Find errors and identify the phase of compiler detecting them for following C program segment. 07
Justify your answers.(Dec-2012)[LJIET]
int fi( int);
char a[10], * cptr;
int k = 1 ; int j = 2;
float f;
cptr = a;
if (k);
fi(k);
fi( j )
++k;
*(cptr + 1 ) = 0 ;
++ a;
n + *k ;
5 Explain lexical analysis phase of a compiler and, for a statement given below, write output of all 07
phases (except of an optimization phase) of a complier. Assume a, b and c of type float
a = a + b * c * 2; .(Dec-2012)[LJIET]
6 Draw structure of Compiler. Also explain Analysis Phase in brief.(Nov-2013)[LJIET] 07
7 What is the pass of a compiler? Explain how the single and multi-pass compilers work.(May- 07
2014)[LJIET]
8 Explain the phases of compiler with an example.(May-2015)[LJIET] 07, 07,
Explain different phases of compiler.(May-2016)[LJIET] 07, 07,
Describe all phases of a compiler.(Nov-2016)[LJIET] 07
Explain various phases of compiler with example.(May-2017) [LJIET]
Explain phases of compiler with example. (April-2018_New)[LJIET]
9 Explain Semantic Analysis and Syntax Analysis phases of compiler with suitable example. Also 07
explain the reporting errors by these two phases.(Dec-2015)[LJIET]
10 Explain linker & loader.(Nov-2016)[LJIET]

Compiler Design (2170701) 2018 Page 1


L.J. Institute of Engineering & Technology Semester: VII (2018)

11 For a statement given below, write output of all phases (except that of optimization phase) of a 07
complier.(Nov-2016) [LJIET]
a=a+b*c;
12 Explain Semantic analysis and Syntax analysis phases of compiler with suitable example. Also 07
explain the errors generated by these two phases.(April-2017_New) [LJIET]
13 What is the difference between compiler and interpreter? (Nov-2017_New)[LJIET] 03
14 Explain analysis phase of the source program with example. (Nov-2017_New)[LJIET] 04
15 Define cross compiler, token and handle. (April-2018_New)[LJIET] 03
16 Define following terms: (May-2018)[LJIET] 03
i. Compiler
ii. Interpreter
iii. Assembler
Sr. CHAPTER NO- 2 :Lexical Analyzer: Marks
No
Introduction to Lexical Analyzer, Input Buffering, Specification of Tokens,
Recognition of Tokens, A Language for Specifying Lexical Analyzers, Finite
Automata From a Regular Expression, Design of a Lexical Analyzer
Generator, Optimization of DFA
DESCRIPTIVE QUESTIONS
1 Write a regular definition for the language of all strings of 0’s and 1’s with an even number of 0’s 07
and odd number of 1’s. Write an algorithm for eliminating left recursion.(Nov-2011)[LJIET]
2 Write the two methods used in lexical analyzer for buffering the input. Which technique is used 07, 07,
for speeding up the lexical analyzer? (Nov-2011)[LJIET] 07, 07,
Write a brief note on input buffering techniques to Lexical Analyzer.(Nov-2013)[LJIET] 07, 07,
Write a brief note on input buffering techniques.(May-2014)[LJIET] 04, 04
Explain Buffer pairs and Sentinels. (Nov-2014)[LJIET]
Write a short note on input buffering methods.(Nov-2016_New)[LJIET]
Explain input buffering methods.(May-2017)[LJIET]
Explain buffer pairs and sentinels. (Nov-2017_New)[LJIET]
Write a short note on input buffering method. (April-2018_New)[LJIET]
3 Find the Regular Expression corresponding to given statement, subset of {0,1}* 07

i. The Language of all strings containing at least one 0 and at least one
ii. The Language of all strings containing 0’s and 1’s both are even.
iii. The Language of all strings containing at most one pair of consecutive 1’s.
iv. The Language of all strings that do not end with 01.(May-2012)
4 How do the parser and scanner communicate? Explain with the block diagram communication 07, 07
between them. Also explain: What is input buffering?(May-2012)(May-2018) [LJIET]
5 Convert the following NFA-ε into equivalent NFA. Here ε is a Λ-transition.(May- 07
2012)[LJIET]

Compiler Design (2170701) 2018 Page 2


L.J. Institute of Engineering & Technology Semester: VII (2018)

6 Construct a DFA for a given regular expression (010+00)*(10)*.(May-2012)[LJIET] 07


7 Construct a DFA without constructing NFA for following regular expression. Find minimized 07
DFA.
a*b*a(a | b)*b*a#.(Dec-2012)[LJIET]
8 Construct a NFA for following regular expression using Thompson’s notation and then convert it 07
into DFA. aa*(b | c) a*c#.(Dec-2012)[LJIET]
9 Draw Deterministic Finite Automata for the binary strings ending with 10.(Nov-2013)[LJIET] 04
10 Write down the regular expression for the binary strings with even length.(Nov-2013) 03
11 Draw Deterministic Finite Automata for :(May-2014)[LJIET] 07
1. (0+1)*101(0+1)*
2. 10(0+1)*1
12 List out phases of a compiles. Write a brief not on Lexical Analyzer.(May-2014)[LJIET] 06
13 Draw Transition diagram of following:(Nov-2014)[LJIET] 07
i. relational operators.
ii. unsigned operator.
14 Construct minimum state DFA’s for following regular expressions.(Nov-2014)[LJIET] 07
i. (a|b)*a(a|b)
ii. (a|b)*a(a|b) (a|b)
15 What are regular expressions? Find the regular expression described by DFA 07
{{A,B},{0,1},δ,A,{B}}, where δ is detailed in following table .(May-2015)[LJIET]

Please note B is accepting state. Describe the language defined by the regular expression.
16 Construct the NFA using thompson’s notation for following regular expression and then convert 07
it to DFA. a+ (c |d) b*f # .(May-2015)[LJIET]
17 Construct DFA for following Regular expression. Use firstpos, lastpos and followpos functions to 07
construct DFA.(Dec-2015)[LJIET]
(a*|b*)*
18 Construct NFA for following Regular Expression using Thomson’s Construction. Apply subset 07
construction method to convert into DFA.(Dec-2015)[LJIET]
(a | b)*abb
Draw the DFA for the regular expression (a|b)*abb using set construction method
only.(May-2016)[LJIET]
Write an algorithm for Thompson’s construction method. Apply the algorithm to construct NFA
for following regular expression. (a | b)*abb. (Nov-2017_New)[LJIET]
19 What is regular expression, give all the algebraic properties of regular expression.(May- 07
2016)[LJIET]

Compiler Design (2170701) 2018 Page 3


L.J. Institute of Engineering & Technology Semester: VII (2018)

20 Draw the state transition diagram for the unsigned numbers.(May-2016)[LJIET] 07

21 Unsigned numbers are strings such as 5280, 39.37, 6.336E4 or 1.894E-4, give the regular 07
definitions for the above mentioned strings.(May-2016)[LJIET]
22 Convert the (a|b|c)*d*(a*|b)ac+# regular expression to DFA directly and draw its DFA.(May- 07
2016)[LJIET]
23 Convert the following regular expression into deterministic finite automata. (a+b)*abb(a+b)* 03
.(Nov-2011)[LJIET]
24 Construct DFA by syntax tree construction method .(May-2015)[LJIET] 07
a+ b* (c |d) f # Optimize the resultant DFA.
25 Construct DFA without constructing NFA for following regular expression: 07
a*b*a(a | b)b*a#
Minimize the same.(Nov-2016)[LJIET]
26 Construct NFA for following regular expression using Thompson’s notation and then convert it 07
into DFA.(Nov-2016)[LJIET]
a(b | c)*a*c#
27 Define the following terms: (Nov-2016_New)[LJIET] 07
1. Token
2. Pattern
3. Lexeme
4. Ambiguous grammar
5. Handle pruning
6. Compiler
7. DAG
28 Explain subset construction method for constructing DFA from an NFA with an example.(Nov- 07, 07
2016_New)[LJIET]
Explain subset construction method with an example. (May-2017)(April-2018_New) [LJIET]
29 Construct DFA for the following regular expression using syntax tree with firspos, laspos and 07, 07,
followpos function.(Nov-2016_New)[LJIET] 07
( a | b) *a
Draw DFA for the following regular expression using firstpos( ), lastpos ( ) and followpos ( )
functions. (April-2018_New)[LJIET]
( a | b) * a
Construct a DFA without constructing NFA for the following regular expression. (a | b) * a.
(May-2017)[LJIET]
30 Construct the NFA using thompson’s notation for following regular expression and then convert 07
it to DFA.(April-2017_New)[LJIET]
(a / b)* ab#
31 Explain role of lexical analyzer. (Nov-2017_New)[LJIET] 04
32 Draw transition diagram for relational operators. (April-2018_New)[LJIET] 04
33 Construct DFA for following regular expression without constructing NFA and optimize the 07
same. (May-2018)[LJIET]
( a | ε )* a b ( a | b )* #
34 Explain automatic generation of lexical analyzer and parser. (May-2018)[LJIET] 07
35 Define following terms: (May-2018)[LJIET] 04
i. Regular Expression
ii. Token
iii. Lexeme
iv. Pattern

Compiler Design (2170701) 2018 Page 4


L.J. Institute of Engineering & Technology Semester: VII (2018)

Sr. CHAPTER NO- 3 :Parsing Theory: Marks


No
TOPIC:1 Top Down Parsing Algorithms
DESCRIPTIVE QUESTIONS
1 Is the following grammar suitable for LL(1) parsing? If not make it suitable for LL(1) parsing. 07
Compute FIRST and FOLLOW sets. Generate the parsing table.(Nov-2011)[LJIET]
S→AB
A→Ca | ϵ
B→BaAC | c
C→b | ϵ
2 Draw the transition diagrams for predictive parsers for the following grammar.(Nov- 07
2011)[LJIET]
E → TE’
E’→ +TE’ | ϵ
T → FT’
T’ → *FT’ | ϵ
F → (E) | id
3 Explain non-recursive predictive parsers. Draw the block diagram of it.(May-2012)[LJIET] 04
4 Construct predictive parsing table for following.(May-2012)[LJIET] 07
S -> A
A -> aB | Ad
B -> bBC | f
C -> g
5 Eliminate left recursion from the following grammar and rewrite the Grammar.(May- 03
2012)[LJIET]
S -> Aa | b
A -> Ac | Sd | ε
6 Perform the Left factoring of following Grammar: (May-2012)[LJIET] 04
A ad | a | ab | abc | b
7 Find out FIRST & FOLLOW set for all the Nonterminals.(May-2012)[LJIET] 06
S AcB | cbB | Ba
Ada | BC
Bg | ε
Ch | ε
8 Test whether the following grammar is LL (1) or not. Construct predictive parsing table for 07
it.(May-2012)[LJIET]
S1AB | ε
A1AC | 0C
B0S
C1
9 Write unambiguous grammar for producing arithmetic expression consisting of symbols id, +, - , 07
/, $. Find first & follow of non terminal symbols of the grammar for non recursive predictive
parser. Construct parse table and parse following string.(Dec-2012)[LJIET]
id – id + id – id $.
10 Write down C program for Recursive Descend Parser for :(Nov-2013)[LJIET] 07
S  ABC B 1B | Λ A 0A1 | Λ C1C0 | Λ
11 Write down the algorithm for left factoring.(Nov-2013)[LJIET] 03
12 Draw parsing table for Table Driven Parser for the given grammar. Is the grammar LL(1)? .(Nov- 07
2013)[LJIET]
A AaB | x B BCb | Cy C Cc | Λ

Compiler Design (2170701) 2018 Page 5


L.J. Institute of Engineering & Technology Semester: VII (2018)

13 What do you understand by a handle? Explain the stack implementation of shift reduce parser 07
with the help of example.(Nov-2014)[LJIET]
14 Explain recursive-descent and predictive parsing..(Nov-2014)[LJIET] 07
15 Implement the following grammar using Table Driven parser and check whether it is LL(1) 14or 07
not. S -> aBDh, B -> cC, C -> bC / ^, D -> EF, E -> g / ^, F-> f / ^ .(May-2014)[LJIET]
16 Implement the following grammar using Recursive Descent Parser.(May-2014)[LJIET] 08
S -> Aa | bAc | bBa, A -> d, B -> d
17 For the following grammar D  T L ; L  L , id | id T  int | float (May-2015)[LJIET] 07
1)Remove left recursion (if required)
2)Find first and follow for each non terminal for Resultant grammar
3)Construct LL(1) parsing table
4)Parse the following string (show stack actions clearly) and draw parse tree for the input: int id,
id;
18 Develop a predictive parser for the following grammar.(May-2015)[LJIET] 07
S’->S S->aA|b|cB|d A->aA|b B->cB|d
19 How top down and bottom up parser will parse the string ‘bbd’ using grammar A  bA | d. 07
Show all steps clearly.(May-2015)[LJIET]
20 Construct LL(1) parsing table for the following Grammar:(Dec-2015)[LJIET] 07
S(L)|a
LL,S|S
21 Define: Left Recursive. State the rule to remove left recursive from the grammar. Eliminate left 07
recursive from following grammar.(Dec-2015)[LJIET]
S  Aa | b
A  Ac | Sd | f
22 What is left recursion? Eliminate the left recursion from the following grammar.(May- 07
2016)[LJIET]
EE+T|T
TT*F|F
F  ( E ) | id
23 Design the FIRST SET and FOLLOW SET for the following grammar.(May-2016)[LJIET] 07
EE+T|T
TT*F|F
F  ( E ) | id
24 (i) Compare top-down and bottom-up parser. 07
(ii) Explain right-most-derivation-in-reverse with the help of an example.(Nov-2016)[LJIET]
25 Draw transition diagrams corresponding to production rules for arithmetic expressions consisting 07
of operators + and ^ for predictive parser. Explain how parsing takes place for the same using
transition diagrams.(Nov-2016)[LJIET]
26 Explain left factoring with the help of an example..(Nov-2016)[LJIET] 04, 03
Write a rule of Left factoring a grammar and give example. (Nov-2017_New)[LJIET]
27 Construct LL(1) Parsing table for the following grammar. Also show moves made by input string 07
: abba.(Nov-2016_New)[LJIET]
S  aBa
B bB | ^
28 Check following grammar is LL (1) or not?(April-2017_New)[LJIET] 07
S -> aB | €
B -> bC | €
C -> cS | €
29 What is left factoring and left recursion? Explain it with suitable example.(April- 07
2017_New)[LJIET]
30 How do you check whether the grammar is LL (1) or not? Justify your answer with appropriate 07
Compiler Design (2170701) 2018 Page 6
L.J. Institute of Engineering & Technology Semester: VII (2018)

example. (May-2017)[LJIET]
31 Check the following grammar is left recursive or not. Justify your answer. If Left recursive then 04
make grammar as non-left recursive. (April-2018_New)[LJIET]
S(L)|a
LL,S|S
32 Consider the following grammar and construct the corresponding left most and right most 03
derivations for the sentence abab. (April-2018_New)[LJIET]
S -> aSbS | bSaS | €
33 Find out FIRST and FOLLOW for the following grammar. (April-2018_New)[LJIET] 04
S -> 1AB | €
A -> 1AC | 0C
B -> 0S
C -> 1
34 Check whether the given grammar is LL (1) or not? (May-2018)[LJIET] 07
S -> aAC | bB
B -> f | g
A -> Abc | Abd | e
C -> h |i
TOPIC:2 Bottom Up Parsing Algorithms
DESCRIPTIVE QUESTIONS
1 Compute the operator precedence matrix and precedence function for the following grammar if it 07
exists. +,*,-,/,id,num,( and ) are terminal symbols.(Nov-2011)[LJIET]
G→E
E→E+T|E-T|T
T→T*F|T/F/F
F→num|id|(E)
2 Consider the following grammar.(Nov-2011)[LJIET] 07
E → E+T | T
T → TF | F
F → F* |a |b
1) Construct the SLR parsing table for this grammar.
2) Construct the LALR parsing table.
3 Construct the canonical parsing table for the following Grammar.(May-2012)[LJIET] 07
S’S
SCC
CcC|d
4 Generate the SLR parsing table for the following Grammar.(May-2012)[LJIET] 07
SAa|bAc|bBa
Ad
Bd
5 Write unambiguous production rules for producing arithmetic expression consisting of symbols id, 07
*, -, ( ) and ^, where ^ represents exponent. Parse following string using shift – reduce parser:
id – id * id ^ id * (id ^ id ) ^ id. Explain various conflicts of a shift – reduce parser.(Dec-
2012)[LJIET]
6 Explain SLR parser in detail with the help of an example.(Dec-2012)(May-2016)[LJIET] 07, 07,
Explain SLR parser. How is its parse table constructed?(Nov-2016)[LJIET] 07, 07,
Explain SLR parsing method with example.(Nov-2016_New)(May-2017)(April-2018_New) 07, 07
[LJIET]
7 Explain Shift-Reduce parsing with suitable example.(Nov-2013)[LJIET] 07
Compiler Design (2170701) 2018 Page 7
L.J. Institute of Engineering & Technology Semester: VII (2018)

8 Write down steps to set precedence relationship for Operator Precedence Grammar. Design 07
precedence table for:(Nov-2013)[LJIET]
E  E+ T | T T  T * F | F F  a
9 Write SLR parsing table for : S  T T  CC C  cC C  d .(Nov-2013)[LJIET] 08
10 What is bottom-up parsing? Discuss Shift Reduce parsing technique in brief. What is a handle? 08
.(May-2014)[LJIET]
11 Define an Operator Precedence Grammar. Also write down the rules to find relationship between 08
each pair of terminal symbols.(May-2014)[LJIET]
12 Construct SLR parsing table for the following grammar : (May-2014)[LJIET] 10
E->E+T E->T T->T*F T->F F->(E) F->a
13 Show that the following grammer S-> AaAb | BbBa A -> ϵ B -> ϵ is LL(1) but not SLR(1). (Nov- 07
2014)[LJIET]
14 Show that the following grammer S->Aa | bAc | dc | bda A->d is LALR(1) but not SLR(1). (Nov- 07
2014)[LJIET]
15 Show that the following grammer:(Nov-2014)[LJIET] 07
S->Aa | bAc | Bc | bBa A->d B->d is LR(1) but not LALR(1).
16 Construct the collection of sets of LR(0) items for the following grammar. S-> Aa | bAc | dc | bda 07
A->d .(May-2015)[LJIET]
17 Construct an SLR Parsing table for the following grammar.(May-2015)[LJIET] 07
E->E-T|T T->F↑T|F F->(E) | id
18 Check whether the following grammar is CLR or not.(Dec-2015)[LJIET] 07
S  Aa | bAc | Bc | bBa
Ad
Bd
19 Construct SLR Parsing Table for the following grammar.(Dec-2015)[LJIET] 07
S 0S0 | 1S1 | 10
20 Explain Operator Precedence Parsing method with example.(Dec-2015)[LJIET] 07, 07,
Explain operator precedence parser by giving example for constructing a precedence graph and 07, 07,
table.(Dec-2012)[LJIET] 07
Write a short note on operator precedence parsing with an example.(Nov-2016_New)[LJIET]
Explain operator precedence parsing method.(May-2017)[LJIET]
Explain Operator precedence Parsing technique in detail. (May-2018)[LJIET]
21 Differentiate SLR, Canonical LR and LALR. Also justify the statement “A class of grammar 07
that can be parsed using LR methods is a proper subset of the class of grammars that can be
parsed with predictive parser”.(May-2016)[LJIET]
22 Explain LALR parser in detail. Support your answer with example.(Dec-2015)[LJIET] 07
23 Where do we use operator precedence parsing technique? Give the general precedence table for 07
operating precedence parsing, considering all the generalized rules.(May-2016)[LJIET]
24 Apply shift reduce parser for parsing following string using unambiguous grammar.(Nov- 07
2016)[LJIET]
id - id * id – id
25 Construct a precedence graph, precedence table for operator precedence parser to be used for 07
parsing a string consisting of id, - , * , $. Parse following string.(Nov-2016)[LJIET]
$ id - id * id * id $
26 Check that following grammar is LALR or not.(Nov-2016_New)[LJIET] 07
S L=R
S R
L*R
L id
RL
27 Construct CLR parsing table for following grammar.(April-2017_New)[LJIET] 07
Compiler Design (2170701) 2018 Page 8
L.J. Institute of Engineering & Technology Semester: VII (2018)

S -> aSA | €
A -> bS | c
28 Show that following grammar is not a SLR (1) grammar.(April-2017_New)[LJIET] 07, 07
S -> AaBa | BbBa
A -> €
B -> €
Check the following grammar is LR(1) or not.(May-2017)[LJIET]
S  AaAb
S BbBa
A^
B ^
29 Define operator precedence grammar. Construct precedence matrix and precedence graph for 07
arithmetic grammar as shown below:(April-2017_New)[LJIET]
E -> E + T | T
T -> T * F | F
F -> (E) | id
30 Check given grammar is LL(1) but not SLR(1). (Nov-2017_New)[LJIET] 07
S -> AaAb | BbBa
A -> €
B -> €
31 What is operator grammar? Generate precedence function table for following grammar. (Nov- 07
2017_New)[LJIET]
E -> EAE | id
A -> + | *
32 Define handle and handle pruning. Explain the stack implementation of shift reduce parser with 07
the help of example. (Nov-2017_New)[LJIET]
33 What is operator grammar? Check the following grammar is operator or not. Justify your answer. 03
(April-2018_New)[LJIET]
E -> EOE
E -> id
O -> * | + | -
34 Construct CLR parsing table for the following grammar. (April-2018_New)[LJIET] 07
S -> CC
C -> cC | d
35 Construct a SLR parsing table for following grammar. (May-2018)[LJIET] 07
S -> aAb | bB
A -> Aa | ϵ
B -> Bb |ϵ
36 Construct the LALR parsing table for the following grammar. (May-2018)[LJIET] 07
S -> CC
C -> aC
C -> d
TOPIC:3 Syntax-Directed Definitions( Bottom-Up Evaluation of S-Attributed
Definitions, L-Attributed Definitions)
1 Write a syntax directed definition for desk calculator. Justify whether this is an S-attributed 07, 07
definition or L-attributed definition. Using this definition draw annotated parse tree for 3*5+4n.
(Nov-2011)(May-2018)[LJIET]
2 What is inherited attribute? Write syntax directed definition with inherited attributes for type 07, 07,
declaration for list of identifiers. Show annotated parse tree for the sentence real 07
id1,id2,id3.(Nov-2011)[LJIET]
What is inherited attribute? Write syntax directed definition with inherited attributes for type

Compiler Design (2170701) 2018 Page 9


L.J. Institute of Engineering & Technology Semester: VII (2018)

declaration for list of identifiers. (April-2018_New)[LJIET]


What is Inherited attribute? Explain with suitable example.(Nov-2013)[LJIET]
3 A robot is to be moved to a unit step in a direction specified as a command given to it. The robot 07
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:(Dec-2012)[LJIET]
Start N N A A C C N
4 Write a syntax directed definition of a simple desk calculator and draw an annotated parse tree for 06
4*3 + 2*5 n.(May-2014)[LJIET]
5 Differentiate Synthesized and Inherited attributes.(May-2014)[LJIET] 04
Discuss differences between inherited attributes and synthesized attributes.(May-2017)[LJIET]
6 Construct a Syntax-Directed Translation scheme that translates arithmetic expressions from 07
intfix into postfix notation. Show the application of your scheme to the string “3*4+5*2”.(Nov-
2014)[LJIET]
7 Explain with an appropriate example how to perform bottom up evaluation of an inherited 07
attributes.(Nov-2014)[LJIET]
8 Discuss synthesized and inherited attributes using a suitable grammar.(May-2015)[LJIET] 07, 07
Discuss synthesized attributes and inherited attributes in details.(Nov-2016_New)[LJIET]
9 Show syntax directed definition for simple desk calculator. Also show annotated parse tree for 07, 07
3*5+4n, where n indicates newline.(Dec-2015)(April-2018_New)[LJIET]
10 Give the translation scheme that converts infix to postfix expression for the following grammar 07
and also generate the annotated parse tree for input string 7+3+2.(Dec-2015)[LJIET]
E  E+T
ET
T0|1|2|3|4|5|6|7|8|9
11 Write syntax directed Defination for translating following grammar for postfix notation. Also 07
draw annotated parse tree for 9-5+2.(May-2012)[LJIET]
expr -> expr + term
expr -> expr – term
term -> 0 | 1 |…..|9
12 What is attributed grammar? Which phase of the compilation process does it facilitate? Explain 03
with example.(May-2012)[LJIET]
13 Write production and semantic rules for producing and analyzing statements like : 07
int * ip , i , j , *ip1;
float * fp , f; (Nov-2016)[LJIET]
14 Explain synthesized attributes with the help of an example.(Nov-2016)[LJIET] 07
15 Write S-attributed syntax directed definition for simple desk calculator. Draw annotated parse 07
tree for any valid input.(Nov-2016_New)[LJIET]
16 Develop a syntax directed definition for following grammar.(April-2017_New)[LJIET] 07
E -> TE’
E’ -> +TE’ | €
T -> ( E )
T -> id
17 Write a grammar to declare variables with data type int or float or char. Also develop a syntax 07
directed definition for that. Draw the dependency graph for same.(April-2017_New)[LJIET]
18 Explain syntax directed translation scheme with example.(May-2017)[LJIET] 07
19 Give the translation scheme that converts infix to postfix notation. Generate the annotated parse 03
tree for input string 3-5+4. (Nov-2017_New)[LJIET]
Compiler Design (2170701) 2018 Page 10
L.J. Institute of Engineering & Technology Semester: VII (2018)

20 Define syntax tree. What is s-attributed definition? Explain construction of syntax tree for the 07
expression a-4+c using SDD. (Nov-2017_New)[LJIET]
21 Write Syntax Directed Definition to produce three address code for the expression containing the 04
operators := , + , - (unary minus), ( ) and id. (Nov-2017_New)[LJIET]
TOPIC:4 Using Ambiguous Grammars , Parser Generators, Automatic
Generation of Parsers
DESCRIPTIVE QUESTIONS
1 Consider the grammar 04, 07
S -> SS+ | SS* | a
Show that the string aa+a* can be generated by the grammar.
Construct the parse tree for it. Is the grammar ambiguous? Justify.(Dec-2012)(Nov-2016)[LJIET]
2 Write production rules for producing following language. Strings of 0’s and 1’s with equal 03
numbers of 0’s and 1’s.(Dec-2012)[LJIET]
3 Draw transition diagrams corresponding to production rules for operators +, - , *, / and id for a 07
predictive parser. Explain how parsing takes place for it.(Dec-2012)[LJIET]
4 Write ambiguous and unambiguous production rules for if then else construct. Illustrate parsing 07
using both types of rules by giving an example. Also explain left factoring and its use.(Dec-
2012)[LJIET]
5 What is the difference between parse tree and syntax tree? Write appropriate grammar and draw 07
parse as well as syntax tree for a*(a-a^a).(Nov-2013)[LJIET]
6 Explain the following:(May-2015)[LJIET] 07
1) The Handle
2) Left Factoring
3) Directed Acyclic Graph
4) Conflicts in LR Parsing
5) Parser Generator
6) Dependency Graph
7) Locality of reference
7 Write a context free grammar for arithmetic expressions. Develop a syntax directed definition for 07
the grammar. Draw an annotated parse tree for the input expression: (3*2+2)*4 (May-
2015)[LJIET]
8 Write short note on context free grammar (CFG) explain it using suitable example.(May- 07
2016)[LJIET]
9 What is the difference between parse tree and syntax tree? Draw the parse tree for following 04
expression: a= a + a * b + a * b * c – a / b + a * b and write three address code for it.(May-
2012)[LJIET]
10 Write unambiguous production rules for if then else construct.(Nov-2016)[LJIET] 03
Sr. CHAPTER NO- 4 :Error Recovery: Marks
No
Error Detection & Recovery, Ad-Hoc and Systematic Methods

DESCRIPTIVE QUESTIONS
1 How can panic mode and phrase level recovery be implemented in LR parsers? Consider the 07
expression grammar :E → E + E | E * E | (E) | id
Prepare the SLR parsing table with error detection and recovery routines.(Nov-2011)[LJIET]
2 Explain: Error Recovery Strategies in Compiler in brief.(May-2012)(May-2014)(Nov- 07, 07,
2014)[LJIET] 07, 07,
Explain all error recovery strategies using suitable examples.(May-2016)[LJIET] 07, 04,
Discuss various error recovery strategies of compiler.(Nov-2016_New)[LJIET] 07
Explain error recovery strategies used by parser. (Nov-2017_New)[LJIET]
Compiler Design (2170701) 2018 Page 11
L.J. Institute of Engineering & Technology Semester: VII (2018)

Write down short note on Error – Recovery Strategies. (May-2018)[LJIET]


3 Explain how panic mode recovery can be implemented.(Nov-2013)[LJIET] 07, 03
Explain panic mode recovery strategy. (April-2018_New)[LJIET]
4 List the errors generated by the syntax analysis phase. Discuss error handling methods in the 07
syntax analysis phase.(May-2015)[LJIET]
Sr. CHAPTER NO- 5 :Intermediate Code Generation :
No
Different Intermediate Forms, Syntax Directed Translation Mechanisms And
Attributed Mechanisms And Attributed Definition.
DESCRIPTIVE QUESTIONS
1 Translate the arithmetic expression a*-(b+c) into 07,03
1. Syntax tree
2. Postfix notation
3. Three address code.(Nov-2011)(Nov-2017_New)[LJIET]
2 Translate the expression –(a+b)*(c+d)+(a+b+c) into 07
1. Quadruples 2. Triples 3. Indirect triples.(Nov-2011)[LJIET]
3 What is Intermediate form of the code? What are the advantages of it? What are generally used 07
intermediate forms? Write N-Tuple notation for: (a+b)*(c+d)-(a+b+c).(May-2012)[LJIET]
4 Explain how type checking & error reporting is performed in a compiler.(Dec-2012)(May- 03
2016)[LJIET]
5 Explain quadruple, triple and indirect triple with suitable example.(Nov-2013)(Nov- 07, 07,
2014)(April-17_New)(April-2018_New)[LJIET] 07, 04
6 Convert the following into quadruple, triple and indirect triple forms : -(a+b)*(c-d).(May- 06
2014)[LJIET]
7 Convert the following statement into triple, indirect triple and quadruple forms. 07
A= (B+C) $ E + (B+C) *F (May-2015)[LJIET]
8 What is intermediate code? What is its importance? Discuss various representations of three 07
address code.(May-2015)(Nov-2016_New)[LJIET]
9 Translate following arithmetic expression:(Dec-2015)[LJIET] 07
- ( a * b ) + ( c + d ) – ( a + b + c + d ) into
1] Quadruples
2] Triple
3] Indirect Triple
10 Translate the expression – (a*b)+(c*d)+(a*b*c) into 07
1. Quadruples
2. Triples
3. Indirect triples.(May-2016)[LJIET]
11 Draw syntax tree and DAG for the statement:(May-2016)[LJIET] 04
a = (a * b + c) ^ (b + c) * b + c. Write three address codes from both.
12 Draw syntax tree and DAG for following statement. Write three address codes from both. 07
a = (a + b * c) ^ (b * c) + b * c ^ a ; (Nov-2016)[LJIET]
13 Construct DAG for a + a * (b- c) + (b – c) * d. also generate three address code for same. (April- 07, 03
2017_New)(April-2018_New)[LJIET]
14 Write a short note on various representations of three address code.(May-2017)[LJIET] 07
15 What is importance of intermediate code? Discuss various representations of three address code 07
using the given expression. a = b * -c + b * -c. (Nov-2017_New)[LJIET]
16 What is intermediate code? Explain different types of intermediate code representations. Also 07
discuss importance of intermediate code. (May-2018)[LJIET]
17 Draw syntax tree and DAG for following statement. [LJIET] 04

Compiler Design (2170701) 2018 Page 12


L.J. Institute of Engineering & Technology Semester: VII (2018)

a = (a + b * c) ^ (b * c) + b * c Write three address codes from both.


Sr. CHAPTER NO- 6 :Run Time Memory Management :
No
Source Language Issues, Storage Organization, Storage-Allocation Strategies,
and Access to Non local Names, Parameter Passing, Symbol Tables, and
Language Facilities for Dynamic Storage Allocation, Dynamic Storage
Allocation Techniques
DESCRIPTIVE QUESTIONS
1 Explain activation tree and control stack.(Nov-2011)[LJIET] 04
2 What are the limitations of static storage allocation? Explain the problem of dangling 03
references.(Nov-2011)[LJIET]
3 For what purpose compiler uses symbol table? How characters of a name are stored in symbol 04
table? (Nov-2011)[LJIET]
4 Explain the static scope rule and dynamic scope rule.(Nov-2011)[LJIET] 03
5 Explain the structure of an activation record with all its components.(May-2012)[LJIET] 04
6 Explain: Symbol Table Management. How symbol table differs from other data structures? 03
(May-2012)[LJIET]
7 Compare: Static v/s Dynamic Memory Allocation.(May-2012)(Nov-2013)(April- 04, 03,
2018_New)[LJIET] 04
8 What is a symbol table? Discuss any two data structures suitable for it & compare their merits 07
/demerits. Also compare one pass & two pass compilers.(Dec-2012)[LJIET]
9 Explain activation record. How is task divided between calling & called program for stack 04,07
updating? .(Dec-2012)(Nov-2016)[LJIET]
10 Explain various parameter passing methods.(Dec-2012)(Nov-2016)[LJIET] 03, 07,
Explain the following parameter passing methods.(Nov-2016_New)[LJIET] 04, 04
1. Call-by-value
2. Call-by-reference
3. Copy-Restore
4. Call-by-Name
Explain parameter passing techniques for procedure. (Nov-2017_New)[LJIET]
Explain any two methods of parameter passing. (April-2018_New)[LJIET]
11 Explain heap, dynamic storage allocation techniques and synthesized attributes.(Dec- 07
2012)[LJIET]
12 Explain Stack Allocation and Activation Record Organization in brief.(Nov-2013)(Nov- 06,07
2014)[LJIET]
13 What is the use of a symbol table? How the identifiers are stored in the symbol table? .(May- 07, 07
2014)(Nov-2014)[LJIET]
14 Write a note on static and dynamic memory allocation. What do you mean by dangling reference? 07
(May-2014)[LJIET]
15 What is an activation record? Explain how they are used to access various local and global 07, 07
variables .(May-2014)(May-2016)[LJIET]
16 Elaborate the term “Activation Record” in detail.(May-2015)[LJIET] 07
17 Write a short note on Symbol Table Management.(Dec-2015)(April-2017_New)[LJIET] 07, 07
18 Explain various dynamic storage allocation techniques.(Dec-2015)[LJIET] 07, 07
Explain Dynamic storage allocation technique.(Nov-2016_New)[LJIET]
19 What is a symbol table? Discuss the most suitable data structure for it by stating merits / 04
demerits.(Nov-2016)[LJIET]
20 Explain Activation record and Activation tree in brief.(April-2017_New)[LJIET] 07

Compiler Design (2170701) 2018 Page 13


L.J. Institute of Engineering & Technology Semester: VII (2018)

21 Explain symbol table with two data structures suitable for it.(May-2017)[LJIET] 07
22 Explain static storage allocation technique.(May-2017)[LJIET] 07
23 Explain activation record organization in brief.(May-2017)[LJIET] 07
24 What is activation record? Explain stack allocation of activation records using example. (Nov- 07
2017_New)[LJIET]
25 What is activation tree? (Nov-2017_New)[LJIET] 03
26 What is symbol table? For what purpose , compiler uses symbol table? 03
(April-2018_New)[LJIET]
27 Write a short note on activation record. (April-2018_New)[LJIET] 04
28 Write difference(s) between stack and heap memory allocation. (April-2018_New)[LJIET] 03
29 Discuss various Storage allocation strategies in detail. (May-2018)[LJIET] 07
30 Explain various data structures used in symbol table management. (May-2018)[LJIET] 07
31 Explain activation tree, control stack, the Scope of Declaration and Bindings of Names. (May- 07
2018)[LJIET]
Sr. CHAPTER NO- 7:Code Optimization : Marks
No
Global Data Flow Analysis, A Few Selected Optimizations like Command Sub
Expression Removal, Loop Invariant Code Motion, Strength Reduction etc
DESCRIPTIVE QUESTIONS
1 Write an algorithm for global common subexpression elimination.(Nov-2011)(Nov- 07
2014)[LJIET]
2 Explain various code optimization techniques.(May-2012)(Nov-2014)(May-2015)(May- 04, 07,
2017)[LJIET] 07, 07
3 Explain any three types of optimization techniques.(Dec-2012)[LJIET] 04, 07,
Discuss any three methods for code optimization.(Nov-2016_New)[LJIET] 07, 07
Explain any three code optimization techniques with example.(Dec-2015)(April-
2018_New)[LJIET]
4 Write down the algorithm for partitioning of basic blocks.(Nov-2013)[LJIET] 07
5 Define a following: Basic block, Constant folding, Natural loop, Handle.(April- 07
2017_New)[LJIET]
6 Define dominators. Construct dominator tree for following graph.(April-2017_New)[LJIET] 07

7 Explain three loop optimization techniques with example. (Nov-2017_New)[LJIET] 03


8 What is code optimization? Explain data flow equation. (Nov-2017_New)[LJIET] 04
9 Explain function preserving transformations with example. (Nov-2017_New)[LJIET] 07
10 Write Short notes on (May-2018)[LJIET] 07
i. Local and loop optimization
ii. induction variable elimination

Compiler Design (2170701) 2018 Page 14


L.J. Institute of Engineering & Technology Semester: VII (2018)

Sr. CHAPTER NO- 8 :Code Generation : Marks


No
Issues in the Design of a Code Generator, The Target Machine, Run-Time
Storage Management, Basic Blocks and Flow Graphs, Next-Use Information,
A Simple Code Generator, Register Allocation and Assignment, The DAG
Representation of Basic Blocks, Peephole Optimization, Generating Code from
DAGs, Dynamic Programming Code-Generation Algorithm, Code-Generator
Generators
DESCRIPTIVE QUESTIONS
1 Write the generic issues in the design of code generators.(Nov-2011)(Nov-2013)[LJIET] 07, 07,
Describe code generator design issues.(Dec-2012)(Nov-2014)[LJIET] 03, 07,
Explain various issues in design of code generator.(Dec-2015)(April-2018_New)[LJIET] 07, 07,
Discuss generic issues in the design of code generator. (Nov-2016_New)[LJIET] 07
Discuss the issues in the design of code generation.(April-2017_New)[LJIET]
Explain code generator design issues.(May-2017)[LJIET]
Describe code generator design issues. (Nov-2017_New)[LJIET]
2 Explain peephole optimization.(Nov-2011)(Nov-2013)(May-2014)(May-2016)(Nov-2016)(Nov- 07, 07,
2017_New)(May-2018)[LJIET] 07, 07,
Explain Peephole Optimization method.(Nov-2016_New)[LJIET] 04, 07,
Write a note on peephole optimization.(April-2017_New)[LJIET] 07
3 Discuss the factors affecting the target code generation.(May-2012)[LJIET] 03
4 Define: DAG. Explain DAG representation of basic block with example.(May-2017)[LJIET] 07
5 Define following : DAG, Basic Blocks, Flow graph (Nov-2017_New)[LJIET] 03
6 Explain algebraic simplifications and flow of control optimization characteristics of peephole 03
optimization. (April-2018_New)[LJIET]
7 i. Construct the DAG for the following basic block: (May-2018)[LJIET] 07
d: = b *
c e: = a +
b b: = b
* c a: = e
–d
ii. Describe issues in code generation process.

Compiler Design (2170701) 2018 Page 15

You might also like