1
$\begingroup$

Suppose I want to make a left derivation tree of an expression, but the expression includes operators that are right-to-left associative. Would I still expand the left-most variable first in my tree? For example, the expression a + b ** c ** d where ** is right-to-left associative, and + is left-to-right associative.

$\endgroup$
1
$\begingroup$

In a leftmost derivation, you always expand the leftmost non-terminal, by definition. The question is, what do you expand it to, since you usually have more than one choice.

$\endgroup$
  • $\begingroup$ What is a situation where you would have more than one choice? Not sure I really understand what you're saying there. $\endgroup$ – jimtimbim May 12 '18 at 21:12
  • $\begingroup$ @jimtimbim: If you take a look at expression grammars, you'll see that most non-terminals have more than one possible production. If that still doesn't make sense, try doing some derivations on paper. $\endgroup$ – rici May 12 '18 at 22:10

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.