Given the following expression grammar: E → E ∗ F ∣ F + E ∣ F F → F − F ∣ id…
2015
Given the following expression grammar:
E → E ∗ F ∣ F + E ∣ F
F → F − F ∣ id
Which of the following is true? ISRO 2015
Answer: B. - has higher precedence than * — In the provided grammar, E is the start symbol and F is a subordinate non-terminal. Operators defined in productions for F (specifically -) have higher…
- A.
* has higher precedence than +
- B.
- has higher precedence than *
- C.
+ and - have same precedence
- D.
+ has higher precedence than *
Attempted by 306 students.
Show answer & explanation
Correct answer: B
In the provided grammar, E is the start symbol and F is a subordinate non-terminal. Operators defined in productions for F (specifically -) have higher precedence than operators defined in productions for E (specifically * and +). Consequently, the subtraction operator binds more tightly than multiplication.
A video solution is available for this question — log in and enroll to watch it.
Explore the full course: Iocl Engineers Officers Grade A Paper 2