Question

Considering the following BNF grammar, answer the questions. <prog> - <assign> | <expr> <assign> = <id> = <expr> <expr> := <e

0 0
Add a comment Improve this question Transcribed image text
Answer #1

2a.

An operator is right associative if the variable on the LHS of the associated production is same as the variable to the right of the particular operator on the RHS of the production.

An operator is left associative if the variable on the LHS of the associated production is same as the variable to the left of the particular operator on the RHS of the production.

The production where the * operator appears on RHS is :

<term> :: = <factor> * <term>

In the given production, the variable on LHS is <term> and the same variable <term> is to the right of the * operator on RHS.

Thus, the * operator is right associative.

2b.

If an operator x is present in mth production in the set and another operator y is present in the nth production in the same set and if m < n, then the operator will have higher precedence than x.

In the given set of productions, the production which has the + operator is the 3rd production in the set and the production which has the * operator is the 4th production in the set.

Thus, the * operator has greater precedence than the + operator.

Add a comment
Know the answer?
Add Answer to:
Considering the following BNF grammar, answer the questions. <prog> - <assign> | <expr> <assign> = <id>...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT