1. Engineering
  2. Computer Science
  3. 3 consider the following grammar for a program prog ...

Question: 3 consider the following grammar for a program prog ...

Question details

3. Consider the following grammar for a program Prog → StmtSeq -> AssignStmt WhileStmt Stmt AssignStmtV-E WhileStmt → while CExpr do StmtSeq BExpr In the above, non-terminals: Any symbol that appears on the left-hand side of the production rules terminals: {z, y, z, +,-, *, / ; , while, do, >, <,-,--, &&, !} . e start symbol: Prog We have discussed in class that ambiguiting in grammar may result in ambiguiting in intepreting the semantics of the sentences in the language of the grammar. Assuming the standard meaning for the operations/operators, is it possible for the above grammar to generate programs whose semantics is ambiguous? Explain your answer (if your answer is no, then provide arguments to support to your answer; if your answer is yes, present a program which has at least two distinct parse trees because of which the semantics of the program may become ambiguous as well).

Solution by an expert tutor
Blurred Solution
This question has been solved
Subscribe to see this solution