edited by
6,401 views
36 votes
36 votes

Consider the context-free grammar

$E  \rightarrow E + E$
$E \rightarrow (E * E)$
$E  \rightarrow id$

where $E$ is the starting symbol, the set of terminals is $\{id, (,+,),*\}$, and the set of nonterminals is $\{E\}$.

Which of the following terminal strings has more than one parse tree when parsed according to the above grammar?

  1. $id + id + id + id$
  2. $id + (id* (id * id))$
  3. $(id* (id * id)) + id$
  4. $((id * id + id) * id)$
edited by

2 Answers

Best answer
31 votes
31 votes

Answer is A.

edited by
8 votes
8 votes
5 parse trees
Answer:

Related questions

37 votes
37 votes
4 answers
2
Kathleen asked Sep 22, 2014
23,300 views
The grammar $A \rightarrow AA \mid (A) \mid \epsilon$ is not suitable for predictive-parsing because the grammar is:ambiguousleft-recursiveright-recursivean operator-gram...
56 votes
56 votes
7 answers
3
1 votes
1 votes
3 answers
4
Satbir asked Jan 13, 2020
2,251 views
A grammar is defined as$A \rightarrow BC$$B \rightarrow x \mid Bx$$C \rightarrow B \mid D$$D \rightarrow y \mid Ey$$E \rightarrow z$The non terminal alphabet of the gram...