The following is an ambiguous grammar for expressions with n binary, infix operators, at n different levels of precedence: E -» E 0! E | E 0 2 E | • • • E 6n E | ( E ) | ida) As a function of n, what are the SLR sets of items?b) How would you resolve the conflicts in the SLR items so that all operators are left associative, and 6\ takes precedence over 02 , which takes precedence over # 3 , and so on?c) Show the SLR parsing table that results from your decisions in part (b).d) Repeat parts (a) and (c) for the unambiguous grammar, which defines the same set of expressions, shown in Fig. 4.55.e) How do the counts of the number of sets of items and the sizes of the tables for the two (ambiguous and unambiguous) grammars compare? What does that comparison tell you about the use of ambiguous expression grammars?
Fig. 4.55
Already registered? Login
Not Account? Sign up
Enter your email address to reset your password
Back to Login? Click here