Associativity-and-Precedence

Question 1

Consider the following parse tree for the expression a#b$c$d#e#f, involving two binary operators $ and #.

Which one of the following is correct for the given parse tree?

A
$ has higher precedence and is left associative; # is right associative
B
# has higher precedence and is left associative; $ is right associative
C
$ has higher precedence and is left associative; # is left associative
D
# has higher precedence and is right associative; $ is left associative
       Compiler-Design       Associativity-and-Precedence       GATE 2018       Video-Explanation
Question 1 Explanation: 
Since $ will be evaluated before # so $ has higher precedence and the left $ i.e., in b$c$d the left “$” (i.e., b$c) will be evaluated first so it is left associative, whereas # is right associative (as in d#e#f) , the right one (i.e., e#f) will be evaluated first.
There is 1 question to complete.

Access quiz wise question and answers by becoming as a solutions adda PRO SUBSCRIBER with Ad-Free content

Register Now

If you have registered and made your payment please contact solutionsadda.in@gmail.com to get access