

Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
This page cannot be seen from the preview
Don't miss anything!


This assignment asks you to prepare written answers to questions on context-free grammars. Each of the questions has a short answer. You may discuss this assignment with other students and work on the problems together. However, your write-up should be your own individual work.
Please print your name and email address on your homework! We need this information so that we can give you credit for the assignment and so that we can return it to you.
S โ aSb S โ Sb S โ
(a) Give a one-sentence description of the language generated by this grammar. (b) Show that this grammar is ambiguous by giving a single string that can be parsed in two different ways. Draw both parse trees. (c) Give an unambiguous grammar that accepts the same language as the grammar above.
while not (x <- z <- 0) loop y <- z + 2 * x + 1 pool
Note that the context-free grammar by itself is ambiguous, so you will need to use the precedence and associativity rules in Section 11.1 to get the correct tree.