0 0 votes Let ' $G$ ' be a grammar with the following translations: \[ \begin{array}{l} S \rightarrow \text { p\{print "G"\} } P \\ P \rightarrow \text { q\{print "A"\} } Q \\ P \rightarrow r\{\text { print " " } "\} \\ P \rightarrow \varepsilon\{\text { print "E"\} } \\ Q \rightarrow \text { s\{print "A"\} } P \\ Q \rightarrow \varepsilon\{\text { print " } O \text { " }\} \end{array} \] What is the output produced for the input "pqsqsr" using the bottom-up parsing with above translations? Compiler Design compiler-design parsing test-series + – Rajesh R 2.3k views answer comment Share Follow Print See all 4 Comments 4 4 Comments reply Rajesh R commented Nov 6, 2017 reply Follow flag GAAAT or TAAAG ? 0 0 replyShare Akash Mittal commented Nov 6, 2017 reply Follow flag GAAAT 0 0 replyShare arch commented Nov 20, 2017 reply Follow flag what will be the correct answer? 0 0 replyShare Vishal Goel commented Jan 6, 2018 reply Follow flag I think it should be GAAAAT. If the print statements were at the end of each production, then it would have been TAAAAG. 1 1 replyShare Please log in or register to add a comment.
0 0 votes Ans. TAAAAG targate2018 answered Nov 6, 2017 • edited Nov 6, 2017 by targate2018 targate2018 comment Share Follow See 1 comment 1 1 comment reply vrajdobariya commented Dec 19, 2020 reply Follow flag here parse tree is correct but answer should be GAAAAT. here in 1st production rule,before reduction and after p, we have to perform semantic action.so when p occurs we print G so reduction perform in bottom to up traverse as usual but semantic action perform before reduction. 0 0 replyShare Please log in or register to add a comment.
0 0 votes ans is TAAAAG suryaprakash answered Jun 13, 2018 suryaprakash comment Share Follow 0 reply Please log in or register to add a comment.