GATE CSE 2022 Q65: Evaluating an expression with a syntax-directed translation
- Compiler Design
- 2 marks
- NAT
- No negative marking
Question
Consider the following grammar along with translation rules.
Here and are operators and is a token that represents an integer and represents the corresponding integer value. The set of non-terminals is and a subscripted non-terminal indicates an instance of the non-terminal.
Using this translation scheme, the computed value of for root of the parse tree for the expression is _____________.
Try it: numerical answer: type the value
Show answer and explanation
Answer: 80 (official GATE 2022 final answer key)
Concept used: The grammar fixes precedence and associativity: % (division) binds tighter than # (multiplication), and both are left-associative.
First step: Group as , i.e. .
Full step-by-step solution
Detailed working, common mistakes and linked mock tests will be available with a free GATEiit account. Log-in is coming soon.
Share this question
Source: official GATE 2022 CS question paper and final answer key, organised by IIT Kharagpur. Question paper · Answer key
More Compiler Design PYQs
- 2026 Session 1 · Q27Classify errors in three C string declarations
- 2026 Session 1 · Q28True statements about LL(1) parsing
- 2026 Session 1 · Q42Redundant (common) subexpressions in blocks B4 and B5 of a CFG
- 2026 Session 1 · Q53Compare two SDDs for type declarations
- 2026 Session 2 · Q35Count tokens produced by a lexer for a given string
- 2026 Session 2 · Q41Shift-reduce conflicts in the LR(0) table of a grammar