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
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started