06: The BNF grammar rules below define CH output statements, where costream> can be any output strcant variable c.g., co
Posted: Fri May 20, 2022 12:03 pm
06: The BNF grammar rules below define CH output statements, where costream> can be any output strcant variable c.g., cout, and <string> represents any valid string object, while cint> denotes a literal integer. (xpr> -> Expr> '<<" <xpr> | <obj> Cobj> -> costream> | <string> | Cint> (a) Explain why this grammar is ambiguous. Show two different derivanons (left , right, or mixed) for the following sentence: cout << "n" < 4. (6 marks) (b) Resolve the ambiguity by making one change to the above grammar. Justify. Show the resulting derivation for the same sentence as in part (a). (4 marks)