recategorized by
9,769 views
27 votes
27 votes

A shift reduce parser carries out the actions specified within braces immediately after reducing with the corresponding rule of grammar

  • $S \rightarrow xxW \;\text{{print“1"}}$
  • $S \rightarrow y \;\text{{print“2"}}$
  • $W \rightarrow Sz\; \text{{print“3"}}$

What is the translation of $xxxxyzz$ using the syntax directed translation scheme described by the above rules?

  1. $23131$
  2. $11233$
  3. $11231$
  4. $33211$
recategorized by

3 Answers

Best answer
28 votes
28 votes

Making a tree and performing post-order traversal will yield an answer as A.

  • $S \rightarrow xx W\; (\text{print }“1”)$
  • $W \rightarrow S z\; (\text{print }“3”)$
  • $S \rightarrow x x W\; (\text{print }“1”)$
  • $W \rightarrow S z\; (\text{print }“3”)$
  • $S \rightarrow y\; (\text{print }“2”)$
edited by
17 votes
17 votes

Shift reduce is bottom up parser. 

Output : 23131

Answer:

Related questions

38 votes
38 votes
3 answers
1
23 votes
23 votes
4 answers
2
Kathleen asked Oct 8, 2014
6,548 views
Translate the arithmetic expression $a^\ast -(b+c)$ into syntax tree.A grammar is said to have cycles if it is the case that $A \overset{+}{\Rightarrow} A$ Show that no g...
44 votes
44 votes
1 answer
4