Question

The questions in this section are based on the grammar given as the following: prog ->...

The questions in this section are based on the grammar given as the following:

prog -> assign | expr assign -> id = expr expr -> expr + term | expr - term | term term -> factor | factor * term factor -> ( expr ) | id | num id -> A | B | C num -> 0 | 1 | 2 | 3

(2a) What is the associativity of the * operator? (5 points)

(2b) What is the associativity of the + operator? (5 points)

(2c) For the * and + operators, do they have the same precedence, does the * operator have greater precedence than +, or does + have greater precedence than * ? (5 points)

(2d) Using this grammar show a leftmost derivation and a parse tree for the strings in d.1 (10 points)

Show the parse tree as a graphical tree.

(2d) C = (1 + A) * B

(2e) Modify the grammar to add a new operator as it follows. (10 points)

A unary minus operator (-) that has precedence higher than any of *, +, or binary minus.

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

d A181 mu213 20 뉴 have hith preci clenLe than + Thatch) tis

Add a comment
Know the answer?
Add Answer to:
The questions in this section are based on the grammar given as the following: prog ->...
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
ADVERTISEMENT