retagged by
805 views
3 votes
3 votes

Consider the following syntax directed definition of any desk calculator:

  1. $L \rightarrow En \{ \text{print}(E.val) \}$
  2. $E \rightarrow E1 + 1 \{ E.val = E1.val + Z.val \}$
  3. $E \rightarrow Z  E \cdot val = Z \cdot val$
  4. $Z \rightarrow Z1 ^* F \{ Z.val = Z1.val  ^* F.val \}$
  5. $Z \rightarrow F \{ Z \cdot val = F \cdot val \}$
  6. $F \rightarrow ( E ) \{ F \cdot val = E \cdot val \}$
  7. $F\rightarrow digit \{ F \cdot val = digit \cdot lexval \}$

How many internal nodes are there in annotated parse tree for input $7 ^* 4 + 2n$?

  1. $9$
  2. $6$
  3. $10$
  4. $11$
retagged by

1 Answer

Best answer
5 votes
5 votes

i

It is 9 nodes.

selected by
Answer:

Related questions

2 votes
2 votes
2 answers
3
Bikram asked Nov 25, 2016
694 views
Consider the following grammar:$S \rightarrow L = P \mid P$$L \rightarrow ^*P \mid id$$P \rightarrow L$The above grammar is:AmbiguousSLR(1)LALR(1)None of the above
3 votes
3 votes
1 answer
4
Bikram asked Nov 25, 2016
284 views
Which grammar causes recursive-descent parser to go into infinite loop?LL(1)Left recursive grammarRight recursive grammarGrammar with left factors