Home » Compiler Design » Compiler design miscellaneous » Question

Compiler design miscellaneous

  1. 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. + is left associative, while * is right associative
    2. + is right associative, while * is left associative
    3. Both + and * are right associative
    4. Both + and * are left associative
Correct Option: B

+ is right associative (with right recursion from S) is left associative (with left recursion from T)



Your comments will be displayed only after manual approval.