Answer:
bnum -> num base base -> O | D num -> num dig | dig dig -> 0 | 1 | 2 | ... | 9Until now, we have dealt with attribute grammars containing only one attribute. In the above case, we have two different bases and thus we need two attributes. The first attribute is val which we are familiar with. The second needed attribute is type which we will use to help us compute val.
P#2: For each of the following grammar rules, fill in the semantic rule(s) for computing the decimal value of a given string in L(bnum)..
Grammar Rule Semantic Rule(s) ------------ ----------------P#3: Show the annotated parse tree for the following number 123o.
bnum -> num base
base -> o
base -> d
num -> num1 dig
num -> dig
dig -> 0
dig -> 1
dig -> 2
dig -> 3
dig -> 4
dig -> 5
dig -> 6
dig -> 7
dig -> 8
dig -> 9