Write a context-free grammar for parenthesized arithmetic expressions that contains the operators `+', `-', `*', `/', and , where is right-associative and has highest precedence, the other operators are left associative and have their usual precedences. Parentheses are used to override the built-in associativities and precedences. Use the simple ambiguous grammar and assume that the bison-like parser ``does the right thing'' in building a parse tree.
Write an attribute grammar that prints out the expression in infix form and that checks each of the following properties, generating an error message if the property is not satisfied. You may invent the side-effect-free attribution language, or take it from one of the papers. Be sure to `declare' the attributes, indicating for each whether it is inherited or synthesized. To clarify your answer, explain how each of the checks is carried out (i.e. provide some intuition).