Question:

For the grammar \[ E\rightarrow E*F\;|\;F+E\;|\;F \] \[ F\rightarrow F-F\;|\;id \] Which statement is true?

Show Hint

Lower grammar levels imply higher operator precedence.
Updated On: Jun 25, 2026
  • * has higher precedence than +
  • - has higher precedence than *
  • + and - have same precedence
  • + has higher precedence than *
Show Solution
collegedunia
Verified By Collegedunia

The Correct Option is B

Solution and Explanation

Concept: Operators appearing lower in the grammar hierarchy have higher precedence.

Step 1:
Observe non-terminal levels.
\[ E\rightarrow E*F \] uses \(F\). \[ F\rightarrow F-F \] contains operator \(-\).

Step 2:
Determine precedence.
Since \(-\) appears inside \(F\), it binds more strongly than operators defined at level \(E\). Thus \[ -\;>\;* \] in precedence.

Step 3:
Write answer.
Therefore option (B) is correct.
Was this answer helpful?
0
0