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

Questions Bank Compiler Design

The document discusses various concepts related to compiler design, including annotated parse trees, semantic rules, and the differences between S-attribute and L-attribute. It also covers topics such as operator precedence parsing, predictive parsing, and the construction of LR(0) automata. Additionally, it addresses code optimization techniques and the representation of three-address code, quadruples, and control flow translation.

Uploaded by

22cse048
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)
44 views

Questions Bank Compiler Design

The document discusses various concepts related to compiler design, including annotated parse trees, semantic rules, and the differences between S-attribute and L-attribute. It also covers topics such as operator precedence parsing, predictive parsing, and the construction of LR(0) automata. Additionally, it addresses code optimization techniques and the representation of three-address code, quadruples, and control flow translation.

Uploaded by

22cse048
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/ 3

Q Description of Questions

Consider the following SDD and give an annotated parse trees for the expression.
(8+7*(6+5)+4)*3n
Production Semantic Rules
L→E n L.val = E.val
E→E1 + T E.val = E1.val + T.val
E→T E.val = T.val
T→T1 * F T.val = T1.val x F.val
T→F T.val = F.val
F→(E) F.val = E.val
F→digit F.val = digit.lexval
Consider the following SDD:
Production Semantic Rules
L→E n L.val = E.val
E→E1 + T E.val = E1.val + T.val
E→T E.val = T.val
T→T1 * F T.val = T1.val x F.val
T→F T.val = F.val
F→(E) F.val = E.val
F→digit F.val = digit.lexval
Give an annotated parse trees for the following expression. ( 9 + 8 * ( 7 + 6 ) + 5 ) * 4
n
Consider the following SDD: Give an annotated parse trees for the following
expression.
1*2*3*(4+5)n
Production Semantic Rules
L→E n L.val = E.val
E→E1 + T E.val = E1.val + T.val
E→T E.val = T.val
T→T1 * F T.val = T1.val x F.val
T→F T.val = F.val
F→(E) F.val = E.val
F→digit F.val = digit.lexval
Differentiate between S-attribute and L-attribute.
Discuss about the signification of symbol table used in the program execution of general
procedural language.
Consider following grammar and describe FIRST and FOLLOW.
S→ABCDE, A→ a/ Є, B→b/ Є, C→c, D→d/ Є, E→e/ Є,
Calculate FIRST and FOLLOW: S→ACB/cbB/Ba, A→ da/BC, B→g/ Є, C→h/Є
Discuss about the Bootstrapping process and cross compiler with suitable example.
Also
Suppose you want to create your own compiler in the view of current trend’s and
technology. So, what features you need to be put into that.
Describe phases of compiler with suitable example.
Suppose you want to create your own compiler in the view of current trend’s and
technology. So, what features you need to be put into that, justify each feature.
Differentiate between S-attribute and L-attribute.
Discuss about Operator Precedence Parsing with grammar E → E + E|E*E|id for string
id+id*id.
Consider following grammar and draw the predictive parsing table and process
following string w = aabb with non-recursive predictive parsing method. S→aSb/Є
Describe the process of each phases of compiler in detail for: Position = initial + rate
* 60
Discuss about Augmented Grammar, Item, Closure of Item and GOTO function. Also
Construct LR(0) automaton for the following grammar: E→E+T/T, T→T*F/F,
F→(E)/id
Discuss about the Bottom Up Parsing with suitable example by handle and reduction
steps.
Consider following grammar and draw the predictive parsing table and process
following string w = (( )) with non-recursive predictive parsing method. S→(S)/Є
Discuss the shift reduce parsing and gives the processing steps in shift-reduce parser
for the input string id *id according to the grammar
E→E+T|T
T→T*F|F
F → ( E ) | id.
Construct LR(0) automaton for the following grammar:
E→E+T/T, T→T*F/F, F→(E)/T
Consider following grammar and draw the predictive parsing table and process
following string w = (( )) with non-recursive predictive parsing method. S→( S )/Є
Write a Lex program to recognize input sting is equivalent to PAN card number.
Write a Lex program to recognize input sting is equivalent to valid identifier.
Discuss about the LEX and YACC for their syntax structure of program, compilation
process with any suitable program also.
1. In Compiler, translation process is going on in number of phases. Why direct
translation is difficult? Discuss.
2. Discuss about pattern, lexeme and token with example.
3. Give the difference between annotated parse tree and parse tree?
4. What is operator grammar? Give example.
5. What is the role of parser?
6. Discuss about the types of parser.
7. What is LR(0) item?
8. What do you mean by Syntax-directed translation?
9. What is peephole optimization?
10. What are the data structures used in the symbol table generation?
1. Suppose you want to create your own compiler in the view of current trend’s and
technology. So, what features you need to be put into that, justify each feature.
2. What do you mean by Bootstrapping?
3. What do you mean by parsing?
4. Discus the classification of parsing techniques.
5. Why do we have to remove the left recursion in the top down parsing?
6. What is LR(1) item?
7. What do you mean by Syntax-directed translation?
8. Discuss the representation of TAC using Triples and Quadruples.
9. What is loop invariant computation?
10. What is activation record?
Perform the code optimization techniques to optimize following code.
A= X **2
B=3
C=X
D=C*C
E=B*2
F=A+D
G=E*F
Represent the following code into Triples, quadruples and indirect triples. T1 = A + B
T2 = T1
T3 = B * C
T4 = A + T3
T5 = T2 * T4
Construct three address code for the following code.
i=0
while( i < 10)
{
x = a + b * c;
i + +;
}
Construct the DAG following expressions and generate TAC for it. ((x + y ) - (( x + y
) * ( x – y ))) + (( x + y ) * ( x – y ))
Consider the following statement and write control flow translation.
if ( x < 100 || x > 200 && x != y ) then x = 0;
Construct the DAG following expressions. a + a + ( a + a + a + ( a + a + a + a ))
Explain the issues in the design of code generation.
Construct the DAG for the following basic block
d=b*c
e=a+b
b=b*c
a=e–d
and simplify the above TAC of assuming: (i) Only a is live on the exit from the block.
(ii) a, b, and c are live on exit from the block.
Suppose you have received the program code written in language L, and you asked to
make it optimize as possible as, therefore what techniques you will use to make that
optimize. Discuss with example.

You might also like