Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                

Assignment 0656643

Download as pdf or txt
Download as pdf or txt
You are on page 1of 3

Compiler Design

Prof. Santanu Chattopadhyay


IIT Kharagpur

Assignment-6 (Week 6)

Q1. In the name “LR Parser”, the ‘L’ and ‘R’ stands for:
(A) Left-to-right scanning and constructing a Rightmost Derivation in Reverse
(B) Left-to-right scanning and constructing a Rightmost Derivation
(C) Left to right reduction
(D) None of the other options

Ans: A

Q2. SLR parser is LR(k) parser with k equals to:


(A) 1
(B) 2
(C) 3
(D) None of the other options

Ans: D

Q3. In SLR parsing for the grammar


S’ → S
S → aSbS
S → bSaS | ε
In state 0, for inputs 'a' and 'b'
(A) Both ‘a’ and ‘b’ 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

Q4. Consider the grammar given below:


E→E+T
E→T
T→T*F
T→F
F → (E)
F → id
Let, I0 = CLOSURE([E’ → .E]). How many items are there in the set GOTO( I0 , ( )?
(A) 4
(B) 5
(C) 6
(D) 7

Ans: D
Q5. Consider the following grammar:
S→L=R
S→R
L→*R
L → id
R→L
Consider the set of LR(0) items and let I2 is as given below:
S → L .=R
R → L.
The entry in ACTION[2, =] is:
(A) Shift to some state
(B) Reduce using some production
(C) A shift-reduce conflict
(D) None of the above

Ans: C

Q6. In LR(1) parsing, we reduce by A → α only on those input symbols a for which [A → α., a] is
an LR(1) item in the state on top of the stack. The set of such a’s will always be:
(A) Equal to the set FOLLOW(A)
(B) A subset of FOLLOW(A)
(C) A proper subset of FOLLOW(A)
(D) None of the above

Ans: B

Q7. Consider the following grammar G:


S→A|B
A→ a|c
B→b|c
Here, S, A and B are non-terminals and a, b, and c are terminals. Consider the two statements given
below:
S1: Unambiguous LL(1) parser can be constructed to parse all strings in L(G)
S2: Conflict-free LR(1) parser exists to parse all strings in L(G)
Which one of the following is true?
(A) S1
(B) S2
(C) Both S1 and S2
(D) Neither S1 nor S2

Ans: D

Q8. Consider the following two statements:


P: Every regular grammar is LL(1)
Q: Every regular set has a LR(1) grammar
Which of the following is TRUE?
(A) Both P and Q are true
(B) P is true and Q is false
(C) P is false and Q is true
(D) Both P and Q are false
Ans: C

Q9. Which one from the following is false?


(A) LALR parser is Bottom-up parser
(B) A parsing algorithm which performs a left to right scanning and a right most deviation in reverse
is RL(1)
(C) LR parser is Bottom-up parser
(D) In LL(1), the 1 indicates that there is a one-symbol look-ahead.

Ans: B

Q10. Which of the following statements is false?


(A) An ambiguous grammar may have LL(1) parser without multiple definitions
(B) An LL(1) parser is a top-down parser
(C) LALR is more powerful than SLR
(D) An ambiguous grammar can never be LR(k) for any k

Ans: A

You might also like