0% found this document useful (0 votes)
31 views7 pages

CS8602 Compiler Design UNIT 2 MCQ

Download as pdf or txt
Download as pdf or txt
Download as pdf or txt
You are on page 1/ 7

www.edubuzz360.

com
ChettinadTech Dept of CSE

Department of Computer Science and Engineering


CS8602 Compiler Design

Unit II - MCQ Bank

1. The construction of the canonical collection of the sets of LR (1) items are similar to the
construction of the canonical collection of the sets of LR (0) items. Which is an exception?
A. Closure and goto operations work a little bit different
B. Closure and goto operations work similarly
C. Closure and additive operations work a little bit different
D. Closure and associatively operations work a little bit different

Answer: (A)

2. When ß is empty (A -> ß.,a), the reduction by A-> a is done by _________


A. If next symbol is a terminal
B. Only If the next input symbol is a
C. Only If the next input symbol is A
D. Only if the next input symbol is a

Answer: (D)

3. When ß (in the LR(1) item A -> ß.a,a) is not empty, the look-ahead _________
A. Will be affecting
B. Does not have any affect
C. Shift will take place
D. Reduction will take place

Answer: (B)

CS8602 – Compiler Design Page 1

https://play.google.com/store/apps/details?id=com.sss.edubuzz360
www.edubuzz360.com
ChettinadTech Dept of CSE

4. When there is a reduce/reduce conflict?


A. If a state does not know whether it will make a shift operation using the production rule i or j for a
terminal
B. If a state does not know whether it will make a shift or reduction operation using the production
rule i or j for a terminal
C. If a state does not know whether it will make a reduction operation using the production rule
i or j for a terminal
D. None of the mentioned

Answer: (C)

5. If a state does not know whether it will make a shift operation or reduction for a terminal is called
_________
A. Shift/reduce conflict
B. Reduce /shift conflict
C. Shift conflict
D. Reduce conflict

Answer: (A)

6. Which of these is true about LR parsing?


A. Is most general non-backtracking shift-reduce parsing
B. It is still efficient
C. Is most general non-backtracking shift-reduce parsing & It is still efficient
D. None of the mentioned

Answer: (C)

7. An LR-parser can detect a syntactic error as soon as __________


A. The parsing starts
B. It is possible to do so a left-to-right scan of the input
C. It is possible to do so a right-to-left scan of the input
D. Parsing ends

CS8602 – Compiler Design Page 2

https://play.google.com/store/apps/details?id=com.sss.edubuzz360
www.edubuzz360.com
ChettinadTech Dept of CSE

Answer: (B)

8. What is the similarity between LR, LALR and SLR?


A. Use same algorithm, but different parsing table
B. Same parsing table, but different algorithm
C. Their Parsing tables and algorithm are similar but uses top down approach
D. Both Parsing tables and algorithm are different

Answer: (A)

9. Shift reduce parsers are __________


A. Top down parser
B. Bottom up parser
C. Maybe both
D. None of the mentioned

Answer: (B)

10. A grammar that produces more than one parse tree for some sentence is called __________
A. Ambiguous
B. Unambiguous
C. Regular
D. None of the mentioned

Answer: (A)

11. A bottom up parser generates __________


A. Right most derivation
B. Right most derivation in reverse
C. Left most derivation
D. Left most derivation in reverse

Answer: (B)

CS8602 – Compiler Design Page 3

https://play.google.com/store/apps/details?id=com.sss.edubuzz360
www.edubuzz360.com
ChettinadTech Dept of CSE

12. A top down parser generates __________


A. Rightmost Derivation
B. Right most derivation in reverse
C. Left most derivation
D. Left most derivation in reverse

Answer: (C)

13. YACC builds up __________


A. SLR parsing table
B. Canonical LR parsing table
C. LALR parsing table
D. None of the mentioned

Answer: (C)

14. What is the maximum number of reduce moves that can be taken by a bottom-up parser for a
grammar with no epsilon- and unit-production to parse a string with n tokens?
A. n/2
B. n-1
C. 2n-1
D. 2^n

Answer: (B)

15. Consider the following grammar G.

S→F⎪H

F→p⎪c

H→d⎪c

CS8602 – Compiler Design Page 4

https://play.google.com/store/apps/details?id=com.sss.edubuzz360
www.edubuzz360.com
ChettinadTech Dept of CSE

Which one is true?


S1: All strings generated by G can be parsed with help of LL (1).
S2: All strings generated by G can be parsed with help of LR (1).

A. Only S1
B. Only S2
C. Both S1 & S2
D. None of the mentioned

Answer: (D)

16. Which of the following statements is false?


A. Unambiguous grammar has both kind of derivations.
B. An LL(1) parser is a top-down parser
C. LALR is more powerful than SLR
D. Ambiguous grammar can’t be LR(k)

Answer: (A)

17. Which of the following derivations does a top-down parser use while parsing an input string?
A. Leftmost derivation
B. Leftmost derivation in reverse
C. Rightmost derivation
D. Rightmost derivation in reverse

Answer: (A)

18. Which of these is not true about the Symbol Table?


A. All the labels of the instructions are symbols
B. Table has entry for symbol name address value
C. Perform the processing of the assembler directives
D. Created during pass 1

Answer: (C)

CS8602 – Compiler Design Page 5

https://play.google.com/store/apps/details?id=com.sss.edubuzz360
www.edubuzz360.com
ChettinadTech Dept of CSE

19. Which of the following system software resides in the main memory?
A. Text Editor
B. Assembler
C. Linker
D. Loader
Answer: (D)

20. Which language is accepted by the push-down automata?

A. Type 0 language
B. Type 1 language
C. Type 2 language
D. Type 3 language

Answer: (C)

21. Leaf nodes in a parse tree indicate?

A. sub-terminals
B. half-terminals
C. non-terminals

D. terminals

Answer: (D)

22. Which phenomenon happens when the non-terminal on the left side is repeated as the first symbol
on the right side?

A. Left-most derivation
B. Left recursion
C. Left factoring
D. Left parsing

CS8602 – Compiler Design Page 6

https://play.google.com/store/apps/details?id=com.sss.edubuzz360
www.edubuzz360.com
ChettinadTech Dept of CSE

Answer: (B)

23. In which derivation the right-most non-terminal symbol is replaced at each step?

A. Right look ahead


B. Right claim

C. Rightmost
D. Right non-terminal

Answer: (C)

24. In which derivation the leftmost non-terminal symbol is replaced at each step?

A. Left recursion
B. Left non-terminal
C. Left pushdown
D. Leftmost

Answer: (D)

25. Which symbol is not related to context-free grammar?

A. End symbol
B. Start symbol
C. Non-terminal symbol
D. Terminal symbol

Answer: (A)

CS8602 – Compiler Design Page 7

https://play.google.com/store/apps/details?id=com.sss.edubuzz360

You might also like