Consider the following grammar: E → E # X | X X → T − X | X * T | T T → T + F…

Consider the following grammar:

E → E # X | X
X → T − X | X * T | T
T → T + F | F
F → (E) | id

Here, id stands for an identifier. The grammar is used to generate valid arithmetic expressions in a hypothetical language. Consider the following statements:

(i) # associates from left and has the least precedence.
(ii) − associates from left and has higher precedence than #.
(iii) + associates from left and has the highest precedence.
(iv) * associates from left and has the same precedence as −.

Which option is correct?

  1. A.

    Only (i), (iii), and (iv) are true

  2. B.

    Only (ii) and (iii) are true

  3. C.

    Only (ii), (iii), and (iv) are true

  4. D.

    All of the above

Attempted by 29 students.

Sign up free to check your answer

Sign up free

Explore the full course: Gate Guidance By Sanchit Sir

Loading lesson…