NPTEL Online Certification Courses Indian
Institute of Technology Kharagpur
Compiler Design
Assignment- Week 6
TYPE OF QUESTION:MCQ
Number ofquestions:11 Total mark: 11 X 1 = 11
1. For the grammar
S' → S
S → CC
C → cC | d
In state 0 of LR(1) parser, an item included is
a) C → .cC; c
b) C → .cC; d
c) C → .cC; c,d
d) C → .cC; c, $
Ans: c)
2. For the grammar
S' → S
S → CC
C → cC | d
In state 0 of LR(1) parser, an item included is
a) C → .d; c
b) C → .d; d
c) C → .d; c,d
d) C → .d; c, $
Ans: c)
3. In SLR parsing to get a shift-reduce conflict for state I on terminal symbol ‘a’,
a) A α.β with First(β) containing ‘a’ should be in I
b) A δ. be in I with Follow(A) having ‘a’
c) A α.β with First(β) containing ‘a’ should be in I and A δ. be in I with
Follow(A) having ‘a’
d) None of the other options
Ans: c)
4. In state I we have the items A α. and B δ., First(A), Follow(A) and Follow(B)
contains the symbol ‘a’. This leads to
a) Shift-reduce conflict
b) Reduce – reduce conflict
c) Both shift-reduce and reduce –reduce conflicts
d) No conflicts
Ans: b)
5. Between SLR, Canonical LR and LALR, which have same number of states
a) SLR and LALR
b) SLR and canonical LR
c) Canonical LR and LALR
d) All of them
Ans : a)
6. Construction of parsing table in which strategies do not need the Follow set?
a) SLR and canonical LR
b) Canonical LR and LALR
c) SLR and LALR
d) None of the given options
Ans: b)
7. In SLR parsing for the grammar
E' → E
E → aEbE | bEaE | ε
In state 0, for inputs 'a' and 'b'
a) Both will have shift-reduce conflict
b) Only 'a' will have shift-reduce conflict
c) Only 'b' will have shift-reduce conflict
d) Neither of the other options
Ans: a)
8. Amount of look ahead in LALR parser is
a) 1
b) 2
c) 3
d) None
Ans: a)
9. In SLR parsing for the grammar
S → B | SabS
B → bB | ε
In state 0, for inputs 'a' and 'b'
a) Both will have shift-reduce conflict
b) Only 'a' will have shift-reduce conflict
c) Only 'b' will have shift-reduce conflict
d) Neither of the other options
Ans: b)
10. Which of the following pairs is the most powerful
a) SLR
b) Canonical LR
c) LALR
d) Nothing can be said
Ans: b) Canonical LR
11. 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.
Ans: a)
END of Assignment