- 06 The Bnf Grammar Rules Below Define Ch Output Statements Where Costream Can Be Any Output Strcant Variable C G Co 1 (89.29 KiB) Viewed 29 times
06: The BNF grammar rules below define CH output statements, where costream> can be any output strcant variable c.g., co
-
- Site Admin
- Posts: 899603
- Joined: Mon Aug 02, 2021 8:13 am
06: The BNF grammar rules below define CH output statements, where costream> can be any output strcant variable c.g., co
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)