Sei sulla pagina 1di 12

Gandhinagar Institute of Technology

Computer Engineering Department


Question Bank

Subject Code: 2170701

Subject Name: Compiler Design

UNIT-1 INTRODUCTION

1. Define lexeme, token and pattern. Identify the lexemes that make up the tokens in
the following program segment. Indicate corresponding token and pattern. (WINTER-
2015 7 Marks)
void swap (int a, int b) { int k; k = a; a = b; b = k; }
2. Explain Semantic Analysis and Syntax Analysis phases of compiler with suitable
example. Also explain the reporting errors by these two phases. (WINTER-2015 7
Marks, SUMMER-2017 7 Marks)
3. Write a short note on Symbol Table Management. (WINTER-2015 7 Marks, SUMMER-
2017 7 Marks)
4. List the errors generated by the syntax analysis phase. Discuss error handling methods in
the syntax analysis phase. (SUMMER-2015 7 Marks)
5. Explain the phases of compiler with an example. (SUMMER-2016 7 Marks, SUMMER-
2015 7 Marks, SUMMER-2014 6 Marks, WINTER-2016 7 Marks)
6. What is the use of a symbol table? How identifiers are stored in the symbol table?
Explain: Symbol Table Management. How symbol table differs from other data
structures? For what purpose compiler uses symbol table? How characters of a name are
stored in symbol table? (WINTER-2014 7 Marks, SUMMER-2014 4 Marks, SUMMER-
2012 3 Marks, WINTER-2011 4 Marks)
7. What is the pass of a compiler? Explain how the single and multi-pass compilers work.
(SUMMER-2014 7 Marks)
8. Explain how type checking & error reporting is performed in compiler. (SUMMER-2016
7 Marks)
9. Draw structure of Compiler. Also explain Analysis Phase in brief. (WINTER-2013 7
Marks)
10. Explain the roles of linker, loader and preprocessor. (WINTER-2013 8 Marks)
11. Explain the analysis synthesis model of compilation. List the factors that affect the
design of compiler. Also List major functions done by compiler. (SUMMER-2012 6
Marks)
12. What does the linker do? What does the loader do? What does the preprocessor do?
Explain their role(s) in compilation process. (SUMMER-2012 4 Marks)
13. What is the difference between compiler and interpreter? (WINTER-2017 3 Marks)
14. What is a pass in a compiler? What is the effect of reducing the number of passes?
(WINTER-2011 4 Marks)
15. Explain analysis phase of the source program with example. (WINTER-2017 4 Marks)
16. What is a pass in a compiler? What is the effect of reducing the number of passes?
(WINTER-2017 3 Marks)
14. (i) What is a symbol table? Discuss the most suitable data structure for it by stating
merits / demerits.
(ii) Explain linker & loader. (WINTER-2016 7 Marks)
15. For a statement given below, write output of all phases (except that of optimization
phase) of a complier. (WINTER-2016 7 Marks)
a = a + b * c;

UNIT-2 LEXICAL ANALYZER

1. Construct DFA for following Regular expression. Use firstpos, lastpos and followpos
functions to construct DFA. (WINTER-2015 7 Marks)
(a*|b*)*
2. Construct NFA for following Regular Expression using Thomson’s Construction. Apply
subset construction method to convert into DFA. (WINTER-2015 7 Marks, WINTER-
2017 7 Marks)
(a | b)*abb
3. What are regular expressions? Find the regular expression described by DFA
{{A,B},{0,1},δ,A,{B}},where δ is detailed in following table. Please note B is accepting
state. Describe the language defined by the regular expression. (SUMMER-2015 7
Marks)

4. Construct the NFA using thompson’s notation for following regular expression and then
convert it to DFA. ( SUMMER-2015 7 Marks)
a+ (c |d) b*f #
5. Construct DFA by syntax tree construction method. a+ b* (c |d) f # Optimize the
resultant DFA.( SUMMER-2015 7 Marks)
6. Explain Buffer pairs and Sentinels. (WINTER-2014 7 Marks, WINTER-2017 4 Marks)
7. Explain role of lexical analyzer. (WINTER-2017 4 Marks)
8. Construct minimum state DFA’s for following regular expressions. (WINTER-2014 7
Marks)
i. (a|b)*a(a|b)
ii. (a|b)*a(a|b) (a|b)
9. Draw Deterministic Finite Automata. (SUMMER-2014 7 Marks)
i. (0+1)*101(0+1)*
ii. 10(0+1)*1
10. Write a brief note on input buffering techniques.
11. Write a brief note on input buffering techniques to Lexical Analyzer. Write the two
methods used in lexical analyzer for buffering the input. Which technique is used
for speeding up the lexical analyzer? (SUMMER-2014 7 Marks, WINTER-2013 7
Marks, WINTER-2011 7 Marks)
12. What is regular expression, give all the algebraic properties of regular expression.
(SUMMER-2016 7 Marks)
13. Draw the DFA for the regular expression (a|b)*abb using set construction method only.
(SUMMER-2016 7 Marks)
14. Unsigned numbers are strings such as 5280, 39.37, 6.336E4 or 1.894E-4, give the regular
definitions for the above mentioned strings. (SUMMER-2016 7 Marks)
15. Convert the (a|b|c)*d*(a*|b)ac+# regular expression to DFA directly and draw its DFA.
(SUMMER-2016 7 Marks)
16. Write short note on context free grammar (CFG) explain it using suitable example.
(SUMMER-2016 7 Marks)
17. Draw Deterministic Finite Automata for the binary strings ending with 10. (WINTER-
2013 4 Marks)
18. Write down the regular expression for the binary strings with even length. (WINTER-
2013 3 Marks)
19. Find the Regular Expression corresponding to given statement, subset of {0,1}*.
(SUMMER-2012 4 Marks)
i. The Language of all strings containing at least one 0 and at least one 1.
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.
20. Convert the following NFA-^ into equivalent NFA. Here ℇ is a ^-transition. (SUMMER-
2012 7 Marks)

21. Construct a DFA for a given regular expression (010+00)*(10)* (SUMMER-2012 7


Marks)
22. How do the parser and scanner communicate? Explain with the block diagram
communication between them. Also explain: What is input buffering? (SUMMER-2012
7 Marks)
23. Write a regular definition for the language of all strings of 0’s and 1’s with an even
number of 0’s and odd number of 1’s. (WINTER-2011 4 Marks)
24. Construct the NFA using thompson’s notation for following regular expression and then
convert it to DFA. (SUMMER-2017 7 Marks)
(a / b)* ab#
25. Convert the following regular expression into deterministic finite automata. (WINTER-
2011 3 Marks)
(a+b)*abb(a+b)*
26. Construct DFA without constructing NFA for following regular expression: (WINTER-
2016 7 Marks)
a*b*a(a | b)b*a#
Minimize the same.
27. Construct NFA for following regular expression using Thompson’s notation and then
convert it into DFA. (WINTER-2016 7 Marks)
a(b | c)*a*c#

UNIT-3 PARSING THEORY

1. Construct LL(1) parsing table for the following Grammar: (WINTER-2015 7 Marks)
S -> ( L ) | a
L -> L , S | S
2. Check whether the following grammar is CLR or not. (WINTER-2015 7 Marks)
S -> Aa | bAc | Bc | bBa
A -> d
B-> d
3. Construct SLR Parsing Table for the following grammar. (WINTER-2015 7 Marks)
S-> 0S0 | 1S1 | 10
4. Explain Operator Precedence Parsing method with example. Define an Operator
Precedence Grammar. Also write down the rules to find relationship between each pair
of terminal symbols. (WINTER-2015 7 Marks, SUMMER-2014 8 Marks, SUMMER-
2016 7 Marks)
5. Explain LALR parser in detail. Support your answer with example. (WINTER-2015 7
Marks)
6. For the following grammar (SUMMER-2015 7 Marks)
D -> T L ;
L -> L , id | id
T -> int | float
i. Remove left recursion (if required) S
ii. Find first and follow for each non terminal for Resultant grammar
iii. Construct LL(1) parsing table
iv. Parse the following string (show stack actions clearly) and draw parse tree for the
input: int id, id;
7. How top down and bottom up parser will parse the string ‘bbd’ using grammar.
(SUMMER-2015 7 Marks)
A -> bA | d.
Show all steps clearly.
8. Construct the collection of sets of LR(0) items for the following grammar. (SUMMER-
2015 7 Marks)
S-> Aa | bAc | dc | bda
A->d
9. Develop a predictive parser for the following grammar. (SUMMER-2015 7 Marks)
S’->S
S->aA|b|cB|d
A->aA|b
B->cB|d
10. Explain the following: (SUMMER-2015 7 Marks)
i. The Handle
ii. Left Factoring
iii. Directed Acyclic Graph
iv. Conflicts in LR Parsing
v. Parser Generator
vi. Dependency Graph
vii. Locality of reference
11. Construct an SLR Parsing table for the following grammar. (SUMMER-2015 7 Marks)
E->E-T|T
T->F↑T|F
F->(E) | id
12. Explain recursive-descent and predictive parsing. (WINTER-2014 7 Marks)
13. What do you understand by a handle? Explain the stack implementation of shift reduce
parser with the help of example. (WINTER-2014 7 Marks)
14. Write a rule of Left factoring a grammar and give example. (WINTER-2017 3 Marks)
15. Show that the following grammer: (WINTER-2014 7 Marks, WINTER-2017 7 Marks)
S-> AaAb | BbBa
A -> ϵ
B -> ϵ
is LL(1) but not SLR(1).
16. Show that the following grammer
S->Aa | bAc | dc | bda
A->d
is LALR(1) but not SLR(1). (WINTER-2014 7 Marks)
17. Show that the following grammer
S->Aa | bAc | Bc | bBa
A->d
B->d is LR(1) but not LALR(1). (WINTER-2014 7 Marks)
18. Implement the following grammar using Table Driven parser and check whether it is
LL(1) or not. (SUMMER-2014 8 Marks)
S -> aBDh
B -> cC
C -> bC / ^
D -> EF
E -> g / ^
F-> f / ^
19. Implement the following grammar using Recursive Descent Parser. (SUMMER-2014 8
Marks)
S -> Aa | bAc | bBa
A -> d
B -> d
20. What is bottom-up parsing? Discuss Shift Reduce parsing technique in brief. What is a
handle? (SUMMER-2014 8 Marks)
21. Construct SLR parsing table for the following grammar: (SUMMER-2014 10 Marks)
E->E+T
E->T
T->T*F
T->F
F->(E)
F->a
22. What is left recursion? Eliminate the left recursion from the following grammar.
(SUMMER-2016 7 Marks)
E -> E + T | T
T -> T * F | F
F -> ( E ) | id
23. Explain SLR parser in detail with the help of a suitable example. (SUMMER-2016 7
Marks)
24. Design the FIRST SET and FOLLOW SET for the following grammar. (SUMMER-2016
7 Marks)
E -> E + T | T
T -> T * F | F
F -> ( E ) | id
25. Differentiate SLR, Canonical LR and LALR. Also justify the statement “A class of
grammar that can be parsed using LR methods is a proper subset of the class of
grammars that can be parsed with predictive parser”. (SUMMER-2016 7 Marks)
26. Write down the algorithm for left factoring. (WINTER-2013 3 Marks)
27. Write down C program for Recursive Descend Parser for : (WINTER-2013 7 Marks)
S -> ABC
B->1B | ˄
A-> 0A1 | ˄
C-> 1C0 | ˄
28. Explain Shift-Reduce parsing with suitable example. (WINTER-2013 7 Marks)
29. What is operator grammar? Generate precedence function table for following grammar.
(WINTER-2017 7 Marks)
E -> EAE | id
A -> + | *
30. Draw parsing table for Table Driven Parser for the given grammar. Is the grammar
LL(1)? (WINTER-2013 7 Marks)
A-> AaB | x
B-> BCb | Cy
C-> Cc | ˄
31. Write down steps to set precedence relationship for Operator Precedence Grammar.
Design precedence table for: (WINTER-2013 7 Marks)
E -> E+ T | T
T ->T * F | F
F -> a
32. What is the difference between parse tree and syntax tree? Write appropriate grammar
and draw parse as well as syntax tree for a*(a-a^a). (WINTER-2013 7 Marks)
33. Write SLR parsing table for : (WINTER-2013 8 Marks)
S -> T
T -> CC
C -> cC
C -> d
34. Explain non-recursive predictive parsers. Draw the block diagram of it. (SUMMER-2012
4 Marks)
35. Define handle and handle pruning. Explain the stack implementation of shift reduce
parser with the help of example. (WINTER-2017 7 Marks)
36. Test whether the following grammar is LL (1) or not. Construct predictive parsing table
for it. (SUMMER-2012 7 Marks)
S-> 1AB | ℇ
A-> 1AC | 0C
B-> 0S C- >1
37. Explain the structure of an activation record with all its components. Construct predictive
parsing table for following. (SUMMER-2012 7 Marks)
S -> A
A -> aB | Ad
B -> bBC | f
C -> g
38. Eliminate left recursion from the following grammar and rewrite the Grammar.
(SUMMER-2012 3 Marks)
S -> Aa | b
A -> Ac | Sd | ℇ
39. (a) Perform the Left factoring of following Grammar
A -> ad | a | ab | abc | b
(b) Find out FIRST & FOLLOW set for all the Nonterminals
S-> AcB | cbB | Ba
A-> da | BC
B-> g | ℇ
C -> h | ℇ
(SUMMER-2012 10 Marks)
40. Construct the canonical parsing table for the following Grammar: (SUMMER-2012 7
Marks)
S’-> S
S-> CC
C-> cC|d
41. Generate the SLR parsing table for the following Grammar: (SUMMER-2012 7 Marks)
S-> Aa|bAc|bBa
A -> d
B -> d
42. How can panic mode and phrase level recovery be implemented in LR parsers? Consider
the expression grammar
E → E + E | E * E | (E) | id
43. Prepare the SLR parsing table with error detection and recovery routines. (WINTER-
2011 7 Marks)
44. Write an algorithm for eliminating left recursion. (WINTER-2011 3 Marks)
45. Is the following grammar suitable for LL(1) parsing? If not make it suitable for LL(1)
parsing. Compute FIRST and FOLLOW sets. Generate the parsing table. (WINTER-
2011 7 Marks)
S→AB
A→Ca | ϵ
B→BaAC | c
C→b | ϵ
F→num|id|(E)
46. Consider the following grammar: (WINTER-2011 7 Marks)
E → E+T | T
T → TF | F
F → F* |a |b
Construct the SLR parsing table for this grammar.
47. Check following grammar is LL (1) or not? (SUMMER-2017 7 Marks)
S -> aB | €
B -> bC | €
C -> cS | €
48. Construct the LALR parsing table.
49. Draw the transition diagrams for predictive parsers for the following grammar.(
WINTER-2011 7 Marks)
E → TE’
E’→ +TE’ | ϵ
T → FT’
T’ → *FT’ | ϵ
F → (E) | id
50. (i)Consider the grammar
S -> SS+ | SS* | a
Show that the string aa+a* can be generated by the grammar. Construct the parse tree for
the grammar.
(ii)Is the grammar ambiguous?
51. Write unambiguous production rules for if then else construct. (WINTER-2016 7 Marks)
52. Apply shift reduce parser for parsing following string using unambiguous grammar.
(WINTER-2016 7 Marks)
id - id * id – id
53. Compare top-down and bottom-up parser.
54. Explain right-most-derivation-in-reverse with the help of an example. (WINTER-2016 7
Marks)
55. Explain SLR parser. How is its parse table constructed? (WINTER-2016 7 Marks)
56. Construct a precedence graph, precedence table for operator precedence parser to be used
for parsing a string consisting of id, - , *, $. Parse following string. (WINTER-2016 7
Marks)
$ id - id * id * id $
57. Draw transition diagrams corresponding to production rules for arithmetic expressions
consisting of operators + and ^ for predictive parser. Explain how parsing takes place for
the same using transition diagrams. (WINTER-2016 7 Marks)
58. (i) Explain various parameter passing methods. (WINTER-2016 7 Marks)
(ii) Explain left factoring with the help of an example.
59. Compute the operator precedence matrix and precedence function for the following
grammar if it exists. +,*,-,/,id,num,( and ) are terminal symbols. (WINTER-2011 7
Marks)
G→E
E→E+T|E-T|T
T→T*F|T/F/F
60. Draw Transition diagram of following: (WINTER-2014 7 Marks)
i. Relational operators.
ii. Unsigned operator.
61. Draw the state transition diagram for the unsigned numbers. (SUMMER-2016 7 Marks)
62. What is left factoring and left recursion? Explain it with suitable example. (SUMMER-
2017 7 Marks)
63. Define operator precedence grammar. Construct precedence matrix and precedence
graph for arithmetic grammar as shown below: (SUMMER-2017 7 Marks)
E -> E + T | T
T -> T * F | F
F -> (E) | id
64. Show that following grammar is not a SLR (1) grammar. (SUMMER-2017 7 Marks)
S -> AaBa | BbBa
A -> €
B -> €
65. Construct CLR parsing table for following grammar. (SUMMER-2017 7 Marks)
S -> aSA | €
A -> bS | c

UNIT-4 ERROR RECOVERY

1. Explain various error recovery strategies of compilers. (WINTER-2014 7 Marks,


SUMMER-2014 4 Marks, SUMMER-2016 7 Marks, SUMMER-2012 7 Marks,
WINTER-2017 4 Marks)
2. Explain how panic mode recovery can be implemented. (WINTER-2013 7 Marks)

UNIT-5 INTERMEDIATE CODE GENERATION


1. Show syntax directed definition for simple desk calculator. Also show annotated parse
tree for 3*5+4n, where n indicates newline. Write a syntax directed definition for desk
calculator. Justify whether this is an S- attributed definition or L-attributed definition.
Using this definition draw annotated parse tree for 3*5+4n. (WINTER-2015 7 Marks,
SUMMER-2014 6 Marks, WINTER-2012 7 Marks)
2. Give the translation scheme that converts infix to postfix expression for the
following grammar and also generate the annotated parse tree for input string 7+3+2.
(WINTER-2015 7 Marks)
E -> E+T
E -> T
T ->0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9
3. Write a context free grammar for arithmetic expressions. Develop a syntax directed
definition for the grammar. Draw an annotated parse tree for the input expression:
(3*2+2)*4 (SUMMER-2015 7 Marks)
4. Discuss synthesized and inherited attributes using a suitable grammar. (SUMMER-2015
7 Marks, SUMMER-2014 4 Marks, WINTER-2013 6 Marks)
5. Construct a Syntax-Directed Translation scheme that translates arithmetic
expressions from intfix into postfix notation. Show the application of your scheme to the
string “3*4+5*2”. (WINTER-2014 7 Marks)
6. Explain with an appropriate example how to perform bottom up evaluation of an
inherited attributes. (WINTER-2014 7 Marks)
7. Write syntax directed Definition for translating following grammar for postfix notation.
Also draw annotated parse tree for 9-5+2. (SUMMER-2012 7 Marks)
expr -> expr + term
expr -> expr – term
term -> 0 | 1 |…..|9
8. What is attributed grammar? Which phase of the compilation process does it facilitate?
Explain with example. (SUMMER-2012 3 Marks)
9. What is inherited attribute? Write syntax directed definition with inherited attributes for
type declaration for list of identifiers. Show annotated parse tree for the sentence real
id1,id2,id3. (WINTER-2011 7 Marks)
10. Translate following arithmetic expression - ( a * b ) + ( c + d ) - ( a + b + c + d ) into
1) Quadruples 2) Triple 3) Indirect Triple (WINTER-2015 7 Marks)
11. Convert the following statement into triple, indirect triple and quadruple forms.
(SUMMER-2015 7 Marks)
A= (B+C) $ E + (B+C) *F
12. What is intermediate code? What is its importance? Discuss various representations of
three address code. (SUMMER-2015 7 Marks)
13. Explain quadruple, triple and indirect triple with suitable example. (WINTER-2014 7
Marks, WINTER-2013 8 Marks, SUMMER-2017 7 Marks)
14. Convert the following into quadruple, triple and indirect triple forms: (WINTER-
2014 7 Marks)
-(a+b)*(c-d).
15. Translate the expression – (a*b)+(c*d)+(a*b*c) into 1. Quadruples 2. Triples 3. Indirect
triples. (SUMMER-2016 7 Marks, WINTER-2011 7 Marks)
16. What is the difference between parse tree and syntax tree? Draw the parse tree for
following expression: a= a + a * b + a * b * c – a / b + a * b and write three address code
for it. (SUMMER-2012 4 Marks)
17. What is Intermediate form of the code? What are the advantages of it? What are
generally used intermediate forms? Write N-Tuple notation for:
(a+b)*(c+d)-(a+b+c)
(SUMMER-2012 7 Marks)
18. Translate the arithmetic expression a*-(b+c) into (WINTER-2011 7 Marks, WINTER-
2017 3 Marks)
1. Syntax tree
2. Postfix notation
3. Three address code
19. Write production and semantic rules for producing and analyzing statements like :
(WINTER-2016 7 Marks)
int * ip , i , j , *ip1;
float * fp , f;
20. Explain synthesized attributes with the help of an example. (WINTER-2016 7 Marks)
21. Define syntax tree. What is s-attributed definition? Explain construction of syntax tree
for the expression a-4+c using SDD. (WINTER-2017 7 Marks)
22. Give the translation scheme that converts infix to postfix notation. Generate the
annotated parse tree for input string 3-5+4. (WINTER-2017 3 Marks)
23. Write Syntax Directed Definition to produce three address code for the expression
containing the operators := , + , - (unary minus), ( ) and id. (WINTER-2017 4 Marks)
24. What is importance of intermediate code? Discuss various representations of three
address code using the given expression. a = b * -c + b * -c. (WINTER-2017 7 Marks)
25. Write a grammar to declare variables with data type int or float or char. Also develop a
syntax directed definition for that. Draw the dependency graph for same. (SUMMER-
2017 7 Marks)
26. Develop a syntax directed definition for following grammar. (SUMMER-2017 7 Marks)
E -> TE’
E’ -> +TE’ | €
T -> ( E )
T -> id

UNIT-6 RUN TIME MEMORY MANAGEMENT

1. Explain various dynamic storage allocation techniques. (WINTER-2015 7 Marks)


2. Elaborate the term “Activation Record” in detail. (SUMMER-2015 7 Marks, WINTER-
2017 7 Marks )
3. Explain Stack allocation and Activation record organization in brief. (WINTER-2014 7
Marks, WINTER-2013 8 Marks, WINTER-2017 7 Marks)
4. Write a note on static and dynamic memory allocation. What do you mean by dangling
reference? (SUMMER-2014 7 Marks)
5. What is an activation record? Explain how they are used to access various local and
global variables. (SUMMER-2014 7 Marks, SUMMER-2016 7 Marks)
6. Differentiate: static v/s dynamic memory allocations (WINTER-2013 3 Marks,
SUMMER-2012 3 Marks)
7. Compare: Static v/s Dynamic Memory Allocation
8. Write down the algorithm for partitioning of basic blocks. (WINTER-2013 7 Marks)
9. Explain the structure of an activation record with all its components. Explain activation
tree and control stack. (SUMMER-2012 4 Marks, WINTER-2011 4 Marks)
10. What are the limitations of static storage allocation? Explain the problem of dangling
references. (WINTER-2011 3 Marks)
11. Explain the static scope rule and dynamic scope rule. (WINTER-2011 3 Marks)
12. Explain activation record. How is task divided between calling & called program for
stack updating? (WINTER-2016 7 Marks)
13. What is activation tree? (WINTER-2017 3 Marks)
14. Explain parameter passing techniques for procedure. (WINTER-2017 4 Marks)
15. Explain function preserving transformations with example. (WINTER-2017 7 Marks)
16. Explain Activation record and Activation tree in brief. (SUMMER-2017 7 Marks)
17. Define dominators. Construct dominator tree for following graph. (SUMMER-2017 7
Marks)

UNIT-7 CODE OPTIMIZATION

1. Explain any three code optimization techniques with example. (WINTER-2015 7 Marks)
2. Discuss various code optimization techniques. (SUMMER-2015 7 Marks, WINTER-
2014 7 Marks, SUMMER-2012 7 Marks)
3. Describe algorithm for global common subexpression elimination.( WINTER-2014 7
Marks, WINTER-2011 7 Marks)
4. Write a note on peephole optimization. (SUMMER-2014 7 Marks, SUMMER-2016 7
Marks, WINTER-2013 8 Marks, WINTER-2011 7 Marks, WINTER-2016 7 Marks,
WINTER-2017 4 Marks, SUMMER-2017 7 Marks)
5. Explain three loop optimization techniques with example. (WINTER-2017 3 Marks)
6. What is code optimization? Explain data flow equation. (WINTER-2017 4 Marks)

UNIT-8 CODE GENERATION

1. Explain various issues in design of code generator. (WINTER-2015 7 Marks, WINTER-


2014 7 Marks, WINTER-2013 7 Marks, WINTER-2011 7 Marks, WINTER-2017 7
Marks, SUMMER-2017 7 Marks)
2. Discuss the factors affecting the target code generation. (SUMMER-2012 3 Marks)
3. Draw syntax tree and DAG for the statement a = (a * b + c) ^ (b + c) * b + c. Write three
address codes from both. (SUMMER-2016 7 Marks)
4. Define following : DAG, Basic Blocks, Flow graph (WINTER-2017 3 Marks)
5. Define a following: Basic block, Constant folding, Natural loop, Handle (SUMMER-
2017 7 Marks)
6. Construct DAG for a + a * (b- c) + (b – c) * d. also generate three address code for same.
(SUMMER-2017 7 Marks)
7. Draw syntax tree and DAG for following statement. Write three address codes from
both. (WINTER-2016 7 Marks)
a = (a + b * c) ^ (b * c) + b * c ^ a;

Potrebbero piacerti anche