726 views
0 votes
0 votes

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
3 votes
3 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:

Related questions

1 votes
1 votes
1 answer
4
Bikram asked Jan 16, 2017
381 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$ $...