42 42 votes Consider the grammar with the following translation rules and $E$ as the start symbol$$\begin{array}{lll}E \rightarrow E_ 1\# \: T & \qquad\left\{E.value = E_1.value * T.value\right\}\\\qquad\mid T & \qquad \{E.value = T.value\}\\T \rightarrow T_1 \& \: F &\qquad \{T.value = T_1.value + F.value\}\\\qquad\mid F&\qquad \{T.value = F.value\}\\F \rightarrow \text{num}&\qquad \{F.value=num.value\}\end{array}$$Compute $E.value$ for the root of the parse tree for the expression:$2$ # $3$ & $5$ # $6$ & $4$$200$$180$$160$$40$ Compiler Design gatecse-2004 compiler-design grammar normal syntax-directed-translation + – Kathleen 17.1k views answer comment Share Follow Print See all 8 Comments 8 8 Comments reply skrahul commented Jan 24, 2015 1 flag: ✌ Low quality (zuxxxy “Explanation missing”) i moved by Hira Thakur Dec 24, 2025 reply Follow flag C will be ans. –1 –1 replyShare Digvijay Pandey commented Apr 23, 2015 reply Follow flag GATE 2004_45 original question was : Consider the grammar with the following translation rules and E as the start symbol E→ E1 # T {E.value=E1.value ∗ T.value} | T {E.value=T.value} T→T1 & F {T.value=T1.value + F.value} | F {T.value=F.value} F→num {F.value=num.value} 8 8 replyShare learner_geek commented Jan 11, 2018 reply Follow flag please draw parse tree? 2 2 replyShare neel19 commented May 6, 2021 reply Follow flag Parse tree for this, please. I don’t know how to use E1 and T1 in the tree. 1 1 replyShare Gajanan Purud commented Sep 22, 2023 reply Follow flag C 0 0 replyShare ritiksri8 commented Nov 9, 2024 reply Follow flag Solve without parse tree 1 1 replyShare Tushar Rana commented Jan 14, 2025 reply Follow flag While creating parse tree for this problem if you are confused whether to take which rule just see how much inorder traversal you have done from the given expression. 0 0 replyShare chidambareswar23 commented 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 0 0 replyShare Please log in or register to add a comment.
Best answer 65 65 votes Here # is multiplication and & is addition by semantics rules given in the question. By observation of productions, here &(+) is higher precedence than #(*), because & is far from starting symbol both &,# are left associative So, we can solve the expression as $((2*(3+5))*(6+4)) =160$ Answer is (C). minal answered Jul 15, 2015 • edited Nov 28, 2017 by kenzou minal comment Share Follow See all 9 Comments 9 9 Comments reply Show 6 previous comments jatin khachane 1 commented Nov 14, 2018 reply Follow flag @Sachin+Mittal+1 Sachin sir , So everytime ..to decide precedence and asscociativity operator relation table constructed using Lead and Trails is needed ?? Can't we answer it using this argument "Operator which is at lower level in the grammar is termed to have higher precedence." 0 0 replyShare chirudeepnamini commented Oct 25, 2019 reply Follow flag @Sachin Mittal 1 can you explain a bit more about trailing and leading method.. Or are there any good references for it? 0 0 replyShare svas7246 commented Nov 15, 2021 reply Follow flag Rackson No they are symbolically categorized to differentiate the one on left hand side and the one right hand side if they are different then we would never be able to determine the string 0 0 replyShare Please log in or register to add a comment.
7 7 votes syntax tree with SDT panipuri answered May 11, 2025 panipuri comment Share Follow 0 reply Please log in or register to add a comment.