Similar questions 1 more → · asked again: GATE 1999, Q9
Semantic Analysis & Type Checking

Answer & solution
Answer: Use integer value and length attributes for the supplied fractional grammar. (no official key was published)
This production parses the fractional example; replacing it by dotless S→LL would describe a different grammar.
Use L.val for the integer represented by its bit string and L.len for its number of bits. All attributes are synthesized:
S→L1 . L2: S.val=L1.val+L2.val/2L2.len
S→L: S.val=L.val
L→L1 B: L.val=2*L1.val+B.val; L.len=L1.len+1
L→B: L.val=B.val; L.len=1
B→0: B.val=0
B→1: B.val=1
Appending a bit shifts the prior number left by one, hence multiplication by two. A fractional bit string of length k represents its integer value divided by 2k. For each 101, (val,len) grows (1,1),(2,2),(5,3); S.val=5+5/8=5.625. The length attribute is necessary: .001 and .1 have the same integer value 1 but represent 1/8 and 1/2 respectively. Every semantic expression uses only child attributes, meeting the synthesized-only requirement. Original official wording has not been established by these secondary copies.