Question

2. Consider the following grammar:                         <assign> à <id> = <expr>       

2. Consider the following grammar:

                        <assign> à <id> = <expr>

           <id>   à A | B | C

           <expr> à <id> + <expr>

                     | <id> * <expr>

                     | ( <expr> )

                     | <id>

Show a parse tree and leftmost derivation for the following statements:

(a)        A = ( A + B ) * C

(b)        A = A * ( B + C )

3. [10 Points] Show that the following grammar is ambiguous.

           <S> à <A>

           <A>   à <A> + <A> | <id>

           <id> à a | b | c

4. [10 Points] Compute the weakest precondition for each of the following assignment statements with their given postconditions.

(a)        a = 2 * (b – 1) – 1 {a > 0}

(b)        a = a + 2 * b 1 {a > 1}

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

a莫 To domina 2. a +a + 2-0 2-0Sub is pse 2 Giuen atat 기 2. pre se condi

Add a comment
Know the answer?
Add Answer to:
2. Consider the following grammar:                         <assign> à <id> = <expr>       
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