CD 2 mid Question Bank DO (III B.Tech.)(2015

advertisement
SRI VENKATESA PERUMAL COLLEGE OF ENGINEERING & TECHNOLOGY::PUTTUR
Branch: CSE-III
Year & Sem: III B.Tech(CSE) – I Sem
Subject: Compiler Design (CD)
Academic Year: 2015-16
Name of the Exam: I-Mid
Paper set by: T.DURGA
(Objective)
UNIT-II
I Choose the correct alternative:
1. Predictive parser must be free from
[
a ]
a) Left recursion
b) Ambiguous grammar
c) Un- Ambiguous grammar
d) LL (1)
2. Which of the following is non-recursive predictive parsing?
[
d
]
a)Top-down parsing b)Bottom-up parsing
c)LALR parsing
d)LL(1) parsing
3. SLR parsing follows------------parsing technique
[
a ]
a)Bottom-up
b)Top-down
c)both a & b
d)none
4. Which of the following is the type of LR parsing?
[
a ]
a)SLR,CLR,LALR b)SLR,LL(1),LL(K)
c)Shift reduce parsing,SLR,LALR
d)none
5. Which of the following does not follow bottom-up parsing technique
[
a
]
a) LL parser
b)LR parser
c)Shift reduce parser
d)Operator precedence parser
6. Which of the following is the most powerful parser?
[
c ]
a) SLR b)LALR c)Canonical LR d)Operator precedence
7. A bottom-up parser generates
[
c ]
a) Left most derivation
b) Right most derivation
c) Right most in reverse
d)left most in reverse
8. Synthesized attribute can easily be simulated by an ---------[
c ]
a)LL grammar
b)ambiguous grammar
c)LR grammar
d)none
9) Implicit type conversion is---------[
a ]
a) done automatically by compiler
b)done automatically by interpreter
c) done automatically by OS
d) done automatically by language
10) Which phase is an optional phase of a compiler
[
c ]
a)semantic analyzer b)intermediate code generator
c)code optimizer d)code generator
II Fill in the blanks
11. LALR stands for Look head LR
12. SLR parser uses FOLLOW information for reduction
13. Parsing table for LL(1) does not have Multiple defined entries
14. The intermediate code generator phase of compiler takes the Syntax tree as input
15. An automatic type conversion is called Coercion
16. In Abstract syntax tree is the nodes represent operators and children of that node represent operands
17. The two form of type checking are Type synthesis and Type inference
18. A Syntax directed definition is combination of grammar and the set of semantic rules
19. Dynamic checking is defined as checking of the target program at run time
20. Type checking done by a compiler is known as Static checking
UNIT _III
Choose the correct alternative:
1. A------ is the combination of a grammar and the set of semantic rule.
a) Syntax directed translation
b) S-attribute grammar
c) Syntax directed definition
2. The general form of three-address statement is-----a)r:=aop
b)r=aopb
c)r:=a
3.----------- is used to add semantic rules to production
a) Semantic analyzer b)Syntax directed definition
c)Lexical analyzer
4. L-attributed grammars consists of ------a) synthesized attributes b)inherited attributes
c)both a& b
5. ---------- adds semantic rules to productions of context free grammar
a)S-attribute
b)DAG
c)L-attribute
[
c
]
d)L-attribute grammar
[
b
]
d)r:=opb
[
d
]
d)Syntax directed translation
[
c ]
d)none
[
b
]
d)none
6. Inherited attributes are used for--------------[
a
]
a)Keeping track of variable declaration b)Checking for correct use of L-values
c)Evaluating arithmetic expressions d)All
7.For which of the following attributes the semantic actions are evaluated before they are
[
d
]
a) Canonical attribute
b) Synthesized attribute
c)Prospective attribute
d) Inherited attribute
8The semantic rule for the production D-->TL is--------------[
c ]
a)D.val:=T.type,L.inherit
b)D.val:=T.type,L
c) L.inherit:=T.type
d)T.type=L.inherit
9.Which of the following programming language consist is the primary one for changing the flow of control in a program
a) Go to-statement
b)Break statement
c)Continue statement
d)Jump statement[ a
]
10.The input to code generation algorithm is a sequence of---------statements constituting a basic block
[
c ]
a)One-address
b)Two-address
c)Three-address
d)Four-address
11.Wtatic allocation strategy allocates memory at----[
d ]
a)Run time
b)Editing time
c)Loading time
d)Compiler time
12.The following storage allocation strategy manages for all the data object at compiler time
[
d
]
a)Heap allocation
b) Dynamic allocation
c)Stack allocation d)Static allocation
13.The allocation that is required for languages that support dynamic data structure---------[
a ]
a)Heap
b)Stack
c)Static
d)Hash
14. Allocation and deallocation operations are performed by---------[
c ]
a)Programmer
b)Operating system
c)Memory manager d)CPUS
15.Garbage collection through reference counting is referred to as------[
b ]
a)Garbage collector
b)Automatic garbage collector
c)Automatic collector d)all
16.The following storage allocation strategy manages for all the data object at compiler time
[
d ]
a)Heap allocation
b) Dynamic allocation
c)Stack allocation
d)Static allocation
17.The allocation that is required for languages that support dynamic data structure---------[
a ]
a)Heap
b)Stack
c)Static
d)Hash
18.Which of the following is not a field of an activated record?
[
c ]
a)Control link
b)Data link
c)Data size
d)Local data
19.Which of the following is an attribute of symbol table
[
d ]
a)Type
b)Name
c)Scope
d)all
20.Types of LR Parser are-------[ d
]
a)SLT
b)CLR
c)LALR
d)All
II Fill in the blanks
21.S-attribues also called as Synthesized-attributes
22.L-attributes can be evaluated in Depth first order
23.CLR stands for Canonical LR
24.The three ways of implementing three-address code are Quadruple , Triple and Indirect triple
25.Static checking is the checking of the source program by the compiler at the compiler time
26.A Symbol Table is a storage area or a data structure that is used by the compiler time
27.Coercion does not change the meaning of the program and no data is lost
28.Runtime memory can be broadly classified in to Code area and Data area
29.DAG stands for Directed acyclic graph
30.The input to code generation algorithm is a sequence of 3-address statements constituting a basic block
UNIT-V
I Choose the correct alternative:
1. In the code optimization, programs are represented by------a)Flow graphs
b)Flow charts
c)Pseudo code
d)All above
2. Machine dependence optimization influenced by the----a)Source machine
b)Target machine
c)Compiler
d)Interpreter
3. The code generator, produces the target program from the transformed--a)High level code
b)Low level code
c)Intermediate code
d)All
4.Get_Reg() is used to access the register and --------a)Address descriptor
b)Two address descriptor
c)Three address descriptor d)None
5. Loop optimization improves the performance of---------
[
a
]
[
b
]
[
d
]
[
a
]
[
d
]
a) System
b)Block
c) CPU
d)Cache
6. Which of the following technique an used for loop optimization?
[
c
]
a) Code motion ,strength reduction b)Induction variable c)Both a&b
d)None
7.-------- are considered to be as major some of code optimization
[
a
]
a)Loops
b)Variable
c)Procedures
d)Semantics
8.The object code form that makes the code generation process easier is----[ a
]
a) Assembly language code b) Absolute machine code c) Relocatable machine code d)none
9.In DAG representation of basic blocks, interior nodes are labeled by----[
c
]
a)Constants
b)Variable name
c)An operator symbol
d)None
10.The following decides in which register each value should be stored
[ b
]
a)Register allocation
b)Register assignment
c)An operator symbol
d)None
11.Which of the following is an advantage of generating a code from DAG?
[ d
]
a) Helps in eliminating induction variables
b)Helps in eliminating common sub expressions
c)Helps in eliminating loop invariant variable
d)Helps in rearranging the order of the final computation sequence easily
12.A-------keep the information about each register
[
a ]
a)Register descriptor
b)DAG
c)Variable descriptor
d)Address descriptor
13.----------Algorithm is used to order the nodes of directed a cyclic graph.
[
b
]
a)Labeling
b)Heuristic ordering
c)Code generation
d)Code optimization
14.------------- Are used in generation of object codes
[ a
]
a)Label trees b)Register allocation c)Register assignment d)Graph coloring
15.---------Descriptor is also known as address descriptor.
[ b
]
a)Register
b)Variable
c)Data
d)Reserve register
16.The function --------- is used to determine the location L to hold the value the of X for the expression x:=y op z. [ d
]
a)gencode
b)genpush
c)genpop
d)getreg
17.A pointer called access link is added to-------[
a ]
a)Activation record b)Activation tree c)Syntax tree
d)Lexical analyzer
II Fill in the blanks
18.A Technique used to improve the target code is known as peephole optimization
19.A process of collecting information regarding the data flow in a program is called Data flow analysis
20.A Register descriptor keeps the information about each register
21.The algorithm used to order the nodes of a directed acyclic graph is Heuristic ordering algorithm
22. Register allocation decides what values in a program should be stored in registrars
23.The cost of addressing modes involving a memory location is one
24. Register allocation is the process of deciding ,which 1R values to keep in register
25.Generic code generation algorithm can generate code for multiple instruction sets
26.Write any object code forms Absolute code and assembler code
27.What is input of code generation Intermediate code and symbol table
28.Write any 2 issues in code generation Input to the code generation and Target program
29.Write any one of the code generation algorithm Simple code generation algorithm.
30.Define code generation: Takes intermediate code as an input generates target machine code as output
UNIT-II
1a. Explain about handling ambiguous grammar
b. Differentiate Among SLR Parser ,CLR Parser and LALR Parser?
2a. Explain Error Recovery in LR Parser?
b. Describe YACC?
3. Construct the SLR (1) parsing table for
EE+T
ET
TT*F
TF
F( E)
Fid
Parsing the input string id*id+id
4. Construct the CLR (1) parsing table for
S’S
SCC
Cac/d
Parsing the input string is adad
5. Construct LALR (1) items for the given productions
SCC
Cac/d
Parse the input string aadd
UNIT-III
1. What is Syntax directed Translation scheme? Explain with an Example.
2. Define L-Attributed and S-Attributed with Examples.
3. Explain the Evaluation order and construction of Syntax tree with Examples?
4. Explain the type conversion. Give the type convert rules for converting type from integer to real
5. Describe about type expressions?
UNIT-V
1. What are the object code forms? Explain the issues in code generation.
2. Explain about register allocation and assignment in target code generation
3. Explain about code generation algorithm with example?
4. What is DAG? Explain how a basic block is represented using DAG.
5. Describe about peephole optimization and code scheduling
Download