Question: Let E be an expression, A be an assignment statement following the grammar we have discussed in class (using factor F and term T) with

Let E be an expression, A be an assignment statement following the grammar we have discussed in class (using factor F and term T) with T={id, num, +, *, (, ), =} and N={A, E, T, F}. Recall that the vertical | means "or". A => id = E E => E + T | T T => T * F | F F => id | num | ( E ) We can build on this grammar to define an IF statement as follows: let I be a non-terminal standing for IF statement and S be non-terminal for statement. Add terminals "if", "then" and "else". Then we can havea grammar for both assign and if statements as follows: S => A | I I => if E then S else S | if E then S However, the rule for I is ambiguous (although the grammar for A is not). Explain what we mean by ambiguous in this case, and find an example that shows the ambiguity.

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 Databases Questions!