edited by
6,711 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
32 votes
32 votes

Answer is A.

edited by
8 votes
8 votes
5 parse trees
Answer:

Related questions

7.2k
views
4 answers
37 votes
Ishrat Jahan asked Nov 3, 2014
7,168 views
Consider the context-free grammar$E\rightarrow E+E$E\rightarrow (E *E)$E\rightarrow \text{id}$where $E$ ... $, how many parse trees are possible?$5$4$3$2$
24.1k
views
4 answers
37 votes
Kathleen asked Sep 22, 2014
24,083 views
The grammar $A \rightarrow AA \mid (A) \mid \epsilon$ is not suitable for predictive-parsing because the grammar is:ambiguousleft-recursiveright-recursivean operator-grammar
21.0k
views
7 answers
56 votes
Kathleen asked Sep 22, 2014
21,019 views
Statement for Linked Answer Questions 83a & 83b:Consider the following expression grammar. The semantic rules for expression evaluation are stated next to each grammar ... and resolves the conflict in favor of a reduce over a shift action
2.4k
views
3 answers
1 votes
Satbir asked Jan 13, 2020
2,363 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 grammar is$\{A,B,C,D,E\}$\{B,C,D,E\}$\{A,B,C,D,E,x,y,z\}$\{x,y,z\}$