Problem 1: Ambiguous Grammars
As you may recall, the following grammar for ``simplified if'' is ambiguous. (All lowercase words are terminals, which is one of the reasons its simplified.)
S ::= C | s C ::= if e then S else S | if e then S
Appel presents an unambiguous version of this grammar on p. 69 of the red book and p. 68 of the green book.
Verify that his grammar is unambiguous.
Prove that the two grammars are equivalent.
Problem 2: Sample Grammars
Do problem 3.3 parts a-d from Appel.
Problem 3: LL Grammars
Redo problem 2, ensuring that the grammars are suitable for LL(1) parsing. You will need to eliminate left recursion and possibly left factor the grammars. Note that we will not cover either of these techniques in depth in class.
Problem 4: Tables galore
Build the First, Follow, and Nullable tables for any four grammars in problems 2 and 3. You should do at least one grammar from each problem.
Problem 5: Finite automata
Do problems 3.9, 3.11, and 3.12 from Appel.
Disclaimer Often, these pages were created "on the fly" with little, if any, proofreading. Any or all of the information on the pages may be incorrect. Please contact me if you notice errors.
Source text last modified Fri Oct 2 09:27:32 1998.
This page generated on Fri Oct 2 09:36:29 1998 by SiteWeaver.
Contact our webmaster at email@example.com