The only hint that will be given here is that you should pay close attention to the order of the items you end up pushing onto the stack and on the order of the items the old calculator instruction set expected to find on the stack. The solution to the problem is actually an easy one -- we can simply change the order of operands expected by one of the old calculator's operations before we use that part of the compiler from MP4.
statement ::= P expression | V ( expression ) = expression | ( statement { statement } ) | L expression rop expression statement rop ::= > | = | <The new statements are a "begin end" block and a while loop. The former new feature is easy to understand -- one legal form of statement is a parenthesized sequence of statements. The second iterates the indicated statement as long as the indicated relation between the expressions remains true. Here is an example:
V(1)=5 V(2)=1 L V(1) > 0 ( V(2)=V(2)*2 V(1)=V(1)-1 P V(1) P V(2) )What output does this produce?