Home » Compiler Design » Compiler design miscellaneous » Question

Compiler design miscellaneous

  1. Consider the following translation scheme:
    S → FR
    R → *E{print (‘*’); R | ε
    E → F + E {print (‘+’); |F
    F → (S)| id {print (id. value);}
    Here, id is a token that represents an integer and id value represents, the corresponding integer value. For an input ‘2 * 3 + 4’, this translation scheme prints.
    1. 2 * 3 + 4
    2. 2 * + 3 4
    3. 2 3 * 4 +
    4. 2 3 4 + *
Correct Option: D

I figured out the following tree and found the answer will be D. make a tree and perform post order evaluation.



Your comments will be displayed only after manual approval.