1k views

In the following grammar \begin{align*} X &::= X \oplus Y \mid Y \\ Y&::= Z * Y \mid Z\\ Z&::= id \end{align*}
Which of the following is true?

1. '$\oplus$' is left associative while '$*$' is right associative
2. Both '$\oplus$' and '$*$' are left associative
3. '$\oplus$' is right associative while '$*$' is left associative
4. None of the above
edited | 1k views

It will be A. For multiple '$\oplus$', the derivation is possible only via '$X$' which is on left side of '$\oplus$' in the production. Hence it is left associative.

For multiple '$*$', the derivation is possible only via '$Y$' which is on the right side of '$*$' in the production. Hence it is right associative.

If both left and right derivations were possible, the grammar would have been ambiguous and we couldn't have given associativity.
edited by
0
When we create parse tree for the above grammar then  * is computed after x-or. So whether this is correct or not if the answer is 3..
0

A is the most apt answer.
But, * is left associative

https://www.programiz.com/c-programming/precedence-associativity-operators

0
U hav to calculate the associativity on the basis of given grammar  ....
0
understood, thanks :)
0
If both left and right derivations were possible, the grammar would have been ambiguous and we couldn't have given associativity.this is nice point gate keeda
0
What will be the answer A or D.
0
$A)$ is the correct answer.

and precedence$:\ast > \oplus$

1
2