Question: Problem 1 - Ambiguity You want to include an arithmetic switch statement in a programming language. The semat- ics of the new construct is as

 Problem 1 - Ambiguity You want to include an arithmetic switch

statement in a programming language. The semat- ics of the new construct

Problem 1 - Ambiguity You want to include an arithmetic switch statement in a programming language. The semat- ics of the new construct is as follows: The expression in the switch statement is evaluated to an integer value .z", and the LX-th" statenent in the statenent list stmt st) is executed if such a statement exists. If no such statement exists, and a default case is specified, the default case is executed. Here is a proposed partial grammar for the switch statement extension. stmt) case arith.cxpr) : : stmtList) case arith, expr) :: (stmt-list) default (stmt) stmt);(stmtList) stmt 1 ::- | 2 (stint-list) 4 | ::- 1. Is the grammar ambiguous? Make a formal argument. 2. If the grammar is ambiguous, how can you change theanage such that its grammar is unambiguous. Show the grammar Problem 2 - Parse trees, derivations, and left-recursion Consider the following grammar with start symbol A 1. Give parse trees for the sentences (a, a) and ((a, a), a) 2. Construct a leftmost and a rightmost derivation for the sentence ((a, a), a) 3. Eliminate the left recursion from the grammar and show the resulting grammar

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!