GATE CS 2014, set 2 · Question 27 · Compiler Design · Multiple choice (MCQ) · 1 mark · −1/3 for a wrong answer

Consider the grammar defined by the following production rules, with two operators * and +
S → T * P ; T → U | T * U ; P → Q + P | Q ; Q → Id ; U → Id
Which one of the following is TRUE?

  1. (A) + is left associative, while * is right associative
  2. (B) + is right associative, while * is left associative
  3. (C) Both + and * are right associative
  4. (D) Both + and * are left associative
Answer

Answer (B)

Answer from the official GATE CS 2014 answer key.

The step-by-step solution, where available, is part of GATE CS Pro. See what Pro includes