Computer-Networks
October 8, 2023Compiler-Design
October 8, 2023Compiler-Design
Question 42 |
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:
n, E + n and E + n × n | |
n, E + n and E + E × n
| |
n, n + n and n + n × n | |
n, E + n and E × n |
Question 42 Explanation:
E → E + n {Applying E → E+n}
→ E + E * n {Applying E → E * n}
→ E + n * n {Applying E → n}
→ n + n * n {Applying E → n}
We use n, E+n, E×n reductions to get a sentence n+n*n.
→ E + E * n {Applying E → E * n}
→ E + n * n {Applying E → n}
→ n + n * n {Applying E → n}
We use n, E+n, E×n reductions to get a sentence n+n*n.
Correct Answer: D
Question 42 Explanation:
E → E + n {Applying E → E+n}
→ E + E * n {Applying E → E * n}
→ E + n * n {Applying E → n}
→ n + n * n {Applying E → n}
We use n, E+n, E×n reductions to get a sentence n+n*n.
→ E + E * n {Applying E → E * n}
→ E + n * n {Applying E → n}
→ n + n * n {Applying E → n}
We use n, E+n, E×n reductions to get a sentence n+n*n.
Subscribe
Login
0 Comments