Home » Compiler Design » Compiler design miscellaneous » Question

Compiler design miscellaneous

  1. Consider the grammar
    E → E + n | E × n | n
    For a sentence n + n × n, the handles in the right-sentential form of the reduction are
    1. n, E + n and E + n × n
    2. n, E + n and E + E × n
    3. n, n + n and n + n × n
    4. n, E + n and E × n
Correct Option: D

Given grammar
E " E + n
E " E #n
E " n
String = n + n #n
Right sentential so right most non terminal will be used.
E " E #n {E " E #n}
E + n #n {E " E + n}
n + n #n {E " n}
So during reduction the order is reverse.
So {E " n, E " E + n, E " E #n}



Your comments will be displayed only after manual approval.