Discussion
Given the following expression grammar :
E -> E * F | F + E | F
F -> F - F | id which of the following is true ?
Answer: B
The true statement is that - has higher precedence than *.
In an expression grammar, an operator introduced at a lower level (closer to id) binds more tightly. Here * and + are both produced by E, while - is produced by F, which sits below E. So any - is grouped first, inside an F, before * or + combine the results.
Because * and + appear at the same level, neither has higher precedence than the other, which rules out the options giving * over + or + over *. And + and - are at different levels, so they do not have the same precedence.
Post your comment
Please log in or register to post a comment.
Examination Categories
- SSC Exams
- Banking Exams
- Teaching Exams
- Civil Services Exams
- Railways Exams
- Engineering Recruitment Exams
- Defence Exams
- State Government Exams
- Police Exams
- Insurance Exams
- Nursing Exams
- Other Government Exams
- NRA CET
- PG Entrance Exams
- Campus Placement
- MBA Entrance Exams
- CUET and UG Entrance
- Judiciary Exams
- Regulatory Body Exams
- Software Development