• retagged by
1,205 views
1 1 vote

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

S -> AS      { print 1 }

S -> AB      { print 2 }

A -> a        { print 3 }

B -> bC      { print 4 }

B -> dB     { print 5 }

C -> c       { print 6 }

This SDT scheme translates a language whose terminal symbols are a, b, c and d into another language whose terminal symbols are 1, 2, 3, 4, 5, 6. What is the translation of "aaadbc" ?

A) 333546211

B) 654211

C) 645323131

D) 645233311

2 Answers

1 1 vote
It is 333645211.
0 0 votes

The grammar production for deriving the string $“aaadbc”$ is as follows:

  • $S\rightarrow AS\rightarrow aS\rightarrow aAS\rightarrow aaS\rightarrow aaAB\rightarrow aaaB\rightarrow aaadB\rightarrow aaadbC\rightarrow aaadbc$

Print the given terminal symbol in the grammar immediately after the reduce move is performed, we get $333645211$

 

Position:
Show:

Related questions

2 2 votes
1 answers 1 answer
726
726 views
Wren Oswin asked Oct 23, 2025
726 views
Consider the following SDT:S - T RR - {printf("*")} + T {printf("*")} R {printf("+")}T - num {printf("*")}R - ε {printf("+")}How many * will be printed before the first +...
0 0 votes
0 0 answers
471
471 views
Ebrahim asked Oct 17, 2024
471 views
Q4. Check the ambiguity for the string id[id]in the given grammar:E → E+T | TT → id | id[ ] | id[X]X → E , E | E Please answer like example in this page link https://ww...