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? $23131$ $11233$ $11231$ $33211$ Compiler Design gate1995 compiler-design grammar syntax-directed-translation normal + – Kathleen 13.7k views answer comment Share Follow Print See all 3 Comments 3 3 Comments reply chauhansunil20th commented Nov 30, 2018 reply Follow flag In the string $xxxxyzz$, $y$ will reduce first to S as there is no other handle other than y. Hence, we can eliminate all other options and A is the correct option. 2 2 replyShare ritiksri8 commented Nov 4, 2024 reply Follow flag if all the semantic actions at the end apply bottom up The question also hints indirectly to use bottom up 0 0 replyShare chidambareswar23 commented Jan 29 i edited by chidambareswar23 Jan 29 reply Follow flag All questions related to Syntax Directed Translation Scheme(SDTS):Compiler Design: GATE CSE 1995 | Question: 2.10Compiler Design: GATE CSE 1996 | Question: 20Compiler Design: GATE CSE 2000 | Question: 19Compiler Design: GATE CSE 2016 Set 1 | Question: 46Compiler Design: GATE CSE 2021 Set 1 | Question: 26Compiler Design: GATE CSE 2022 | Question: 55Compiler Design: GATE CSE 2023 | Question: 50Compiler Design: GATE CSE 2003 | Question: 58Compiler Design: GATE CSE 2004 | Question: 45Compiler Design: GATE CSE 2006 | Question: 59 2 2 replyShare Please log in or register to add a comment.
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”)$ Gate Keeda answered Oct 9, 2014 • edited Apr 25, 2021 by Lakshman Bhaiya Gate Keeda comment Share Follow See all 3 Comments 3 3 Comments reply Cruise Device commented Jan 15, 2016 reply Follow flag why can't we take s--> y(pf'2') at the 3rd step? 0 0 replyShare Kajal K commented Mar 21, 2018 reply Follow flag @Cruise Device because, if we do so then we cannot generate the given string. 0 0 replyShare RAPAKA_LOKESH commented Dec 29, 2024 reply Follow flag @Cruise Device if you take s->y at third step then our requirement of producing string : xxxxyzz will not be satisfiedour output will look like xxyz.so,we are supposed to do s->y in third step. 0 0 replyShare Please log in or register to add a comment.
22 22 votes Shift reduce is bottom up parser. Output : 23131 pC answered Oct 22, 2016 pC comment Share Follow See all 2 Comments 2 2 Comments reply AshwiniT commented Jan 22, 2018 reply Follow flag We should not use L attribute and S attribute thingy 0 0 replyShare Umesh Shelke commented Oct 14, 2025 reply Follow flag This Should be The Best Answer. 0 0 replyShare Please log in or register to add a comment.
0 0 votes ⇒ 23131 Note SR is bottom up parser. varunrajarathnam answered Sep 22, 2020 varunrajarathnam comment Share Follow 0 reply Please log in or register to add a comment.
0 0 votes A seems correct. Ninja004 answered Dec 2, 2025 Ninja004 comment Share Follow 0 reply Please log in or register to add a comment.