Question: 1. Write a BNF grammar that can generate nested if-else structures. Assume, the statements inside the If-else block to be simple. Eg of the

1. Write a BNF grammar that can generate nested if-else structures. Assume,

1. Write a BNF grammar that can generate nested if-else structures. Assume, the statements inside the If-else block to be simple. Eg of the statement that can be generated is if(x>y}{ } x = x + y; if(z>0){ else{ } } y = x; x=x-y; Also show the left-derivation of any statements of your choice that illustrates the correctness of your grammar. 2. Show the left and right derivation for the string "aaabbabbba" using the following grammar, SaB/bA A as /bAA/a BbS/aBB/b 3. Using the Parse trees, determine whether the grammar from Q2 is ambiguous or not

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Programming Questions!