0% found this document useful (0 votes)
27 views3 pages

232_Sheet_08_01

The document contains exercises related to compiler design, focusing on SLR(1) parsing automata, first and follow sets, and shift-reduce parsing conflicts. It includes questions about specific grammars, parsing strategies, and the identification of conflicts in parsing states. The exercises aim to deepen understanding of compiler principles and techniques.
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)
27 views3 pages

232_Sheet_08_01

The document contains exercises related to compiler design, focusing on SLR(1) parsing automata, first and follow sets, and shift-reduce parsing conflicts. It includes questions about specific grammars, parsing strategies, and the identification of conflicts in parsing states. The exercises aim to deepen understanding of compiler principles and techniques.
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/ 3

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.
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 '('.

Page 1 of 3 Ver 1.0


Compiler Design
CSC 480
Misr International university Sheet 08 Faculty of Computer Science

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,

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?

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:


Page 2 of 3 Ver 1.0
Compiler Design
CSC 480
Misr International university Sheet 08 Faculty of Computer Science

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)

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 3 of 3 Ver 1.0

You might also like