You are on page 1of 3

1. Consider the following SDT.

A BC *(I) B.i = f(A.i)


(II) B.i = f(A.S)
(III) A.S = f(B.s)
Which of the above is violating L attributed definition?
(a) I only (b) II only
(c) I, II (d) I, II, III
Solution: Option (b)

2. Consider the following grammar.

S aB | aAb
A bAb | a
B aB |
How many back tracks are required to generate the string aab from the above grammar?
(a) 1 (b) 2
(c) 3 (d) 4
Solution: Option (b)

3. Choose the False statement.

(a) No left recursive/ ambiguous grammar can be LL(1)


(b) The class of grammars that can be parsed using LR methods is proper subset of the class of
grammar that can be parsed by LL method
(c) LR parsing is non-backtracking method
(d) LR parsing can describe more languages than LL parsing
Solution: Option (b)

4. If attribute can be evaluated in depth-first order then definition is

(a) S attributed (b) L attributed


(c) Both (a) and (b) (d) None of these
Solution: Option (b)

5. S Sa | b
Which of the following is True?
(a) There will be SR conflict during parsing
(b) There will be RR conflict during Parsing
(c) There will be both conflict
(d) There will be no conflict
Solution: Option (d)

6. A grammar can have


a) a non-terminal A that cant derive any string of terminals
(b) a non-terminal A that can be present in any sequential form
(c) all of the above
(d) none of the above
Solution: Option (c)

7. A bottom-up parser generates


(a) Left-most derivation (b) right-most derivation
(c) right-most derivation in reverse (d) left-most derivation in reverse
Solution: Option (c)

8. Choose the correct statement


(a) Language corresponding to a given grammar, is the set of all strings that
can be generated by the given grammar
(b) A given language is ambiguous if no unambiguous grammar exists for it
(c) Two different grammars may generate the same language
(d) All of the above
Solution: Option (d)

9. Reduction in strength means


(a) replacing run time computation by compile time computation
(b) removing loop invariant computation
(c) removing common sub-expressions
(d) replacing a costly operation by a relatively cheaper one
Solution: Option (d)

10. Which of the following comments about peep-hole optimization are True?
(a) It is applied to a small part of the code
(b) It can be used to optimize intermediate code
(c) It can be applied to a portion of the code that is not contiguous
(d) All of the above
Solution: Option (d)

11. In a syntax directed translation scheme, if the value of an attribute of a node is a function
of the values of the attributes of its children, then it is called a
(a) synthesized attribute (b) inherited attribute
(c) canonical attribute (d) none of the above
Solution: Option (a)

12. Which of the following is not an intermediate code form?


(a) Postfix notation (b) Syntax trees(c) Three address codes (d) Quadruples
(a) Solution: Option (d)
13. Syntax directed translation scheme is desirable because

(a) it is based on the syntax


(b) its description is independent of any implementation
(c) it is easy to modify
(d) only (a) and (c) are correct
Solution: Option (a), (b) & (c)
14. Symbol table can be used for
(a) checking type compatibility (b) suppressing duplicate error messages
(c) storage allocation (d) all of the above
Solution: Option (d)

15. The cost of developing a compiler is proportional to the


(a) complexity of the source language
(b) complexity of the architecture of the target machine
(c) flexibility of the available instruction set
(d) all of the above
Solution: Option (d)

16. An optimizing compiler


(a) is optimized to occupy less space
(b) is optimized to take less time for execution 2
(c) optimizes the code
(d) All of the above
Solution: Option (c)

17. A top-down parser generates


(a) left-most derivation (b) right-most derivation
(c) right-most derivation in reverse (d) left-most derivation in reverse
Solution: Option (a)

18. In a compiler, grouping of characters into tokens is done by the


(a) scanner (b) parser
(c) code generator (d) code optimizer
Solution: Option (a)

19. CFG can be recognized by a


(a) push-down automata (b) finite state automata
(c) 2-way linear bounded automata (d) statement (b) incorrect
Solution: Option (d)

20. The number of tokens in the following C statement is


printf("i = %d, &i = %x", i, &i);
a)3 c)10
b)26 d)21
Solution 10(c)

You might also like