Question: In languages such as C and C + + , assignments are also expressions. In such languages, the following is a syntactically correct statement: n

In languages such as C and C++, assignments are also expressions. In such languages, the following is a syntactically correct statement: n =3+( m =4) The value of ( m =4) is the value assigned, namely 4. Thus, the value 7 is assigned to the variable n. Suppose we extend the grammar from the previous question to include assignments as follows: E E $$ E id = E E T Ttl Ttl + T Ttl Ttl - T Ttl Ttl T F Ftl Ftl * F Ftl Ftl / F Ftl Ftl F id F ( E ) Note that in the example above, the parentheses around ( m =4) are necessary. The grammar above does NOT generate the string: id = id + id * id = id + id However, id = id = id + id * id + id and id = id + id *(id = id + id) CAN be generated. This is consistent with C/C++.1. Compute EPS, FIRST and FOLLOW for each nonterminal in the grammar above. Recall that $$ is the end-of-input marker. 2. Explain why the grammar above is not LL(1). Be specific. 3. Modify the grammar above to obtain an equivalent grammar that is LL(1). Your modified grammar must generate the same set of strings as the original grammar. Explain why your modified grammar is indeed LL(1). Note: It does not work to modify the grammar to allow F to generate assignments, because if F id = id + id , then id = id + id * id = id + id can be generated and it should not be. Answer all 3 questions
In languages such as C and C + + , assignments

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 Programming Questions!