• Courses
  • Tutorials
  • Jobs
  • Practice
  • Contests

GATE | CSE 2023 | Question 60

Consider the syntax-directed translation given by the following grammar and semantic rules. Here N, I, F and B are non-terminals. N is the starting non-terminal, and #, 0, and 1 are lexical tokens corresponding to input letters “#”, “0” and “1”, respectively. X.val denotes the synthesized attribute (a numeric value) associated with a non-terminal X. I1 and F1 denote occurrences of I and F on the right-hand side of a production, respectively. For the tokens 0 and 1, 0.val = 0 and 1.val = 1.

N	→	I # F	N.val = I.val + F.val
I	→	I1 B	I.val = (2 I1.val )+ B.val
I	→	B	    I.val = B.val

F	→	B F1	F.val = 2 (B.val + F1.val )
1
F	→	B	F.val = 2 B.val
B	→	0	B.val = 0.val
B	→	1	B.val = 1.val

The value computed by the translation scheme for the input string

10#011

is. (Rounded off to three decimal places)

(A)

2.375

(B)

6.352

(C)

4.750

(D)

0.125

Answer

Please comment below if you find anything wrong in the above post
Feeling lost in the world of random DSA topics, wasting time without progress? It's time for a change! Join our DSA course, where we'll guide you on an exciting journey to master DSA efficiently and on schedule.
Ready to dive in? Explore our Free Demo Content and join our DSA course, trusted by over 100,000 geeks!

Last Updated :
Share your thoughts in the comments