1,476 views
1 1 vote

A shift reduced parser carries out the actions specified within braces Immediately after reducing with the corresponding rule of grammar.

S -->  xxW (print 'a')
S --> Y        (print'b')
W --> Sz    (print 'c')

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

  1. bcaca
  2. aabcc   
  3. aabca    
  4. ccbaa

1 Answer

Best answer
5 5 votes
The right most derivation of the string xxxxyzz is:
 S-> xxW -> xxSz  --> xxxxWz ---> xxxxSzz  --> xxxxyzz
A shift reduce parser, performs the right most derivation in reverse. So first it reduces the y to 5, by the production S --> Y . As a consequence of this, b is immediately printed. Next, Sz is reduced to W and so on. So the answer is bcaca.
• selected by
Answer:
Position:
Show:

Related questions

2 2 votes
1 answers 1 answer
1.5k
1.5k views
Bikram asked Jan 16, 2017
1,507 views
For the given grammar consider the statements:$S' \rightarrow S$$S \rightarrow aAd \mid bBd \mid aBe \mid bAe$$A \rightarrow c$$B \rightarrow c$Which of the following...
1 1 vote
1 answers 1 answer
795
795 views
Bikram asked Jan 16, 2017
795 views
What will be the resulting grammar after removal of left-recursion from the following grammar?$E$ $\rightarrow$ $Ea $|$ Eb $|$ a $|$ b$$E$$\rightarrow$ $aE'$|$ bE'$ ; ...
1 1 vote
1 answers 1 answer
852
852 views
Bikram asked Jan 16, 2017
852 views
Consider the following grammar for Boolean expression:$E$ $\rightarrow$ $E$ OR $E$$E$ $\rightarrow$ $E$ AND$E$$E$ $\rightarrow$ NOT $E$$E$ $\rightarrow$ $\left ( E \right...
1 1 vote
1 answers 1 answer
789
789 views
Bikram asked Jan 16, 2017
789 views
Match the following:List IList IIABackus Naur form 1Regular expressionBLex2$\left ( I \right )$$LALR$CYacc3$LL$$\left ( 1 \right )$DRecursive descent parsing 4$CFG's$ $...