recategorized by
13,701 views
40 40 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$

4 Answers

Best answer
33 33 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
22 22 votes

Shift reduce is bottom up parser. 

Output : 23131

Answer:
Position:
Show:

Related questions

54 54 votes
6 answers 6 answers
26.3k
26.3k views
Kathleen asked Oct 8, 2014
26,329 views
Consider a grammar with the following productions$S \rightarrow a \alpha b \mid b \alpha c \mid aB$$S \rightarrow \alpha S\mid b$$S \rightarrow \alpha b b\mid ab$$...
27 27 votes
5 5 answers
10.8k
10.8k views
Kathleen asked Oct 8, 2014
10,806 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...
9 9 votes
4 answers 4 answers
5.2k
5.2k views
Kathleen asked Oct 8, 2014
5,171 views
Construct the $\text{LL(1)}$ table for the following grammar.$Expr \rightarrow \_Expr$$Expr \rightarrow (Expr)$$Expr \rightarrow Var\; ExprTail$$ExprTail \rightarrow \_Ex...
50 50 votes
1 answers 1 answer
20.7k
20.7k views
Kathleen asked Oct 8, 2014
20,654 views
A linker is given object modules for a set of programs that were compiled separately. What information need not be included in an object module?Object codeRelocation bits...