This lab will prepare you to do Project, Part 4 which uses the abstract syntax tree created in Project, part 3 to generate code.
As in the other labs, the yacc (bison) program is in the left box and input to that program is in the right box. The lex code is below.
When you press the button Edit the text and click me, the following will happen.
Step 0 Run the input and look at the output. Note that pseudocode for a stack machine is produced.
Step 1 Change the yacc/bison grammar so that it recognizes division and will
divide an expression and add that node to the AST tree.
Add an expression to the input and show that the division works.
(You should have this from the last lab.)
Make the divide operation print the correct pseudo-assembler in the
generate function.
Step 2 Now add code to generate pseudo assembly for the pow()
funtion (^) to get the power of two numbers,
adding the pow node to the ast tree (as done in the last lab).
Step 3 On to Project, part 4! Now you are a compiler designer!