0% found this document useful (0 votes)
12 views5 pages

232 - Sheet - 08 - 01 MA

The document contains a series of questions related to compiler design, focusing on SLR(1) parsing automata, first and follow sets, and shift-reduce parsing conflicts. It includes specific grammar examples and asks for analysis of parsing techniques and conflicts. The questions aim to assess understanding of concepts in compiler construction and parsing strategies.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
12 views5 pages

232 - Sheet - 08 - 01 MA

The document contains a series of questions related to compiler design, focusing on SLR(1) parsing automata, first and follow sets, and shift-reduce parsing conflicts. It includes specific grammar examples and asks for analysis of parsing techniques and conflicts. The questions aim to assess understanding of concepts in compiler construction and parsing strategies.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 5

Book: Compilers: Principles, Techniques, and Tools (Second Edition)

Alfred Aho, Monica Lam, Ravi Sethi, and Jeffrey Ullman. Addison-Wesley
1. Consider the grammar

Draw the SLR(1) parsing automaton for the grammar?

2. Consider the following grammar:

What are the first and follow sets of S?

3. What are the items in the initial state of the SLR(1) parsing automaton for the grammar in
last question(Question 1)?

4. Which of the following are true of the initial state of the SLR(1) parsing automaton from the
last question (Question 2)?
[Choose all that apply]
a) This state has a shift-reduce conflict on input x.
CSC 480 Page 1 of 5 Ver 1.0
b) The state has a reduce-reduce conflict on input x.
c) The state has a reduce-reduce conflict on transition S.
d) This state has a shift-reduce conflict on transition S.
e) This state has a shift-reduce conflict on end-of-input.
f) This state has a shift-reduce conflict on input '('.
g) The state has a reduce-reduce conflict on end-of-input.
h) The state has a reduce-reduce conflict on input '('.

5. Consider grammars G1, G2, and G3.

The number of symbols in the first sets for the *non-terminals* are: ?

6. Given the following grammar,

Page 2 of 5 Ver 1.0


Write a valid bottom-up parsing for the string:
if a then if b then win else loss

7. For the grammar in last question (Question 5), when applying shift-reduce parsing to the
same string:
if a then if b then win else loss
What kind of conflicts will we have?

CSC 480 Page 3 of 5 Ver 1.0


8. Consider the following grammar:

Using shift-reduce parsing, how many shift and how many reduce moves does it take to
accept the input string:
((int + int)*int)

9. Consider the following grammar:

This grammar is:


a) LL(1)
b) SLR(1) but not LL(1)
c) not SLR(1)

10. Consider the following grammar:

This grammar is:


a) LL(1)
b) SLR(1) but not LL(1)
c) not SLR(1)

11. Consider the following grammar:

This grammar is:


a) LL(1)
b) SLR(1) but not LL(1)
c) not SLR(1)

Page 4 of 5 Ver 1.0


12. Which of the following statements are true about this grammar:

a) The first set of U is {a, b, c}


b) The first set of S is {ϵ, a, b}
c) The follow set of T is {a, b, c}
d) The follow set of S is {$, b}

Page 5 of 5 Ver 1.0

You might also like