Unformatted text preview: * x + 1 else if ( b == 0) then x = 3 * x + 2 else x = 3 * x-1. When E is written in place of Boolean expressions and S is written in place of statements, this can be written as if (E1) then S1 else if (E2) then S2 else S3. Show a parse tree for this statement using grammar G 1 . (b) Draw two diﬀerent parse trees for grammar G 1 and string if (E1) then if (E2) then S2 else S3. 3.1.2 Draw a parse tree for the same string if (E1) then if (E2) then S2 else S3 using grammar G 2 . 3.1.3 Answer the following questions: • Is the grammar G 1 ambiguous? Explain. • Which of the two trees generated with grammar G 1 correspond to the meaning of the statement in a typical programming language (such as C++)? • Is grammar G 2 ambiguous? How could you justify your answer? 1...
View Full Document
- Fall '09
- Computer Science, Department of Computer Science, University of Kentucky.— —Please, grammar g1