15 points
This is the final and most exciting part of your project! This, the Code Generation phase, may be done a number of ways. All of them take as input your AST & Symbol Table:
Input: Your AST & Symbol Table
Output 1: (for up to 15 points) A maze with a robot (use some character like a caret for the Robot)
Output 2: (for up to 10 points) A list of commands like:
Robot Eve is at 0,0 Robot Eve turns left Robot Eve moves 1
Don't try to implement this all at once. Start small. Grading will be:
<= 8 points: Most everything except declarations
<= 10 points: Most language constructs <= 15 points: The programs execute on a screen maze
Hand in Everything, in a nice package. Include the input programs and a screen dump of the programs if you created screens; otherwise include the input and output. Write some programs that have the robot(s) actually do things (climb stairs, navigate walls...)
Method: The symbol table is used to create the world, output assembler directives (if that is your route), and can even be used (with minor enhancements) during interpreting to hold values. The ast can be intepreted a number of ways. Section 11.3 shows code being generated by a simple tree walk. A simple tree walk will suffice for interpreting also. The last question on the exam can also be used as the code generation algorithm or as the basis for interpreting.
You can do this within your current program, by adding a procedure call in the semantic actions section to call the code generator. That way, you'll still have your ast's and symbol tables to use:
Send questions and comment to: Karen Lemone