...
Programming
October 4, 2023
Time-Complexity
October 4, 2023
Programming
October 4, 2023
Time-Complexity
October 4, 2023

Compiler-Design

Question 6

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
Question 6 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.
Correct Answer: A
Question 6 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.
0 0 votes
Article Rating
Subscribe
Notify of
0 Comments
Inline Feedbacks
View all comments
0
Would love your thoughts, please comment.x
()
x
error: Alert: Content selection is disabled!!